In batch mode, avoid killing Emacs with C-g in the minibuffer

* src/keyboard.c (Fcommand_error_default_function): Don't kill emacs
when handling the minibuffer-quit condition (bug#48603).
This commit is contained in:
Miha Rihtaršič 2021-09-01 10:10:44 +02:00 committed by Lars Ingebrigtsen
parent a0be0cdbd2
commit 45793b195c

View file

@ -1009,25 +1009,28 @@ Default value of `command-error-function'. */)
(Lisp_Object data, Lisp_Object context, Lisp_Object signal) (Lisp_Object data, Lisp_Object context, Lisp_Object signal)
{ {
struct frame *sf = SELECTED_FRAME (); struct frame *sf = SELECTED_FRAME ();
Lisp_Object conditions; Lisp_Object conditions = Fget (XCAR (data), Qerror_conditions);
int is_minibuffer_quit = !NILP (Fmemq (Qminibuffer_quit, conditions));
CHECK_STRING (context); CHECK_STRING (context);
/* If the window system or terminal frame hasn't been initialized /* If the window system or terminal frame hasn't been initialized
yet, or we're not interactive, write the message to stderr and exit. */ yet, or we're not interactive, write the message to stderr and exit.
if (!sf->glyphs_initialized_p Don't do this for the minibuffer-quit condition. */
/* The initial frame is a special non-displaying frame. It if (!is_minibuffer_quit
will be current in daemon mode when there are no frames && (!sf->glyphs_initialized_p
to display, and in non-daemon mode before the real frame /* The initial frame is a special non-displaying frame. It
has finished initializing. If an error is thrown in the will be current in daemon mode when there are no frames
latter case while creating the frame, then the frame to display, and in non-daemon mode before the real frame
will never be displayed, so the safest thing to do is has finished initializing. If an error is thrown in the
write to stderr and quit. In daemon mode, there are latter case while creating the frame, then the frame
many other potential errors that do not prevent frames will never be displayed, so the safest thing to do is
from being created, so continuing as normal is better in write to stderr and quit. In daemon mode, there are
that case. */ many other potential errors that do not prevent frames
|| (!IS_DAEMON && FRAME_INITIAL_P (sf)) from being created, so continuing as normal is better in
|| noninteractive) that case. */
|| (!IS_DAEMON && FRAME_INITIAL_P (sf))
|| noninteractive))
{ {
print_error_message (data, Qexternal_debugging_output, print_error_message (data, Qexternal_debugging_output,
SSDATA (context), signal); SSDATA (context), signal);
@ -1036,12 +1039,10 @@ Default value of `command-error-function'. */)
} }
else else
{ {
conditions = Fget (XCAR (data), Qerror_conditions);
clear_message (1, 0); clear_message (1, 0);
message_log_maybe_newline (); message_log_maybe_newline ();
if (!NILP (Fmemq (Qminibuffer_quit, conditions))) if (is_minibuffer_quit)
{ {
Fding (Qt); Fding (Qt);
} }