diff options
| author | Lars Ingebrigtsen | 2022-01-27 19:54:48 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-01-27 19:56:29 +0100 |
| commit | b8ddd94aacb4478600d528e0080aff334e44e0f6 (patch) | |
| tree | a2b4ab34fdb08c8f28c85feb482d2734a2c2388f | |
| parent | 10c680551e899805a6de7360e9b65986fd87df72 (diff) | |
| download | emacs-b8ddd94aacb4478600d528e0080aff334e44e0f6.tar.gz emacs-b8ddd94aacb4478600d528e0080aff334e44e0f6.zip | |
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.
| -rw-r--r-- | lisp/files.el | 10 | ||||
| -rw-r--r-- | lisp/subr.el | 12 |
2 files changed, 17 insertions, 5 deletions
diff --git a/lisp/files.el b/lisp/files.el index 79c336f7825..9e8afc8d527 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." | |||
| 7752 | (interactive "P") | 7752 | (interactive "P") |
| 7753 | ;; Don't use save-some-buffers-default-predicate, because we want | 7753 | ;; Don't use save-some-buffers-default-predicate, because we want |
| 7754 | ;; to ask about all the buffers before killing Emacs. | 7754 | ;; to ask about all the buffers before killing Emacs. |
| 7755 | (save-some-buffers arg t) | 7755 | (if (use-dialog-box-p) |
| 7756 | (pcase (x-popup-dialog | ||
| 7757 | t `("Unsaved Buffers" | ||
| 7758 | ("Close Without Saving" . no-save) | ||
| 7759 | ("Save All" . save-all) | ||
| 7760 | ("Cancel" . cancel))) | ||
| 7761 | ('cancel (user-error "Exit cancelled")) | ||
| 7762 | ('save-all (save-some-buffers t))) | ||
| 7763 | (save-some-buffers arg t)) | ||
| 7756 | (let ((confirm confirm-kill-emacs)) | 7764 | (let ((confirm confirm-kill-emacs)) |
| 7757 | (and | 7765 | (and |
| 7758 | (or (not (memq t (mapcar (lambda (buf) | 7766 | (or (not (memq t (mapcar (lambda (buf) |
diff --git a/lisp/subr.el b/lisp/subr.el index 29b9b6dfcf5..4b4412a883e 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3249,6 +3249,13 @@ switch back again to the minibuffer before entering the | |||
| 3249 | character. This is not possible when using `read-key', but using | 3249 | character. This is not possible when using `read-key', but using |
| 3250 | `read-key' may be less confusing to some users.") | 3250 | `read-key' may be less confusing to some users.") |
| 3251 | 3251 | ||
| 3252 | (defun use-dialog-box-p () | ||
| 3253 | "Say whether the user should be prompted with a dialog popup box." | ||
| 3254 | (and (display-popup-menus-p) | ||
| 3255 | last-input-event ; not during startup | ||
| 3256 | (listp last-nonmenu-event) | ||
| 3257 | use-dialog-box)) | ||
| 3258 | |||
| 3252 | (defun y-or-n-p (prompt) | 3259 | (defun y-or-n-p (prompt) |
| 3253 | "Ask user a \"y or n\" question. | 3260 | "Ask user a \"y or n\" question. |
| 3254 | Return t if answer is \"y\" and nil if it is \"n\". | 3261 | Return t if answer is \"y\" and nil if it is \"n\". |
| @@ -3308,10 +3315,7 @@ like) while `y-or-n-p' is running)." | |||
| 3308 | ((and (member str '("h" "H")) help-form) (print help-form)) | 3315 | ((and (member str '("h" "H")) help-form) (print help-form)) |
| 3309 | (t (setq temp-prompt (concat "Please answer y or n. " | 3316 | (t (setq temp-prompt (concat "Please answer y or n. " |
| 3310 | prompt)))))))) | 3317 | prompt)))))))) |
| 3311 | ((and (display-popup-menus-p) | 3318 | ((use-dialog-box-p) |
| 3312 | last-input-event ; not during startup | ||
| 3313 | (listp last-nonmenu-event) | ||
| 3314 | use-dialog-box) | ||
| 3315 | (setq prompt (funcall padded prompt t) | 3319 | (setq prompt (funcall padded prompt t) |
| 3316 | answer (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) | 3320 | answer (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) |
| 3317 | (y-or-n-p-use-read-key | 3321 | (y-or-n-p-use-read-key |