]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't require mouse for prompting via dialog boxes
authorEli Zaretskii <eliz@gnu.org>
Sat, 29 Jan 2022 15:54:43 +0000 (17:54 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 29 Jan 2022 15:54:43 +0000 (17:54 +0200)
* lisp/subr.el (use-dialog-box-p): Don't require mouse support,
and allow dialog boxes when invoked via the TTY menus without a
mouse.
(from--tty-menu-p): New internal variable.

* lisp/menu-bar.el (popup-menu): Bind 'from--tty-menu-p' when
invoking a command from the menu.

lisp/menu-bar.el
lisp/subr.el

index 817c2d485e8d8dc8ee50420b4e7f373f15f38891..b6dbf209ec1e2685d6f72931d4e8987fbb820bc2 100644 (file)
@@ -2629,8 +2629,11 @@ FROM-MENU-BAR, if non-nil, means we are dropping one of menu-bar's menus."
       ;; `setup-specified-language-environment', for instance,
       ;; expects this to be set from a menu keymap.
       (setq last-command-event (car (last event)))
-      ;; mouse-major-mode-menu was using `command-execute' instead.
-      (call-interactively cmd))))
+      (setq from--tty-menu-p nil)
+      ;; Signal use-dialog-box-p this command was invoked from a menu.
+      (let ((from--tty-menu-p t))
+        ;; mouse-major-mode-menu was using `command-execute' instead.
+        (call-interactively cmd)))))
 
 (defun popup-menu-normalize-position (position)
   "Convert the POSITION to the form which `popup-menu' expects internally.
index 4b4412a883e3bf6d53076ad704b93b00c163b8f8..6d70d9e8d65bc1ef40bca0410f02ac14f4eb7f4b 100644 (file)
@@ -3249,11 +3249,14 @@ 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.")
 
+
+(defvar from--tty-menu-p nil
+  "Non-nil means the current command was invoked from a TTY menu.")
 (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)
+  "Say whether the current command should promp the user via GUI dialog box."
+  (and last-input-event                 ; not during startup
+       (or (listp last-nonmenu-event)   ; invoked by a mouse event
+           from--tty-menu-p)             ; invoked via TTY menu
        use-dialog-box))
 
 (defun y-or-n-p (prompt)