]> git.eshelyaron.com Git - emacs.git/commitdiff
Make the save buffers prompt from Quit Emacs menu more understandable
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 27 Jan 2022 18:54:48 +0000 (19:54 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 27 Jan 2022 18:56:29 +0000 (19:56 +0100)
* lisp/files.el (save-buffers-kill-emacs): Use a much simpler (and
more understandable) prompt when exiting Emacs from the menu bar
(bug#4980).

* lisp/subr.el (use-dialog-box-p): Separate out into its own
function for reuse...
(y-or-n-p): ... from here.

lisp/files.el
lisp/subr.el

index 79c336f7825fd9629af1654215ee315f0e5ca2f9..9e8afc8d527a5cef16cd1f5baeaf1e2b364d6afd 100644 (file)
@@ -7752,7 +7752,15 @@ if any returns nil.  If `confirm-kill-emacs' is non-nil, calls it."
   (interactive "P")
   ;; Don't use save-some-buffers-default-predicate, because we want
   ;; to ask about all the buffers before killing Emacs.
-  (save-some-buffers arg t)
+  (if (use-dialog-box-p)
+      (pcase (x-popup-dialog
+              t `("Unsaved Buffers"
+                  ("Close Without Saving" . no-save)
+                  ("Save All" . save-all)
+                  ("Cancel" . cancel)))
+        ('cancel (user-error "Exit cancelled"))
+        ('save-all (save-some-buffers t)))
+    (save-some-buffers arg t))
   (let ((confirm confirm-kill-emacs))
     (and
      (or (not (memq t (mapcar (lambda (buf)
index 29b9b6dfcf5d3a5e72776be6b16dd78126822393..4b4412a883e3bf6d53076ad704b93b00c163b8f8 100644 (file)
@@ -3249,6 +3249,13 @@ switch back again to the minibuffer before entering the
 character.  This is not possible when using `read-key', but using
 `read-key' may be less confusing to some users.")
 
+(defun use-dialog-box-p ()
+  "Say whether the user should be prompted with a dialog popup box."
+  (and (display-popup-menus-p)
+       last-input-event                 ; not during startup
+       (listp last-nonmenu-event)
+       use-dialog-box))
+
 (defun y-or-n-p (prompt)
   "Ask user a \"y or n\" question.
 Return t if answer is \"y\" and nil if it is \"n\".
@@ -3308,10 +3315,7 @@ like) while `y-or-n-p' is running)."
                  ((and (member str '("h" "H")) help-form) (print help-form))
                  (t (setq temp-prompt (concat "Please answer y or n.  "
                                               prompt))))))))
-     ((and (display-popup-menus-p)
-           last-input-event             ; not during startup
-          (listp last-nonmenu-event)
-          use-dialog-box)
+     ((use-dialog-box-p)
       (setq prompt (funcall padded prompt t)
            answer (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip)))))
      (y-or-n-p-use-read-key