diff options
| author | Paul Eggert | 2011-03-27 11:33:45 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-03-27 11:33:45 -0700 |
| commit | 48011560d73038cbfebfd9d272eabec55005db78 (patch) | |
| tree | 8e871920a244504032401e33187367824997ff9a /src | |
| parent | 32ad8845a456fef4118a657b79129e837b4ec778 (diff) | |
| download | emacs-48011560d73038cbfebfd9d272eabec55005db78.tar.gz emacs-48011560d73038cbfebfd9d272eabec55005db78.zip | |
* keyboard.c (read_key_sequence): Don't check last_real_key_start redundantly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 1 | ||||
| -rw-r--r-- | src/keyboard.c | 134 |
2 files changed, 70 insertions, 65 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8b32aa78a6d..eb1555db6fb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * keyboard.c (parse_modifiers_uncached, parse_modifiers): | 3 | * keyboard.c (parse_modifiers_uncached, parse_modifiers): |
| 4 | Don't assume string length fits in int. | 4 | Don't assume string length fits in int. |
| 5 | (keyremap_step, read_key_sequence): Use size_t for sizes. | 5 | (keyremap_step, read_key_sequence): Use size_t for sizes. |
| 6 | (read_key_sequence): Don't check last_real_key_start redundantly. | ||
| 6 | 7 | ||
| 7 | * callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA | 8 | * callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA |
| 8 | instead of alloca (Bug#8344). | 9 | instead of alloca (Bug#8344). |
diff --git a/src/keyboard.c b/src/keyboard.c index 0fde344478e..6c706590dc4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -9359,80 +9359,84 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 9359 | last_real_key_start = t - 1; | 9359 | last_real_key_start = t - 1; |
| 9360 | } | 9360 | } |
| 9361 | 9361 | ||
| 9362 | /* Key sequences beginning with mouse clicks are | 9362 | if (last_real_key_start == 0) |
| 9363 | read using the keymaps in the buffer clicked on, | ||
| 9364 | not the current buffer. If we're at the | ||
| 9365 | beginning of a key sequence, switch buffers. */ | ||
| 9366 | if (last_real_key_start == 0 | ||
| 9367 | && WINDOWP (window) | ||
| 9368 | && BUFFERP (XWINDOW (window)->buffer) | ||
| 9369 | && XBUFFER (XWINDOW (window)->buffer) != current_buffer) | ||
| 9370 | { | 9363 | { |
| 9371 | XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; | 9364 | /* Key sequences beginning with mouse clicks are |
| 9372 | keybuf[t] = key; | 9365 | read using the keymaps in the buffer clicked on, |
| 9373 | mock_input = t + 1; | 9366 | not the current buffer. If we're at the |
| 9374 | 9367 | beginning of a key sequence, switch buffers. */ | |
| 9375 | /* Arrange to go back to the original buffer once we're | 9368 | if (WINDOWP (window) |
| 9376 | done reading the key sequence. Note that we can't | 9369 | && BUFFERP (XWINDOW (window)->buffer) |
| 9377 | use save_excursion_{save,restore} here, because they | 9370 | && XBUFFER (XWINDOW (window)->buffer) != current_buffer) |
| 9378 | save point as well as the current buffer; we don't | 9371 | { |
| 9379 | want to save point, because redisplay may change it, | 9372 | XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; |
| 9380 | to accommodate a Fset_window_start or something. We | 9373 | keybuf[t] = key; |
| 9381 | don't want to do this at the top of the function, | 9374 | mock_input = t + 1; |
| 9382 | because we may get input from a subprocess which | 9375 | |
| 9383 | wants to change the selected window and stuff (say, | 9376 | /* Arrange to go back to the original buffer once we're |
| 9384 | emacsclient). */ | 9377 | done reading the key sequence. Note that we can't |
| 9385 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 9378 | use save_excursion_{save,restore} here, because they |
| 9386 | 9379 | save point as well as the current buffer; we don't | |
| 9387 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 9380 | want to save point, because redisplay may change it, |
| 9388 | Fkill_emacs (Qnil); | 9381 | to accommodate a Fset_window_start or something. We |
| 9389 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 9382 | don't want to do this at the top of the function, |
| 9390 | orig_local_map = get_local_map (PT, current_buffer, | 9383 | because we may get input from a subprocess which |
| 9391 | Qlocal_map); | 9384 | wants to change the selected window and stuff (say, |
| 9392 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | 9385 | emacsclient). */ |
| 9393 | goto replay_sequence; | 9386 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
| 9394 | } | 9387 | |
| 9388 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | ||
| 9389 | Fkill_emacs (Qnil); | ||
| 9390 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | ||
| 9391 | orig_local_map = get_local_map (PT, current_buffer, | ||
| 9392 | Qlocal_map); | ||
| 9393 | orig_keymap = get_local_map (PT, current_buffer, | ||
| 9394 | Qkeymap); | ||
| 9395 | goto replay_sequence; | ||
| 9396 | } | ||
| 9395 | 9397 | ||
| 9396 | /* For a mouse click, get the local text-property keymap | 9398 | /* For a mouse click, get the local text-property keymap |
| 9397 | of the place clicked on, rather than point. */ | 9399 | of the place clicked on, rather than point. */ |
| 9398 | if (last_real_key_start == 0 | 9400 | if (CONSP (XCDR (key)) |
| 9399 | && CONSP (XCDR (key)) | 9401 | && ! localized_local_map) |
| 9400 | && ! localized_local_map) | 9402 | { |
| 9401 | { | 9403 | Lisp_Object map_here, start, pos; |
| 9402 | Lisp_Object map_here, start, pos; | ||
| 9403 | 9404 | ||
| 9404 | localized_local_map = 1; | 9405 | localized_local_map = 1; |
| 9405 | start = EVENT_START (key); | 9406 | start = EVENT_START (key); |
| 9406 | 9407 | ||
| 9407 | if (CONSP (start) && POSN_INBUFFER_P (start)) | 9408 | if (CONSP (start) && POSN_INBUFFER_P (start)) |
| 9408 | { | ||
| 9409 | pos = POSN_BUFFER_POSN (start); | ||
| 9410 | if (INTEGERP (pos) | ||
| 9411 | && XINT (pos) >= BEGV | ||
| 9412 | && XINT (pos) <= ZV) | ||
| 9413 | { | 9409 | { |
| 9414 | map_here = get_local_map (XINT (pos), | 9410 | pos = POSN_BUFFER_POSN (start); |
| 9415 | current_buffer, Qlocal_map); | 9411 | if (INTEGERP (pos) |
| 9416 | if (!EQ (map_here, orig_local_map)) | 9412 | && XINT (pos) >= BEGV |
| 9413 | && XINT (pos) <= ZV) | ||
| 9417 | { | 9414 | { |
| 9418 | orig_local_map = map_here; | 9415 | map_here = get_local_map (XINT (pos), |
| 9419 | ++localized_local_map; | 9416 | current_buffer, |
| 9420 | } | 9417 | Qlocal_map); |
| 9418 | if (!EQ (map_here, orig_local_map)) | ||
| 9419 | { | ||
| 9420 | orig_local_map = map_here; | ||
| 9421 | ++localized_local_map; | ||
| 9422 | } | ||
| 9421 | 9423 | ||
| 9422 | map_here = get_local_map (XINT (pos), | 9424 | map_here = get_local_map (XINT (pos), |
| 9423 | current_buffer, Qkeymap); | 9425 | current_buffer, |
| 9424 | if (!EQ (map_here, orig_keymap)) | 9426 | Qkeymap); |
| 9425 | { | 9427 | if (!EQ (map_here, orig_keymap)) |
| 9426 | orig_keymap = map_here; | 9428 | { |
| 9427 | ++localized_local_map; | 9429 | orig_keymap = map_here; |
| 9428 | } | 9430 | ++localized_local_map; |
| 9431 | } | ||
| 9429 | 9432 | ||
| 9430 | if (localized_local_map > 1) | 9433 | if (localized_local_map > 1) |
| 9431 | { | 9434 | { |
| 9432 | keybuf[t] = key; | 9435 | keybuf[t] = key; |
| 9433 | mock_input = t + 1; | 9436 | mock_input = t + 1; |
| 9434 | 9437 | ||
| 9435 | goto replay_sequence; | 9438 | goto replay_sequence; |
| 9439 | } | ||
| 9436 | } | 9440 | } |
| 9437 | } | 9441 | } |
| 9438 | } | 9442 | } |