bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61553: 29.0.60; Inconsistent use of dialog boxes by read-multiple-ch


From: Eli Zaretskii
Subject: bug#61553: 29.0.60; Inconsistent use of dialog boxes by read-multiple-choice
Date: Thu, 16 Feb 2023 19:59:08 +0200

> From: Augusto Stoffel <arstoffel@gmail.com>
> Date: Thu, 16 Feb 2023 17:19:30 +0100
> 
> 
> In the scratch buffer of emacs -Q, type
> 
>     (read-multiple-choice "Question" '((?y "yes") (?n "no")))
> 
> then click, on the menu bar, "Lisp-Interaction -> Evaluate and Print".
> As expected, I see a dialog box.
> 
> Now repeat the same using the long-form style:
> 
>     (read-multiple-choice "Question" '((?y "yes") (?n "no")) nil nil t)
> 
> Then I get a minibuffer query, but I would expect a dialog box in the
> case as well.

The long-form call does a completing-read, and we don't support that
via GUI dialogs (how could we?).

> As a more concrete example, when clicking the "File -> Close" menu item
> in a modified buffer, I would expect a to always get a dialog box for
> the "buffer modified, kill anyway?" question.  (assuming of course
> use-dialog-box is t).  Currently, one gets a minibuffer query by
> default.  This change from mouse interaction to keyboard interaction
> seems unexpected to me.

Does the patch below give good results in that case?

diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index 542c965..8ab1f86 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -177,8 +177,9 @@ read-multiple-choice
      prompt choices help-string show-help)))
 
 (defun read-multiple-choice--short-answers (prompt choices help-string 
show-help)
-  (let* ((prompt-choices
-          (if show-help choices (append choices '((?? "?")))))
+  (let* ((dialog-p (use-dialog-box-p))
+         (prompt-choices
+          (if (or show-help dialog-p) choices (append choices '((?? "?")))))
          (altered-names (mapcar #'rmc--add-key-description prompt-choices))
          (full-prompt
           (format
@@ -192,11 +193,12 @@ read-multiple-choice--short-answers
             (setq buf (rmc--show-help prompt help-string show-help
                                       choices altered-names)))
        (while (not tchar)
-         (message "%s%s"
-                   (if wrong-char
-                       "Invalid choice.  "
-                     "")
-                   full-prompt)
+          (unless dialog-p
+           (message "%s%s"
+                     (if wrong-char
+                         "Invalid choice.  "
+                       "")
+                     full-prompt))
           (setq tchar
                 (if (and (display-popup-menus-p)
                          last-input-event ; not during startup
diff --git a/lisp/simple.el b/lisp/simple.el
index c58acfe..d0ba7dc 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10799,7 +10799,8 @@ kill-buffer--possibly-save
            '((?y "yes" "kill buffer without saving")
              (?n "no" "exit without doing anything")
              (?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")
         nil
       (unless (equal response "yes")





reply via email to

[Prev in Thread] Current Thread [Next in Thread]