X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a934bf445ffaa7920aa1dfea47fe08920bbbc94c..3e71e4379ce7b53afe51ead4c94e6bb016bc6e7a:/src/keyboard.c diff --git a/src/keyboard.c b/src/keyboard.c index 4e1ac152a5..8901ff055e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7,8 +7,8 @@ This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -70,6 +70,11 @@ along with GNU Emacs. If not, see . */ #include TERM_HEADER #endif /* HAVE_WINDOW_SYSTEM */ +/* Work around GCC bug 54561. */ +#if GNUC_PREREQ (4, 3, 0) +# pragma GCC diagnostic ignored "-Wclobbered" +#endif + /* Variables for blockinput.h: */ /* Positive if interrupt input is blocked right now. */ @@ -430,10 +435,9 @@ kset_system_key_syms (struct kboard *kb, Lisp_Object val) static bool echo_keystrokes_p (void) { - return (!cursor_in_echo_area) - && (FLOATP (Vecho_keystrokes) ? XFLOAT_DATA (Vecho_keystrokes) > 0.0 - : INTEGERP (Vecho_keystrokes) ? XINT (Vecho_keystrokes) > 0 - : false); + return (FLOATP (Vecho_keystrokes) ? XFLOAT_DATA (Vecho_keystrokes) > 0.0 + : INTEGERP (Vecho_keystrokes) ? XINT (Vecho_keystrokes) > 0 + : false); } /* Add C to the echo string, without echoing it immediately. C can be @@ -682,6 +686,14 @@ recursive_edit_1 (void) specbind (Qinhibit_redisplay, Qnil); redisplaying_p = 0; + /* This variable stores buffers that have changed so that an undo + boundary can be added. specbind this so that changes in the + recursive edit will not result in undo boundaries in buffers + changed before we entered there recursive edit. + See Bug #23632. + */ + specbind (Qundo_auto__undoably_changed_buffers, Qnil); + val = command_loop (); if (EQ (val, Qt)) Fsignal (Qquit, Qnil); @@ -2123,7 +2135,7 @@ read_event_from_main_queue (struct timespec *end_time, { Lisp_Object c = Qnil; sys_jmp_buf save_jump; - KBOARD *kb IF_LINT (= NULL); + KBOARD *kb; start: @@ -2194,8 +2206,8 @@ read_decoded_event_from_main_queue (struct timespec *end_time, Lisp_Object prev_event, bool *used_mouse_menu) { -#define MAX_ENCODED_BYTES 16 #ifndef WINDOWSNT +#define MAX_ENCODED_BYTES 16 Lisp_Object events[MAX_ENCODED_BYTES]; int n = 0; #endif @@ -2530,7 +2542,7 @@ read_char (int commandflag, Lisp_Object map, if (KEYMAPP (map) && INTERACTIVE && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) /* Don't bring up a menu if we already have another event. */ - && NILP (Vunread_command_events) + && !CONSP (Vunread_command_events) && !detect_input_pending_run_timers (0)) { c = read_char_minibuf_menu_prompt (commandflag, map); @@ -2661,7 +2673,7 @@ read_char (int commandflag, Lisp_Object map, && !EQ (XCAR (prev_event), Qmenu_bar) && !EQ (XCAR (prev_event), Qtool_bar) /* Don't bring up a menu if we already have another event. */ - && NILP (Vunread_command_events)) + && !CONSP (Vunread_command_events)) { c = read_char_x_menu_prompt (map, prev_event, used_mouse_menu); @@ -2835,10 +2847,19 @@ read_char (int commandflag, Lisp_Object map, last_input_event = c; call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt); - if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) + if (CONSP (c) + && (EQ (XCAR (c), Qselect_window) +#ifdef HAVE_DBUS + || EQ (XCAR (c), Qdbus_event) +#endif +#ifdef USE_FILE_NOTIFY + || EQ (XCAR (c), Qfile_notify) +#endif + || EQ (XCAR (c), Qconfig_changed_event)) + && !end_time) /* We stopped being idle for this event; undo that. This prevents automatic window selection (under - mouse_autoselect_window from acting as a real input event, for + mouse-autoselect-window) from acting as a real input event, for example banishing the mouse under mouse-avoidance-mode. */ timer_resume_idle (); @@ -3885,6 +3906,16 @@ kbd_buffer_get_event (KBOARD **kbp, kbd_fetch_ptr = event + 1; } #endif + +#ifdef HAVE_NTGUI + else if (event->kind == END_SESSION_EVENT) + { + /* Make an event (end-session). */ + obj = list1 (Qend_session); + kbd_fetch_ptr = event + 1; + } +#endif + #if defined (HAVE_X11) || defined (HAVE_NTGUI) \ || defined (HAVE_NS) else if (event->kind == ICONIFY_EVENT) @@ -6871,7 +6902,10 @@ tty_read_avail_input (struct terminal *terminal, the kbd_buffer can really hold. That may prevent loss of characters on some systems when input is stuffed at us. */ unsigned char cbuf[KBD_BUFFER_SIZE - 1]; - int n_to_read, i; +#ifndef WINDOWSNT + int n_to_read; +#endif + int i; struct tty_display_info *tty = terminal->display_info.tty; int nread = 0; #ifdef subprocesses @@ -8820,7 +8854,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, /* The length of the echo buffer when we started reading, and the length of this_command_keys when we started reading. */ - ptrdiff_t echo_start IF_LINT (= 0); + ptrdiff_t echo_start UNINIT; ptrdiff_t keys_start; Lisp_Object current_binding = Qnil; @@ -8868,7 +8902,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, While we're reading, we keep the event here. */ Lisp_Object delayed_switch_frame; - Lisp_Object original_uppercase IF_LINT (= Qnil); + Lisp_Object original_uppercase UNINIT; int original_uppercase_position = -1; /* Gets around Microsoft compiler limitations. */ @@ -8901,7 +8935,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, if (!echo_keystrokes_p ()) current_kboard->immediate_echo = false; } - else if (echo_keystrokes_p ()) + else if (cursor_in_echo_area /* FIXME: Not sure why we test this here, + maybe we should just drop this test. */ + && echo_keystrokes_p ()) /* This doesn't put in a dash if the echo buffer is empty, so you don't always see a dash hanging out in the minibuffer. */ echo_dash (); @@ -8976,7 +9012,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, while those allow us to restart the entire key sequence, echo_local_start and keys_local_start allow us to throw away just one key. */ - ptrdiff_t echo_local_start IF_LINT (= 0); + ptrdiff_t echo_local_start UNINIT; int keys_local_start; Lisp_Object new_binding; @@ -9876,7 +9912,7 @@ clear_input_pending (void) bool requeued_events_pending_p (void) { - return (!NILP (Vunread_command_events)); + return (CONSP (Vunread_command_events)); } DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 1, 0, @@ -9887,7 +9923,7 @@ if there is a doubt, the value is t. If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */) (Lisp_Object check_timers) { - if (!NILP (Vunread_command_events) + if (CONSP (Vunread_command_events) || !NILP (Vunread_post_input_method_events) || !NILP (Vunread_input_method_events)) return (Qt); @@ -10957,6 +10993,8 @@ syms_of_keyboard (void) DEFSYM (Qpost_command_hook, "post-command-hook"); DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary"); + DEFSYM (Qundo_auto__undoably_changed_buffers, + "undo-auto--undoably-changed-buffers"); DEFSYM (Qdeferred_action_function, "deferred-action-function"); DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook"); @@ -10974,6 +11012,7 @@ syms_of_keyboard (void) #ifdef HAVE_NTGUI DEFSYM (Qlanguage_change, "language-change"); + DEFSYM (Qend_session, "end-session"); #endif #ifdef HAVE_DBUS @@ -11383,7 +11422,7 @@ See Info node `(elisp)Multiple Terminals'. */); DEFVAR_BOOL ("cannot-suspend", cannot_suspend, doc: /* Non-nil means to always spawn a subshell instead of suspending. -(Even if the operating system has support for stopping a process.) */); +\(Even if the operating system has support for stopping a process.) */); cannot_suspend = false; DEFVAR_BOOL ("menu-prompting", menu_prompting, @@ -11597,7 +11636,7 @@ immediately after running `post-command-hook'. */); DEFVAR_LISP ("input-method-function", Vinput_method_function, doc: /* If non-nil, the function that implements the current input method. It's called with one argument, a printing character that was just read. -(That means a character with code 040...0176.) +\(That means a character with code 040...0176.) Typically this function uses `read-event' to read additional events. When it does so, it should first bind `input-method-function' to nil so it will not be called recursively. @@ -11748,6 +11787,10 @@ keys_of_keyboard (void) initial_define_lispy_key (Vspecial_event_map, "delete-frame", "handle-delete-frame"); +#ifdef HAVE_NTGUI + initial_define_lispy_key (Vspecial_event_map, "end-session", + "kill-emacs"); +#endif initial_define_lispy_key (Vspecial_event_map, "ns-put-working-text", "ns-put-working-text"); initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",