From: Eli Zaretskii Date: Sat, 29 Jan 2022 15:54:43 +0000 (+0200) Subject: Don't require mouse for prompting via dialog boxes X-Git-Tag: emacs-29.0.90~2664 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f7b408ec5001e777bf5facc81fcb815be0e1f5f6;p=emacs.git Don't require mouse for prompting via dialog boxes * 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. --- diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 817c2d485e8..b6dbf209ec1 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -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. diff --git a/lisp/subr.el b/lisp/subr.el index 4b4412a883e..6d70d9e8d65 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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)