[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b8ddd94aac: Make the save buffers prompt from Quit Emacs menu mor
From: |
Lars Ingebrigtsen |
Subject: |
master b8ddd94aac: Make the save buffers prompt from Quit Emacs menu more understandable |
Date: |
Thu, 27 Jan 2022 13:56:37 -0500 (EST) |
branch: master
commit b8ddd94aacb4478600d528e0080aff334e44e0f6
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make the save buffers prompt from Quit Emacs menu more understandable
* 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 | 10 +++++++++-
lisp/subr.el | 12 ++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/lisp/files.el b/lisp/files.el
index 79c336f782..9e8afc8d52 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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)
diff --git a/lisp/subr.el b/lisp/subr.el
index 29b9b6dfcf..4b4412a883 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b8ddd94aac: Make the save buffers prompt from Quit Emacs menu more understandable,
Lars Ingebrigtsen <=