diff options
Diffstat (limited to 'src/keyboard.c')
-rw-r--r-- | src/keyboard.c | 109 |
1 files changed, 30 insertions, 79 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 6aad0acc656..a86e7c5f8e4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -87,7 +87,7 @@ char const DEV_TTY[] = "/dev/tty"; volatile int interrupt_input_blocked; /* True means an input interrupt or alarm signal has arrived. - The QUIT macro checks this. */ + The maybe_quit function checks this. */ volatile bool pending_signals; #define KBD_BUFFER_SIZE 4096 @@ -169,9 +169,6 @@ struct kboard *echo_kboard; Lisp_Object echo_message_buffer; -/* True means C-g should cause immediate error-signal. */ -bool immediate_quit; - /* Character that causes a quit. Normally C-g. If we are running on an ordinary terminal, this must be an ordinary @@ -1416,7 +1413,7 @@ command_loop_1 (void) if (!NILP (Vquit_flag)) { Vexecuting_kbd_macro = Qt; - QUIT; /* Make some noise. */ + maybe_quit (); /* Make some noise. */ /* Will return since macro now empty. */ } } @@ -3584,16 +3581,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, as input, set quit-flag to cause an interrupt. */ if (!NILP (Vthrow_on_input) && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) - { - Vquit_flag = Vthrow_on_input; - /* If we're inside a function that wants immediate quits, - do it now. */ - if (immediate_quit && NILP (Vinhibit_quit)) - { - immediate_quit = false; - QUIT; - } - } + Vquit_flag = Vthrow_on_input; } @@ -7053,40 +7041,22 @@ tty_read_avail_input (struct terminal *terminal, /* Now read; for one reason or another, this will not block. NREAD is set to the number of chars read. */ - do - { - nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); - /* POSIX infers that processes which are not in the session leader's - process group won't get SIGHUPs at logout time. BSDI adheres to - this part standard and returns -1 from read (0) with errno==EIO - when the control tty is taken away. - Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ - if (nread == -1 && errno == EIO) - return -2; /* Close this terminal. */ -#if defined (AIX) && defined (_BSD) - /* The kernel sometimes fails to deliver SIGHUP for ptys. - This looks incorrect, but it isn't, because _BSD causes - O_NDELAY to be defined in fcntl.h as O_NONBLOCK, - and that causes a value other than 0 when there is no input. */ - if (nread == 0) - return -2; /* Close this terminal. */ -#endif - } - while ( - /* We used to retry the read if it was interrupted. - But this does the wrong thing when O_NONBLOCK causes - an EAGAIN error. Does anybody know of a situation - where a retry is actually needed? */ -#if 0 - nread < 0 && (errno == EAGAIN || errno == EFAULT -#ifdef EBADSLT - || errno == EBADSLT -#endif - ) -#else - 0 + nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); + /* POSIX infers that processes which are not in the session leader's + process group won't get SIGHUPs at logout time. BSDI adheres to + this part standard and returns -1 from read (0) with errno==EIO + when the control tty is taken away. + Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ + if (nread == -1 && errno == EIO) + return -2; /* Close this terminal. */ +#if defined AIX && defined _BSD + /* The kernel sometimes fails to deliver SIGHUP for ptys. + This looks incorrect, but it isn't, because _BSD causes + O_NDELAY to be defined in fcntl.h as O_NONBLOCK, + and that causes a value other than 0 when there is no input. */ + if (nread == 0) + return -2; /* Close this terminal. */ #endif - ); #ifndef USABLE_FIONREAD #if defined (USG) || defined (CYGWIN) @@ -7426,7 +7396,7 @@ menu_bar_items (Lisp_Object old) USE_SAFE_ALLOCA; /* In order to build the menus, we need to call the keymap - accessors. They all call QUIT. But this function is called + accessors. They all call maybe_quit. But this function is called during redisplay, during which a quit is fatal. So inhibit quitting while building the menus. We do this instead of specbind because (1) errors will clear it anyway @@ -7987,7 +7957,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems) *nitems = 0; /* In order to build the menus, we need to call the keymap - accessors. They all call QUIT. But this function is called + accessors. They all call maybe_quit. But this function is called during redisplay, during which a quit is fatal. So inhibit quitting while building the menus. We do this instead of specbind because (1) errors will clear it anyway and (2) this @@ -9806,7 +9776,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, if (!NILP (prompt)) CHECK_STRING (prompt); - QUIT; + maybe_quit (); specbind (Qinput_method_exit_on_first_char, (NILP (cmd_loop) ? Qt : Qnil)); @@ -9840,7 +9810,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, if (i == -1) { Vquit_flag = Qt; - QUIT; + maybe_quit (); } return unbind_to (count, @@ -10278,7 +10248,7 @@ clear_waiting_for_input (void) If we have a frame on the controlling tty, we assume that the SIGINT was generated by C-g, so we call handle_interrupt. - Otherwise, tell QUIT to kill Emacs. */ + Otherwise, tell maybe_quit to kill Emacs. */ static void handle_interrupt_signal (int sig) @@ -10289,7 +10259,7 @@ handle_interrupt_signal (int sig) { /* If there are no frames there, let's pretend that we are a well-behaving UN*X program and quit. We must not call Lisp - in a signal handler, so tell QUIT to exit when it is + in a signal handler, so tell maybe_quit to exit when it is safe. */ Vquit_flag = Qkill_emacs; } @@ -10445,30 +10415,12 @@ handle_interrupt (bool in_signal_handler) } else { - /* If executing a function that wants to be interrupted out of - and the user has not deferred quitting by binding `inhibit-quit' - then quit right away. */ - if (immediate_quit && NILP (Vinhibit_quit)) - { - struct gl_state_s saved; - - immediate_quit = false; - pthread_sigmask (SIG_SETMASK, &empty_mask, 0); - saved = gl_state; - quit (); - gl_state = saved; - } - else - { /* Else request quit when it's safe. */ - int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1; - force_quit_count = count; - if (count == 3) - { - immediate_quit = true; - Vinhibit_quit = Qnil; - } - Vquit_flag = Qt; - } + /* Request quit when it's safe. */ + int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1; + force_quit_count = count; + if (count == 3) + Vinhibit_quit = Qnil; + Vquit_flag = Qt; } pthread_sigmask (SIG_SETMASK, &empty_mask, 0); @@ -10907,7 +10859,6 @@ init_keyboard (void) { /* This is correct before outermost invocation of the editor loop. */ command_loop_level = -1; - immediate_quit = false; quit_char = Ctl ('g'); Vunread_command_events = Qnil; timer_idleness_start_time = invalid_timespec (); |