Commit 48011560 authored by Paul Eggert's avatar Paul Eggert
Browse files

* keyboard.c (read_key_sequence): Don't check last_real_key_start redundantly.

parent 32ad8845
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* keyboard.c (parse_modifiers_uncached, parse_modifiers): * keyboard.c (parse_modifiers_uncached, parse_modifiers):
Don't assume string length fits in int. Don't assume string length fits in int.
(keyremap_step, read_key_sequence): Use size_t for sizes. (keyremap_step, read_key_sequence): Use size_t for sizes.
(read_key_sequence): Don't check last_real_key_start redundantly.
   
* callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA * callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA
instead of alloca (Bug#8344). instead of alloca (Bug#8344).
...@@ -9359,80 +9359,84 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, ...@@ -9359,80 +9359,84 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
last_real_key_start = t - 1; last_real_key_start = t - 1;
} }
/* Key sequences beginning with mouse clicks are if (last_real_key_start == 0)
read using the keymaps in the buffer clicked on,
not the current buffer. If we're at the
beginning of a key sequence, switch buffers. */
if (last_real_key_start == 0
&& WINDOWP (window)
&& BUFFERP (XWINDOW (window)->buffer)
&& XBUFFER (XWINDOW (window)->buffer) != current_buffer)
{ {
XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; /* Key sequences beginning with mouse clicks are
keybuf[t] = key; read using the keymaps in the buffer clicked on,
mock_input = t + 1; not the current buffer. If we're at the
beginning of a key sequence, switch buffers. */
/* Arrange to go back to the original buffer once we're if (WINDOWP (window)
done reading the key sequence. Note that we can't && BUFFERP (XWINDOW (window)->buffer)
use save_excursion_{save,restore} here, because they && XBUFFER (XWINDOW (window)->buffer) != current_buffer)
save point as well as the current buffer; we don't {
want to save point, because redisplay may change it, XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key;
to accommodate a Fset_window_start or something. We keybuf[t] = key;
don't want to do this at the top of the function, mock_input = t + 1;
because we may get input from a subprocess which
wants to change the selected window and stuff (say, /* Arrange to go back to the original buffer once we're
emacsclient). */ done reading the key sequence. Note that we can't
record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); use save_excursion_{save,restore} here, because they
save point as well as the current buffer; we don't
if (! FRAME_LIVE_P (XFRAME (selected_frame))) want to save point, because redisplay may change it,
Fkill_emacs (Qnil); to accommodate a Fset_window_start or something. We
set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); don't want to do this at the top of the function,
orig_local_map = get_local_map (PT, current_buffer, because we may get input from a subprocess which
Qlocal_map); wants to change the selected window and stuff (say,
orig_keymap = get_local_map (PT, current_buffer, Qkeymap); emacsclient). */
goto replay_sequence; record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
}
if (! FRAME_LIVE_P (XFRAME (selected_frame)))
Fkill_emacs (Qnil);
set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
orig_local_map = get_local_map (PT, current_buffer,
Qlocal_map);
orig_keymap = get_local_map (PT, current_buffer,
Qkeymap);
goto replay_sequence;
}
/* For a mouse click, get the local text-property keymap /* For a mouse click, get the local text-property keymap
of the place clicked on, rather than point. */ of the place clicked on, rather than point. */
if (last_real_key_start == 0 if (CONSP (XCDR (key))
&& CONSP (XCDR (key)) && ! localized_local_map)
&& ! localized_local_map) {
{ Lisp_Object map_here, start, pos;
Lisp_Object map_here, start, pos;
localized_local_map = 1; localized_local_map = 1;
start = EVENT_START (key); start = EVENT_START (key);
if (CONSP (start) && POSN_INBUFFER_P (start)) if (CONSP (start) && POSN_INBUFFER_P (start))
{
pos = POSN_BUFFER_POSN (start);
if (INTEGERP (pos)
&& XINT (pos) >= BEGV
&& XINT (pos) <= ZV)
{ {
map_here = get_local_map (XINT (pos), pos = POSN_BUFFER_POSN (start);
current_buffer, Qlocal_map); if (INTEGERP (pos)
if (!EQ (map_here, orig_local_map)) && XINT (pos) >= BEGV
&& XINT (pos) <= ZV)
{ {
orig_local_map = map_here; map_here = get_local_map (XINT (pos),
++localized_local_map; current_buffer,
} Qlocal_map);
if (!EQ (map_here, orig_local_map))
{
orig_local_map = map_here;
++localized_local_map;
}
map_here = get_local_map (XINT (pos), map_here = get_local_map (XINT (pos),
current_buffer, Qkeymap); current_buffer,
if (!EQ (map_here, orig_keymap)) Qkeymap);
{ if (!EQ (map_here, orig_keymap))
orig_keymap = map_here; {
++localized_local_map; orig_keymap = map_here;
} ++localized_local_map;
}
if (localized_local_map > 1) if (localized_local_map > 1)
{ {
keybuf[t] = key; keybuf[t] = key;
mock_input = t + 1; mock_input = t + 1;
goto replay_sequence; goto replay_sequence;
}
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment