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)
This commit is contained in:
Eli Zaretskii 2023-02-19 11:29:32 +02:00
parent cd05fca5f7
commit 4faebba2fe
2 changed files with 16 additions and 14 deletions

View file

@ -162,8 +162,10 @@ dialogs. Otherwise, the function will always use text-mode dialogs.
The return value is the matching entry from the CHOICES list. The return value is the matching entry from the CHOICES list.
If LONG-FORM, do a `completing-read' over the NAME elements in If LONG-FORM is non-nil, do a `completing-read' over the NAME elements
CHOICES instead. in CHOICES instead. In this case, GUI dialog is not used, regardless
of the value of `use-dialog-box' and whether the function was invoked
via a mouse gesture.
Usage example: Usage example:
@ -177,8 +179,9 @@ Usage example:
prompt choices help-string show-help))) prompt choices help-string show-help)))
(defun read-multiple-choice--short-answers (prompt choices help-string show-help) (defun read-multiple-choice--short-answers (prompt choices help-string show-help)
(let* ((prompt-choices (let* ((dialog-p (use-dialog-box-p))
(if show-help choices (append choices '((?? "?"))))) (prompt-choices
(if (or show-help dialog-p) choices (append choices '((?? "?")))))
(altered-names (mapcar #'rmc--add-key-description prompt-choices)) (altered-names (mapcar #'rmc--add-key-description prompt-choices))
(full-prompt (full-prompt
(format (format
@ -192,16 +195,14 @@ Usage example:
(setq buf (rmc--show-help prompt help-string show-help (setq buf (rmc--show-help prompt help-string show-help
choices altered-names))) choices altered-names)))
(while (not tchar) (while (not tchar)
(unless dialog-p
(message "%s%s" (message "%s%s"
(if wrong-char (if wrong-char
"Invalid choice. " "Invalid choice. "
"") "")
full-prompt) full-prompt))
(setq tchar (setq tchar
(if (and (display-popup-menus-p) (if dialog-p
last-input-event ; not during startup
(consp last-nonmenu-event)
use-dialog-box)
(x-popup-dialog (x-popup-dialog
t t
(cons prompt (cons prompt

View file

@ -10801,7 +10801,8 @@ If the buffer doesn't exist, create it first."
'((?y "yes" "kill buffer without saving") '((?y "yes" "kill buffer without saving")
(?n "no" "exit without doing anything") (?n "no" "exit without doing anything")
(?s "save and then kill" "save the buffer and then kill it")) (?s "save and then kill" "save the buffer and then kill it"))
nil nil (not use-short-answers))))) nil nil (and (not use-short-answers)
(not (use-dialog-box-p)))))))
(if (equal response "no") (if (equal response "no")
nil nil
(unless (equal response "yes") (unless (equal response "yes")