diff options
| author | Stefan Monnier | 2020-12-12 09:56:04 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2020-12-12 09:56:04 -0500 |
| commit | adbb4eacc2a984c0fc0b65ec761368fd9067d6c5 (patch) | |
| tree | f2496954a664e3c02f01a76b4f22ec1a479fd3d9 /src | |
| parent | 7ee0fc0dc1a7cba8a3e965f411aca498a7db3f4f (diff) | |
| download | emacs-adbb4eacc2a984c0fc0b65ec761368fd9067d6c5.tar.gz emacs-adbb4eacc2a984c0fc0b65ec761368fd9067d6c5.zip | |
* src/keyboard.c: Fix bug#5803.
A long time ago, `read_key_sequence` used to read the keymaps at the
start, so if something happened between this start and the moment
the user actually hits a key, `read_key_sequence` could end up using
the wrong keymaps. To work around this problem, the code used
`record_asynch_buffer_change` to try and trigger `read_key_sequence`
to re-read the keymaps in some known cases.
Several years ago, `read_key_sequence` was changed so as to read the keymaps
only once the user hits a key, making this machinery now redundant
(and also harmful apparently in bug#5803 because it introduces
"spurious" events).
So we here remove `record_asynch_buffer_change` and the
`BUFFER_SWITCH_EVENT` and `Qbuffer_switch` pseudo-events it generated.
* src/termhooks.h (enum event_kind): Delete `BUFFER_SWITCH_EVENT`.
* src/keyboard.c: (record_asynch_buffer_change): Delete function.
(syms_of_keyboard): Delete `Qbuffer_switch`.
(force_auto_save_soon, readable_events)
(kbd_buffer_store_buffered_event, kbd_buffer_get_event)
(make_lispy_event):
* src/xterm.c (handle_one_xevent):
* src/w32term.c (w32_read_socket):
* src/process.c (wait_reading_process_output)
(read_and_dispose_of_process_output, exec_sentinel): Simplify accordingly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 59 | ||||
| -rw-r--r-- | src/keyboard.h | 1 | ||||
| -rw-r--r-- | src/process.c | 38 | ||||
| -rw-r--r-- | src/termhooks.h | 1 | ||||
| -rw-r--r-- | src/thread.h | 1 | ||||
| -rw-r--r-- | src/w32term.c | 19 | ||||
| -rw-r--r-- | src/xterm.c | 4 |
7 files changed, 1 insertions, 122 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 49261fcc3e8..560d92c99f3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -741,9 +741,6 @@ void | |||
| 741 | force_auto_save_soon (void) | 741 | force_auto_save_soon (void) |
| 742 | { | 742 | { |
| 743 | last_auto_save = - auto_save_interval - 1; | 743 | last_auto_save = - auto_save_interval - 1; |
| 744 | /* FIXME: What's the relationship between forcing auto-save and adding | ||
| 745 | a buffer-switch event? */ | ||
| 746 | record_asynch_buffer_change (); | ||
| 747 | } | 744 | } |
| 748 | #endif | 745 | #endif |
| 749 | 746 | ||
| @@ -3431,8 +3428,7 @@ readable_events (int flags) | |||
| 3431 | && event->ie.part == scroll_bar_handle | 3428 | && event->ie.part == scroll_bar_handle |
| 3432 | && event->ie.modifiers == 0) | 3429 | && event->ie.modifiers == 0) |
| 3433 | #endif | 3430 | #endif |
| 3434 | && !((flags & READABLE_EVENTS_FILTER_EVENTS) | 3431 | ) |
| 3435 | && event->kind == BUFFER_SWITCH_EVENT)) | ||
| 3436 | return 1; | 3432 | return 1; |
| 3437 | event = next_kbd_event (event); | 3433 | event = next_kbd_event (event); |
| 3438 | } | 3434 | } |
| @@ -3583,12 +3579,6 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, | |||
| 3583 | return; | 3579 | return; |
| 3584 | } | 3580 | } |
| 3585 | } | 3581 | } |
| 3586 | /* Don't insert two BUFFER_SWITCH_EVENT's in a row. | ||
| 3587 | Just ignore the second one. */ | ||
| 3588 | else if (event->kind == BUFFER_SWITCH_EVENT | ||
| 3589 | && kbd_fetch_ptr != kbd_store_ptr | ||
| 3590 | && prev_kbd_event (kbd_store_ptr)->kind == BUFFER_SWITCH_EVENT) | ||
| 3591 | return; | ||
| 3592 | 3582 | ||
| 3593 | /* Don't let the very last slot in the buffer become full, | 3583 | /* Don't let the very last slot in the buffer become full, |
| 3594 | since that would make the two pointers equal, | 3584 | since that would make the two pointers equal, |
| @@ -3622,7 +3612,6 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, | |||
| 3622 | case ICONIFY_EVENT: ignore_event = Qiconify_frame; break; | 3612 | case ICONIFY_EVENT: ignore_event = Qiconify_frame; break; |
| 3623 | case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break; | 3613 | case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break; |
| 3624 | case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break; | 3614 | case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break; |
| 3625 | case BUFFER_SWITCH_EVENT: ignore_event = Qbuffer_switch; break; | ||
| 3626 | default: ignore_event = Qnil; break; | 3615 | default: ignore_event = Qnil; break; |
| 3627 | } | 3616 | } |
| 3628 | 3617 | ||
| @@ -3961,7 +3950,6 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3961 | #ifdef HAVE_XWIDGETS | 3950 | #ifdef HAVE_XWIDGETS |
| 3962 | case XWIDGET_EVENT: | 3951 | case XWIDGET_EVENT: |
| 3963 | #endif | 3952 | #endif |
| 3964 | case BUFFER_SWITCH_EVENT: | ||
| 3965 | case SAVE_SESSION_EVENT: | 3953 | case SAVE_SESSION_EVENT: |
| 3966 | case NO_EVENT: | 3954 | case NO_EVENT: |
| 3967 | case HELP_EVENT: | 3955 | case HELP_EVENT: |
| @@ -5341,14 +5329,6 @@ make_lispy_event (struct input_event *event) | |||
| 5341 | return list2 (Qmove_frame, list1 (event->frame_or_window)); | 5329 | return list2 (Qmove_frame, list1 (event->frame_or_window)); |
| 5342 | #endif | 5330 | #endif |
| 5343 | 5331 | ||
| 5344 | case BUFFER_SWITCH_EVENT: | ||
| 5345 | { | ||
| 5346 | /* The value doesn't matter here; only the type is tested. */ | ||
| 5347 | Lisp_Object obj; | ||
| 5348 | XSETBUFFER (obj, current_buffer); | ||
| 5349 | return obj; | ||
| 5350 | } | ||
| 5351 | |||
| 5352 | /* Just discard these, by returning nil. | 5332 | /* Just discard these, by returning nil. |
| 5353 | With MULTI_KBOARD, these events are used as placeholders | 5333 | With MULTI_KBOARD, these events are used as placeholders |
| 5354 | when we need to randomly delete events from the queue. | 5334 | when we need to randomly delete events from the queue. |
| @@ -6805,41 +6785,6 @@ get_input_pending (int flags) | |||
| 6805 | return input_pending; | 6785 | return input_pending; |
| 6806 | } | 6786 | } |
| 6807 | 6787 | ||
| 6808 | /* Put a BUFFER_SWITCH_EVENT in the buffer | ||
| 6809 | so that read_key_sequence will notice the new current buffer. */ | ||
| 6810 | |||
| 6811 | void | ||
| 6812 | record_asynch_buffer_change (void) | ||
| 6813 | { | ||
| 6814 | /* We don't need a buffer-switch event unless Emacs is waiting for input. | ||
| 6815 | The purpose of the event is to make read_key_sequence look up the | ||
| 6816 | keymaps again. If we aren't in read_key_sequence, we don't need one, | ||
| 6817 | and the event could cause trouble by messing up (input-pending-p). | ||
| 6818 | Note: Fwaiting_for_user_input_p always returns nil when async | ||
| 6819 | subprocesses aren't supported. */ | ||
| 6820 | if (!NILP (Fwaiting_for_user_input_p ())) | ||
| 6821 | { | ||
| 6822 | struct input_event event; | ||
| 6823 | |||
| 6824 | EVENT_INIT (event); | ||
| 6825 | event.kind = BUFFER_SWITCH_EVENT; | ||
| 6826 | event.frame_or_window = Qnil; | ||
| 6827 | event.arg = Qnil; | ||
| 6828 | |||
| 6829 | /* Make sure no interrupt happens while storing the event. */ | ||
| 6830 | #ifdef USABLE_SIGIO | ||
| 6831 | if (interrupt_input) | ||
| 6832 | kbd_buffer_store_event (&event); | ||
| 6833 | else | ||
| 6834 | #endif | ||
| 6835 | { | ||
| 6836 | stop_polling (); | ||
| 6837 | kbd_buffer_store_event (&event); | ||
| 6838 | start_polling (); | ||
| 6839 | } | ||
| 6840 | } | ||
| 6841 | } | ||
| 6842 | |||
| 6843 | /* Read any terminal input already buffered up by the system | 6788 | /* Read any terminal input already buffered up by the system |
| 6844 | into the kbd_buffer, but do not wait. | 6789 | into the kbd_buffer, but do not wait. |
| 6845 | 6790 | ||
| @@ -11573,8 +11518,6 @@ syms_of_keyboard (void) | |||
| 11573 | /* Menu and tool bar item parts. */ | 11518 | /* Menu and tool bar item parts. */ |
| 11574 | DEFSYM (Qmenu_enable, "menu-enable"); | 11519 | DEFSYM (Qmenu_enable, "menu-enable"); |
| 11575 | 11520 | ||
| 11576 | DEFSYM (Qbuffer_switch, "buffer-switch"); | ||
| 11577 | |||
| 11578 | #ifdef HAVE_NTGUI | 11521 | #ifdef HAVE_NTGUI |
| 11579 | DEFSYM (Qlanguage_change, "language-change"); | 11522 | DEFSYM (Qlanguage_change, "language-change"); |
| 11580 | DEFSYM (Qend_session, "end-session"); | 11523 | DEFSYM (Qend_session, "end-session"); |
diff --git a/src/keyboard.h b/src/keyboard.h index 41da3a6bf44..24e9a007888 100644 --- a/src/keyboard.h +++ b/src/keyboard.h | |||
| @@ -446,7 +446,6 @@ extern void push_kboard (struct kboard *); | |||
| 446 | extern void push_frame_kboard (struct frame *); | 446 | extern void push_frame_kboard (struct frame *); |
| 447 | extern void pop_kboard (void); | 447 | extern void pop_kboard (void); |
| 448 | extern void temporarily_switch_to_single_kboard (struct frame *); | 448 | extern void temporarily_switch_to_single_kboard (struct frame *); |
| 449 | extern void record_asynch_buffer_change (void); | ||
| 450 | extern void input_poll_signal (int); | 449 | extern void input_poll_signal (int); |
| 451 | extern void start_polling (void); | 450 | extern void start_polling (void); |
| 452 | extern void stop_polling (void); | 451 | extern void stop_polling (void); |
diff --git a/src/process.c b/src/process.c index bf64ead24e5..48b727d9e3b 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -5333,14 +5333,6 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 5333 | 5333 | ||
| 5334 | timer_delay = timer_check (); | 5334 | timer_delay = timer_check (); |
| 5335 | 5335 | ||
| 5336 | /* If a timer has run, this might have changed buffers | ||
| 5337 | an alike. Make read_key_sequence aware of that. */ | ||
| 5338 | if (timers_run != old_timers_run | ||
| 5339 | && (old_buffer != current_buffer | ||
| 5340 | || !EQ (old_window, selected_window)) | ||
| 5341 | && waiting_for_user_input_p == -1) | ||
| 5342 | record_asynch_buffer_change (); | ||
| 5343 | |||
| 5344 | if (timers_run != old_timers_run && do_display) | 5336 | if (timers_run != old_timers_run && do_display) |
| 5345 | /* We must retry, since a timer may have requeued itself | 5337 | /* We must retry, since a timer may have requeued itself |
| 5346 | and that could alter the time_delay. */ | 5338 | and that could alter the time_delay. */ |
| @@ -5706,14 +5698,6 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 5706 | leave = true; | 5698 | leave = true; |
| 5707 | } | 5699 | } |
| 5708 | 5700 | ||
| 5709 | /* If a timer has run, this might have changed buffers | ||
| 5710 | an alike. Make read_key_sequence aware of that. */ | ||
| 5711 | if (timers_run != old_timers_run | ||
| 5712 | && waiting_for_user_input_p == -1 | ||
| 5713 | && (old_buffer != current_buffer | ||
| 5714 | || !EQ (old_window, selected_window))) | ||
| 5715 | record_asynch_buffer_change (); | ||
| 5716 | |||
| 5717 | if (leave) | 5701 | if (leave) |
| 5718 | break; | 5702 | break; |
| 5719 | } | 5703 | } |
| @@ -6213,18 +6197,6 @@ read_and_dispose_of_process_output (struct Lisp_Process *p, char *chars, | |||
| 6213 | /* Restore waiting_for_user_input_p as it was | 6197 | /* Restore waiting_for_user_input_p as it was |
| 6214 | when we were called, in case the filter clobbered it. */ | 6198 | when we were called, in case the filter clobbered it. */ |
| 6215 | waiting_for_user_input_p = waiting; | 6199 | waiting_for_user_input_p = waiting; |
| 6216 | |||
| 6217 | #if 0 /* Call record_asynch_buffer_change unconditionally, | ||
| 6218 | because we might have changed minor modes or other things | ||
| 6219 | that affect key bindings. */ | ||
| 6220 | if (! EQ (Fcurrent_buffer (), obuffer) | ||
| 6221 | || ! EQ (current_buffer->keymap, okeymap)) | ||
| 6222 | #endif | ||
| 6223 | /* But do it only if the caller is actually going to read events. | ||
| 6224 | Otherwise there's no need to make him wake up, and it could | ||
| 6225 | cause trouble (for example it would make sit_for return). */ | ||
| 6226 | if (waiting_for_user_input_p == -1) | ||
| 6227 | record_asynch_buffer_change (); | ||
| 6228 | } | 6200 | } |
| 6229 | 6201 | ||
| 6230 | DEFUN ("internal-default-process-filter", Finternal_default_process_filter, | 6202 | DEFUN ("internal-default-process-filter", Finternal_default_process_filter, |
| @@ -7390,16 +7362,6 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason) | |||
| 7390 | when we were called, in case the filter clobbered it. */ | 7362 | when we were called, in case the filter clobbered it. */ |
| 7391 | waiting_for_user_input_p = waiting; | 7363 | waiting_for_user_input_p = waiting; |
| 7392 | 7364 | ||
| 7393 | #if 0 | ||
| 7394 | if (! EQ (Fcurrent_buffer (), obuffer) | ||
| 7395 | || ! EQ (current_buffer->keymap, okeymap)) | ||
| 7396 | #endif | ||
| 7397 | /* But do it only if the caller is actually going to read events. | ||
| 7398 | Otherwise there's no need to make him wake up, and it could | ||
| 7399 | cause trouble (for example it would make sit_for return). */ | ||
| 7400 | if (waiting_for_user_input_p == -1) | ||
| 7401 | record_asynch_buffer_change (); | ||
| 7402 | |||
| 7403 | unbind_to (count, Qnil); | 7365 | unbind_to (count, Qnil); |
| 7404 | } | 7366 | } |
| 7405 | 7367 | ||
diff --git a/src/termhooks.h b/src/termhooks.h index 44ab14225fd..e94959ca9a3 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -159,7 +159,6 @@ enum event_kind | |||
| 159 | SELECTION_REQUEST_EVENT, /* Another X client wants a selection from us. | 159 | SELECTION_REQUEST_EVENT, /* Another X client wants a selection from us. |
| 160 | See `struct selection_input_event'. */ | 160 | See `struct selection_input_event'. */ |
| 161 | SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */ | 161 | SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */ |
| 162 | BUFFER_SWITCH_EVENT, /* A process filter has switched buffers. */ | ||
| 163 | DELETE_WINDOW_EVENT, /* An X client said "delete this window". */ | 162 | DELETE_WINDOW_EVENT, /* An X client said "delete this window". */ |
| 164 | #ifdef HAVE_NTGUI | 163 | #ifdef HAVE_NTGUI |
| 165 | END_SESSION_EVENT, /* The user is logging out or shutting down. */ | 164 | END_SESSION_EVENT, /* The user is logging out or shutting down. */ |
diff --git a/src/thread.h b/src/thread.h index a09929fa440..9697e49f09f 100644 --- a/src/thread.h +++ b/src/thread.h | |||
| @@ -140,7 +140,6 @@ struct thread_state | |||
| 140 | for user-input when that process-filter was called. | 140 | for user-input when that process-filter was called. |
| 141 | waiting_for_input cannot be used as that is by definition 0 when | 141 | waiting_for_input cannot be used as that is by definition 0 when |
| 142 | lisp code is being evalled. | 142 | lisp code is being evalled. |
| 143 | This is also used in record_asynch_buffer_change. | ||
| 144 | For that purpose, this must be 0 | 143 | For that purpose, this must be 0 |
| 145 | when not inside wait_reading_process_output. */ | 144 | when not inside wait_reading_process_output. */ |
| 146 | int m_waiting_for_user_input_p; | 145 | int m_waiting_for_user_input_p; |
diff --git a/src/w32term.c b/src/w32term.c index dc5cd1f6997..a038e4593f4 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -4858,10 +4858,6 @@ w32_read_socket (struct terminal *terminal, | |||
| 4858 | inev.kind = DEICONIFY_EVENT; | 4858 | inev.kind = DEICONIFY_EVENT; |
| 4859 | XSETFRAME (inev.frame_or_window, f); | 4859 | XSETFRAME (inev.frame_or_window, f); |
| 4860 | } | 4860 | } |
| 4861 | else if (!NILP (Vframe_list) && !NILP (XCDR (Vframe_list))) | ||
| 4862 | /* Force a redisplay sooner or later to update the | ||
| 4863 | frame titles in case this is the second frame. */ | ||
| 4864 | record_asynch_buffer_change (); | ||
| 4865 | } | 4861 | } |
| 4866 | else | 4862 | else |
| 4867 | { | 4863 | { |
| @@ -5479,12 +5475,6 @@ w32_read_socket (struct terminal *terminal, | |||
| 5479 | inev.kind = DEICONIFY_EVENT; | 5475 | inev.kind = DEICONIFY_EVENT; |
| 5480 | XSETFRAME (inev.frame_or_window, f); | 5476 | XSETFRAME (inev.frame_or_window, f); |
| 5481 | } | 5477 | } |
| 5482 | else if (! NILP (Vframe_list) | ||
| 5483 | && ! NILP (XCDR (Vframe_list))) | ||
| 5484 | /* Force a redisplay sooner or later | ||
| 5485 | to update the frame titles | ||
| 5486 | in case this is the second frame. */ | ||
| 5487 | record_asynch_buffer_change (); | ||
| 5488 | 5478 | ||
| 5489 | /* Windows can send us a SIZE_MAXIMIZED message even | 5479 | /* Windows can send us a SIZE_MAXIMIZED message even |
| 5490 | when fullscreen is fullboth. The following is a | 5480 | when fullscreen is fullboth. The following is a |
| @@ -5532,12 +5522,6 @@ w32_read_socket (struct terminal *terminal, | |||
| 5532 | inev.kind = DEICONIFY_EVENT; | 5522 | inev.kind = DEICONIFY_EVENT; |
| 5533 | XSETFRAME (inev.frame_or_window, f); | 5523 | XSETFRAME (inev.frame_or_window, f); |
| 5534 | } | 5524 | } |
| 5535 | else if (! NILP (Vframe_list) | ||
| 5536 | && ! NILP (XCDR (Vframe_list))) | ||
| 5537 | /* Force a redisplay sooner or later | ||
| 5538 | to update the frame titles | ||
| 5539 | in case this is the second frame. */ | ||
| 5540 | record_asynch_buffer_change (); | ||
| 5541 | } | 5525 | } |
| 5542 | 5526 | ||
| 5543 | if (EQ (get_frame_param (f, Qfullscreen), Qmaximized)) | 5527 | if (EQ (get_frame_param (f, Qfullscreen), Qmaximized)) |
| @@ -5829,9 +5813,6 @@ w32_read_socket (struct terminal *terminal, | |||
| 5829 | SET_FRAME_GARBAGED (f); | 5813 | SET_FRAME_GARBAGED (f); |
| 5830 | DebPrint (("obscured frame %p (%s) found to be visible\n", | 5814 | DebPrint (("obscured frame %p (%s) found to be visible\n", |
| 5831 | f, SDATA (f->name))); | 5815 | f, SDATA (f->name))); |
| 5832 | |||
| 5833 | /* Force a redisplay sooner or later. */ | ||
| 5834 | record_asynch_buffer_change (); | ||
| 5835 | } | 5816 | } |
| 5836 | } | 5817 | } |
| 5837 | } | 5818 | } |
diff --git a/src/xterm.c b/src/xterm.c index 0d2452de929..3de0d2e73c0 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -8383,10 +8383,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8383 | inev.ie.kind = DEICONIFY_EVENT; | 8383 | inev.ie.kind = DEICONIFY_EVENT; |
| 8384 | XSETFRAME (inev.ie.frame_or_window, f); | 8384 | XSETFRAME (inev.ie.frame_or_window, f); |
| 8385 | } | 8385 | } |
| 8386 | else if (! NILP (Vframe_list) && ! NILP (XCDR (Vframe_list))) | ||
| 8387 | /* Force a redisplay sooner or later to update the | ||
| 8388 | frame titles in case this is the second frame. */ | ||
| 8389 | record_asynch_buffer_change (); | ||
| 8390 | } | 8386 | } |
| 8391 | goto OTHER; | 8387 | goto OTHER; |
| 8392 | 8388 | ||