more momentous questions, since it requires three or four characters to
answer.
- If either of these functions is called in a command that was invoked
-using the mouse---more precisely, if @code{last-nonmenu-event}
-(@pxref{Command Loop Info}) is either @code{nil} or a list---then it
-uses a dialog box or pop-up menu to ask the question. Otherwise, it
-uses keyboard input. You can force use either of the mouse or of keyboard
-input by binding @code{last-nonmenu-event} to a suitable value around
-the call.
+ If either of these functions is called in a command that was
+invoked using the mouse or some other window-system gesture, or in a
+command invoked via a menu, then they use a dialog box or pop-up menu
+to ask the question if dialog boxes are supported. Otherwise, they
+use keyboard input. You can force use either of the mouse or of
+keyboard input by binding @code{last-nonmenu-event} to a suitable
+value around the call---bind it to @code{t} to force keyboard
+interaction, and to a list to force dialog boxes.
Both @code{yes-or-no-p} and @code{y-or-n-p} use the minibuffer.
prompting. But if @var{no-cursor-in-echo-area} is non-@code{nil}, it
does not do that.
-If @code{map-y-or-n-p} is called in a command that was invoked using the
-mouse---more precisely, if @code{last-nonmenu-event} (@pxref{Command
-Loop Info}) is either @code{nil} or a list---then it uses a dialog box
-or pop-up menu to ask the question. In this case, it does not use
-keyboard input or the echo area. You can force use either of the mouse or
-of keyboard input by binding @code{last-nonmenu-event} to a suitable
-value around the call.
+If @code{map-y-or-n-p} is called in a command that was invoked using
+the mouse or some other window-system gesture, or a command invoked
+via a menu, then it uses a dialog box or pop-up menu to ask the
+question if dialog boxes are supported. In this case, it does not use
+keyboard input or the echo area. You can force use either of the
+mouse or of keyboard input by binding @code{last-nonmenu-event} to a
+suitable value around the call---bind it to @code{t} to force keyboard
+interaction, and to a list to force dialog boxes.
The return value of @code{map-y-or-n-p} is the number of objects acted on.
@end defun
"Return non-nil if the current command should prompt the user via a dialog box."
(and last-input-event ; not during startup
(or (consp last-nonmenu-event) ; invoked by a mouse event
+ (and (null last-nonmenu-event)
+ (consp last-input-event))
from--tty-menu-p) ; invoked via TTY menu
use-dialog-box))
responses, perform the requested window recentering or scrolling
and ask again.
-Under a windowing system a dialog box will be used if `last-nonmenu-event'
-is nil and `use-dialog-box' is non-nil.
+If dialog boxes are supported, this function will use a dialog box
+if `use-dialog-box' is non-nil and the last input event was produced
+by a mouse, or by some window-system gesture, or via a menu.
By default, this function uses the minibuffer to read the key.
If `y-or-n-p-use-read-key' is non-nil, `read-key' is used
If the `use-short-answers' variable is non-nil, instead of asking for
\"yes\" or \"no\", this function will ask for \"y\" or \"n\".
-If dialog boxes are supported, a dialog box will be used
-if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */)
+If dialog boxes are supported, this function will use a dialog box
+if `use-dialog-box' is non-nil and the last input event was produced
+by a mouse, or by some window-system gesture, or via a menu. */)
(Lisp_Object prompt)
{
- Lisp_Object ans;
+ Lisp_Object ans, val;
CHECK_STRING (prompt);
- if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
- && use_dialog_box && ! NILP (last_input_event))
+ if (!NILP (last_input_event)
+ && (CONSP (last_nonmenu_event)
+ || (NILP (last_nonmenu_event) && CONSP (last_input_event))
+ || (val = find_symbol_value (Qfrom__tty_menu_p),
+ (!NILP (val) && !EQ (val, Qunbound))))
+ && use_dialog_box)
{
Lisp_Object pane, menu, obj;
redisplay_preserve_echo_area (4);
defsubr (&Sbuffer_line_statistics);
DEFSYM (Qreal_this_command, "real-this-command");
+ DEFSYM (Qfrom__tty_menu_p, "from--tty-menu-p");
}