;; `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.
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)