aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2023-02-19 11:29:32 +0200
committerEli Zaretskii2023-02-19 11:29:32 +0200
commit4faebba2fedcb428838fbda8537140841bdd8aa0 (patch)
treec9041ffe2cba7f0413bb722dac43c60e98e48c16
parentcd05fca5f78048cb867be2d5f0857f6997f12ccc (diff)
downloademacs-4faebba2fedcb428838fbda8537140841bdd8aa0.tar.gz
emacs-4faebba2fedcb428838fbda8537140841bdd8aa0.zip
Fix invocation of File->Close from the menu bar
* lisp/simple.el (kill-buffer--possibly-save): Don't request LONG-FORM from 'read-multiple-choice' if GUI dialog should be used. * lisp/emacs-lisp/rmc.el (read-multiple-choice): Doc fix. (read-multiple-choice--short-answers): Don't append "?" to CHOICES and don't display the prompt in the echo area if GUI dialog is used. Use 'use-dialog-box-p'. (Bug#61553)
-rw-r--r--lisp/emacs-lisp/rmc.el27
-rw-r--r--lisp/simple.el3
2 files changed, 16 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index 542c96512f5..bfd7434be9a 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -162,8 +162,10 @@ dialogs. Otherwise, the function will always use text-mode dialogs.
162 162
163The return value is the matching entry from the CHOICES list. 163The return value is the matching entry from the CHOICES list.
164 164
165If LONG-FORM, do a `completing-read' over the NAME elements in 165If LONG-FORM is non-nil, do a `completing-read' over the NAME elements
166CHOICES instead. 166in CHOICES instead. In this case, GUI dialog is not used, regardless
167of the value of `use-dialog-box' and whether the function was invoked
168via a mouse gesture.
167 169
168Usage example: 170Usage example:
169 171
@@ -177,8 +179,9 @@ Usage example:
177 prompt choices help-string show-help))) 179 prompt choices help-string show-help)))
178 180
179(defun read-multiple-choice--short-answers (prompt choices help-string show-help) 181(defun read-multiple-choice--short-answers (prompt choices help-string show-help)
180 (let* ((prompt-choices 182 (let* ((dialog-p (use-dialog-box-p))
181 (if show-help choices (append choices '((?? "?"))))) 183 (prompt-choices
184 (if (or show-help dialog-p) choices (append choices '((?? "?")))))
182 (altered-names (mapcar #'rmc--add-key-description prompt-choices)) 185 (altered-names (mapcar #'rmc--add-key-description prompt-choices))
183 (full-prompt 186 (full-prompt
184 (format 187 (format
@@ -192,16 +195,14 @@ Usage example:
192 (setq buf (rmc--show-help prompt help-string show-help 195 (setq buf (rmc--show-help prompt help-string show-help
193 choices altered-names))) 196 choices altered-names)))
194 (while (not tchar) 197 (while (not tchar)
195 (message "%s%s" 198 (unless dialog-p
196 (if wrong-char 199 (message "%s%s"
197 "Invalid choice. " 200 (if wrong-char
198 "") 201 "Invalid choice. "
199 full-prompt) 202 "")
203 full-prompt))
200 (setq tchar 204 (setq tchar
201 (if (and (display-popup-menus-p) 205 (if dialog-p
202 last-input-event ; not during startup
203 (consp last-nonmenu-event)
204 use-dialog-box)
205 (x-popup-dialog 206 (x-popup-dialog
206 t 207 t
207 (cons prompt 208 (cons prompt
diff --git a/lisp/simple.el b/lisp/simple.el
index c2d10b4dcb4..27aeb2fa8cc 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10801,7 +10801,8 @@ If the buffer doesn't exist, create it first."
10801 '((?y "yes" "kill buffer without saving") 10801 '((?y "yes" "kill buffer without saving")
10802 (?n "no" "exit without doing anything") 10802 (?n "no" "exit without doing anything")
10803 (?s "save and then kill" "save the buffer and then kill it")) 10803 (?s "save and then kill" "save the buffer and then kill it"))
10804 nil nil (not use-short-answers))))) 10804 nil nil (and (not use-short-answers)
10805 (not (use-dialog-box-p)))))))
10805 (if (equal response "no") 10806 (if (equal response "no")
10806 nil 10807 nil
10807 (unless (equal response "yes") 10808 (unless (equal response "yes")