aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/cus-start.el19
-rw-r--r--src/ChangeLog57
-rw-r--r--src/keyboard.c454
-rw-r--r--src/keyboard.h2
-rw-r--r--src/keymap.c6
-rw-r--r--src/lread.c6
8 files changed, 153 insertions, 401 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 71f48af96d7..a29c8eb054e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -210,6 +210,8 @@ It is layered as:
210 210
211* Incompatible Lisp Changes in Emacs 24.4 211* Incompatible Lisp Changes in Emacs 24.4
212 212
213** Removed inhibit-local-menu-bar-menus.
214
213** frame-local variables that affect redisplay do not work any more. 215** frame-local variables that affect redisplay do not work any more.
214More specifically, the redisplay does not bother to check for a frame-local 216More specifically, the redisplay does not bother to check for a frame-local
215value when looking up variables. 217value when looking up variables.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e0cc3f3b595..1510c6a8fba 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12013-02-11 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * cus-start.el (all): Remove inhibit-local-menu-bar-menus.
4
12013-02-11 Glenn Morris <rgm@gnu.org> 52013-02-11 Glenn Morris <rgm@gnu.org>
2 6
3 * vc/diff.el (diff-use-labels): New variable. 7 * vc/diff.el (diff-use-labels): New variable.
@@ -14,8 +18,8 @@
14 18
152013-02-10 Christopher Schmidt <christopher@ch.ristopher.com> 192013-02-10 Christopher Schmidt <christopher@ch.ristopher.com>
16 20
17 * minibuf-eldef.el (minibuffer-default--in-prompt-regexps): Handle 21 * minibuf-eldef.el (minibuffer-default--in-prompt-regexps):
18 "foo (bar, default: xxx): " prompts. 22 Handle "foo (bar, default: xxx): " prompts.
19 23
202013-02-10 Chong Yidong <cyd@gnu.org> 242013-02-10 Chong Yidong <cyd@gnu.org>
21 25
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 2bc47426332..2e442b6c944 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -286,7 +286,6 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
286 (double-click-time mouse (restricted-sexp 286 (double-click-time mouse (restricted-sexp
287 :match-alternatives (integerp 'nil 't))) 287 :match-alternatives (integerp 'nil 't)))
288 (double-click-fuzz mouse integer "22.1") 288 (double-click-fuzz mouse integer "22.1")
289 (inhibit-local-menu-bar-menus menu boolean)
290 (help-char keyboard character) 289 (help-char keyboard character)
291 (help-event-list keyboard (repeat (sexp :format "%v"))) 290 (help-event-list keyboard (repeat (sexp :format "%v")))
292 (menu-prompting menu boolean) 291 (menu-prompting menu boolean)
@@ -301,15 +300,15 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
301 (const :tag "When sent SIGUSR2" sigusr2)) 300 (const :tag "When sent SIGUSR2" sigusr2))
302 "24.1") 301 "24.1")
303 302
304;; This is not good news because it will use the wrong 303 ;; This is not good news because it will use the wrong
305;; version-specific directories when you upgrade. We need 304 ;; version-specific directories when you upgrade. We need
306;; customization of the front of the list, maintaining the standard 305 ;; customization of the front of the list, maintaining the
307;; value intact at the back. 306 ;; standard value intact at the back.
308;;; (load-path environment 307 ;;(load-path environment
309;;; (repeat (choice :tag "[Current dir?]" 308 ;; (repeat (choice :tag "[Current dir?]"
310;;; :format "%[Current dir?%] %v" 309 ;; :format "%[Current dir?%] %v"
311;;; (const :tag " current dir" nil) 310 ;; (const :tag " current dir" nil)
312;;; (directory :format "%v")))) 311 ;; (directory :format "%v"))))
313 ;; minibuf.c 312 ;; minibuf.c
314 (enable-recursive-minibuffers minibuffer boolean) 313 (enable-recursive-minibuffers minibuffer boolean)
315 (history-length minibuffer 314 (history-length minibuffer
diff --git a/src/ChangeLog b/src/ChangeLog
index 4353b92673b..3e8f30049b0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,24 @@
12013-02-11 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 Clean up read_key_sequence a bit; reread active keymaps after first event.
4 * keyboard.c (read_char, read_char_x_menu_prompt)
5 (read_char_minibuf_menu_prompt):
6 Replace nmaps+maps with a single `map' arg.
7 (follow_key): Operate on a single map.
8 (active_maps): New function.
9 (test_undefined): Also return true for nil bindings.
10 (read_key_sequence): Use active_maps to replace the arrays of keymaps with
11 a single (composed) keymap. Remember `first_event' to choose the right
12 set of active keymaps. Recompute the set of keymaps after receiving
13 the first event. Remove GOBBLE_FIRST_EVENT.
14 (syms_of_keyboard): Remove inhibit_local_menu_bar_menus.
15 * keyboard.h (read_char): Update declaration.
16 * lread.c (read_filtered_event): Adjust call to read_char.
17
12013-02-11 Eli Zaretskii <eliz@gnu.org> 182013-02-11 Eli Zaretskii <eliz@gnu.org>
2 19
3 * xdisp.c (move_it_vertically_backward, move_it_by_lines): Don't 20 * xdisp.c (move_it_vertically_backward, move_it_by_lines):
4 use the limitation on backwards movement when lines are truncated 21 Don't use the limitation on backwards movement when lines are truncated
5 in the window. (Bug#13675) 22 in the window. (Bug#13675)
6 23
72013-02-11 Dmitry Antipov <dmantipov@yandex.ru> 242013-02-11 Dmitry Antipov <dmantipov@yandex.ru>
@@ -17,8 +34,8 @@
17 34
182013-02-10 Eli Zaretskii <eliz@gnu.org> 352013-02-10 Eli Zaretskii <eliz@gnu.org>
19 36
20 * xdisp.c (move_it_vertically_backward, move_it_by_lines): When 37 * xdisp.c (move_it_vertically_backward, move_it_by_lines):
21 text lines are longer than window's screen lines, don't move back 38 When text lines are longer than window's screen lines, don't move back
22 too far. This speeds up some redisplay operations. (Bug#13675) 39 too far. This speeds up some redisplay operations. (Bug#13675)
23 40
242013-02-10 Dmitry Antipov <dmantipov@yandex.ru> 412013-02-10 Dmitry Antipov <dmantipov@yandex.ru>
@@ -140,8 +157,8 @@
140 * xdisp.c (window_buffer_changed): region_showing can be negative, 157 * xdisp.c (window_buffer_changed): region_showing can be negative,
141 which still means region is being displayed. 158 which still means region is being displayed.
142 (redisplay_internal): Resurrect code that forced redisplay of the 159 (redisplay_internal): Resurrect code that forced redisplay of the
143 whole window when showing region and the mark has changed. Record 160 whole window when showing region and the mark has changed.
144 the new mark position to allow redisplay optimizations. 161 Record the new mark position to allow redisplay optimizations.
145 (display_line): If it->region_beg_charpos is non-zero, set the 162 (display_line): If it->region_beg_charpos is non-zero, set the
146 window's region_showing member to -1. (Bug#13623) (Bug#13626) 163 window's region_showing member to -1. (Bug#13623) (Bug#13626)
147 164
@@ -196,8 +213,8 @@
196 * dired.c (file_name_completion): Don't call Fdirectory_file_name 213 * dired.c (file_name_completion): Don't call Fdirectory_file_name
197 with an encoded file name. 214 with an encoded file name.
198 215
199 * w32proc.c (Fw32_short_file_name, Fw32_long_file_name): Adjust 216 * w32proc.c (Fw32_short_file_name, Fw32_long_file_name):
200 calls to dostounix_filename. 217 Adjust calls to dostounix_filename.
201 218
202 * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename. 219 * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename.
203 220
@@ -292,8 +309,8 @@
292 closing it. (Bug#13546) 309 closing it. (Bug#13546)
293 310
294 * w32.c (parse_root, get_volume_info, readdir, read_unc_volume) 311 * w32.c (parse_root, get_volume_info, readdir, read_unc_volume)
295 (logon_network_drive, stat_worker, symlink, chase_symlinks): Use 312 (logon_network_drive, stat_worker, symlink, chase_symlinks):
296 CharNextExA and CharPrevExA to iterate over file names encoded in 313 Use CharNextExA and CharPrevExA to iterate over file names encoded in
297 DBCS. (Bug#13553) 314 DBCS. (Bug#13553)
298 315
299 * w32.c (w32_get_long_filename, init_environment, readlink): 316 * w32.c (w32_get_long_filename, init_environment, readlink):
@@ -333,8 +350,8 @@
333 (normalize_filename, readdir): Use it to detect locales where ANSI 350 (normalize_filename, readdir): Use it to detect locales where ANSI
334 encoding of file names uses a double-byte character set (DBCS). 351 encoding of file names uses a double-byte character set (DBCS).
335 If a DBCS encoding is used, advance by characters using 352 If a DBCS encoding is used, advance by characters using
336 CharNextExA, instead of incrementing a 'char *' pointer. Use 353 CharNextExA, instead of incrementing a 'char *' pointer.
337 _mbslwr instead of _strlwr. (Bug#13515) 354 Use _mbslwr instead of _strlwr. (Bug#13515)
338 355
339 * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial 356 * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial
340 request of memory reservation to 1.7GB. (Bug#13065) 357 request of memory reservation to 1.7GB. (Bug#13065)
@@ -475,8 +492,8 @@
475 segfault when there are lots of overlays. 492 segfault when there are lots of overlays.
476 493
477 * buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault 494 * buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault
478 when there are lots of overlays. See 495 when there are lots of overlays.
479 http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html 496 See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html
480 for the details and a way to reproduce. 497 for the details and a way to reproduce.
481 498
4822013-01-19 Paul Eggert <eggert@cs.ucla.edu> 4992013-01-19 Paul Eggert <eggert@cs.ucla.edu>
@@ -534,8 +551,8 @@
534 551
5352013-01-18 Dmitry Antipov <dmantipov@yandex.ru> 5522013-01-18 Dmitry Antipov <dmantipov@yandex.ru>
536 553
537 Fix crash when inserting data from non-regular files. See 554 Fix crash when inserting data from non-regular files.
538 http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00406.html 555 See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00406.html
539 for the error description produced by valgrind. 556 for the error description produced by valgrind.
540 * fileio.c (read_non_regular): Rename to read_contents. 557 * fileio.c (read_non_regular): Rename to read_contents.
541 Free Lisp_Save_Value object used to pass parameters. 558 Free Lisp_Save_Value object used to pass parameters.
@@ -587,8 +604,8 @@
587 (map_keymap_char_table_item): Adjust accordingly. 604 (map_keymap_char_table_item): Adjust accordingly.
588 * fileio.c (non_regular_fd, non_regular_inserted) 605 * fileio.c (non_regular_fd, non_regular_inserted)
589 (non_regular_nbytes): Remove. 606 (non_regular_nbytes): Remove.
590 (Finsert_file_contents): Convert trytry to ptrdiff_t. Use 607 (Finsert_file_contents): Convert trytry to ptrdiff_t.
591 format_save_value to pass parameters to read_non_regular. 608 Use format_save_value to pass parameters to read_non_regular.
592 (read_non_regular): Use XSAVE_ macros to extract parameters. 609 (read_non_regular): Use XSAVE_ macros to extract parameters.
593 Adjust comment. 610 Adjust comment.
594 * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Use 611 * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Use
@@ -715,8 +732,8 @@
715 732
7162013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com> 7332013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com>
717 734
718 * insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix 735 * insdel.c (Fcombine_after_change_execute, syms_of_insdel):
719 ambiguous doc string cross-reference(s). 736 Fix ambiguous doc string cross-reference(s).
720 737
721 * keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous 738 * keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
722 doc string cross-reference(s). 739 doc string cross-reference(s).
diff --git a/src/keyboard.c b/src/keyboard.c
index ca7be56e6ae..29f90b2ebbb 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -417,10 +417,9 @@ static void (*keyboard_init_hook) (void);
417 417
418static bool get_input_pending (int); 418static bool get_input_pending (int);
419static bool readable_events (int); 419static bool readable_events (int);
420static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, 420static Lisp_Object read_char_x_menu_prompt (Lisp_Object,
421 Lisp_Object, bool *); 421 Lisp_Object, bool *);
422static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, 422static Lisp_Object read_char_minibuf_menu_prompt (int, Lisp_Object);
423 Lisp_Object *);
424static Lisp_Object make_lispy_event (struct input_event *); 423static Lisp_Object make_lispy_event (struct input_event *);
425static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, 424static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object,
426 enum scroll_bar_part, 425 enum scroll_bar_part,
@@ -2231,13 +2230,12 @@ do { if (! polling_stopped_here) stop_polling (); \
2231do { if (polling_stopped_here) start_polling (); \ 2230do { if (polling_stopped_here) start_polling (); \
2232 polling_stopped_here = 0; } while (0) 2231 polling_stopped_here = 0; } while (0)
2233 2232
2234/* read a character from the keyboard; call the redisplay if needed */ 2233/* Read a character from the keyboard; call the redisplay if needed. */
2235/* commandflag 0 means do not autosave, but do redisplay. 2234/* commandflag 0 means do not autosave, but do redisplay.
2236 -1 means do not redisplay, but do autosave. 2235 -1 means do not redisplay, but do autosave.
2237 1 means do both. */ 2236 1 means do both. */
2238 2237
2239/* The arguments MAPS and NMAPS are for menu prompting. 2238/* The arguments MAP is for menu prompting. MAP is a keymap.
2240 MAPS is an array of keymaps; NMAPS is the length of MAPS.
2241 2239
2242 PREV_EVENT is the previous input event, or nil if we are reading 2240 PREV_EVENT is the previous input event, or nil if we are reading
2243 the first event of a key sequence (or not reading a key sequence). 2241 the first event of a key sequence (or not reading a key sequence).
@@ -2259,7 +2257,7 @@ do { if (polling_stopped_here) start_polling (); \
2259 Value is t if we showed a menu and the user rejected it. */ 2257 Value is t if we showed a menu and the user rejected it. */
2260 2258
2261Lisp_Object 2259Lisp_Object
2262read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, 2260read_char (int commandflag, Lisp_Object map,
2263 Lisp_Object prev_event, 2261 Lisp_Object prev_event,
2264 bool *used_mouse_menu, EMACS_TIME *end_time) 2262 bool *used_mouse_menu, EMACS_TIME *end_time)
2265{ 2263{
@@ -2407,7 +2405,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2407 goto reread_first; 2405 goto reread_first;
2408 } 2406 }
2409 2407
2410 /* if redisplay was requested */ 2408 /* If redisplay was requested. */
2411 if (commandflag >= 0) 2409 if (commandflag >= 0)
2412 { 2410 {
2413 bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); 2411 bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]);
@@ -2416,7 +2414,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2416 user-visible, such as X selection_request events. */ 2414 user-visible, such as X selection_request events. */
2417 if (input_pending 2415 if (input_pending
2418 || detect_input_pending_run_timers (0)) 2416 || detect_input_pending_run_timers (0))
2419 swallow_events (0); /* may clear input_pending */ 2417 swallow_events (0); /* May clear input_pending. */
2420 2418
2421 /* Redisplay if no pending input. */ 2419 /* Redisplay if no pending input. */
2422 while (!input_pending) 2420 while (!input_pending)
@@ -2486,13 +2484,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2486 menu prompting. If EVENT_HAS_PARAMETERS then we are reading 2484 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
2487 after a mouse event so don't try a minibuf menu. */ 2485 after a mouse event so don't try a minibuf menu. */
2488 c = Qnil; 2486 c = Qnil;
2489 if (nmaps > 0 && INTERACTIVE 2487 if (KEYMAPP (map) && INTERACTIVE
2490 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) 2488 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
2491 /* Don't bring up a menu if we already have another event. */ 2489 /* Don't bring up a menu if we already have another event. */
2492 && NILP (Vunread_command_events) 2490 && NILP (Vunread_command_events)
2493 && !detect_input_pending_run_timers (0)) 2491 && !detect_input_pending_run_timers (0))
2494 { 2492 {
2495 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); 2493 c = read_char_minibuf_menu_prompt (commandflag, map);
2496 2494
2497 if (INTEGERP (c) && XINT (c) == -2) 2495 if (INTEGERP (c) && XINT (c) == -2)
2498 return c; /* wrong_kboard_jmpbuf */ 2496 return c; /* wrong_kboard_jmpbuf */
@@ -2616,7 +2614,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2616 because the recursive call of read_char in read_char_minibuf_menu_prompt 2614 because the recursive call of read_char in read_char_minibuf_menu_prompt
2617 does not pass on any keymaps. */ 2615 does not pass on any keymaps. */
2618 2616
2619 if (nmaps > 0 && INTERACTIVE 2617 if (KEYMAPP (map) && INTERACTIVE
2620 && !NILP (prev_event) 2618 && !NILP (prev_event)
2621 && EVENT_HAS_PARAMETERS (prev_event) 2619 && EVENT_HAS_PARAMETERS (prev_event)
2622 && !EQ (XCAR (prev_event), Qmenu_bar) 2620 && !EQ (XCAR (prev_event), Qmenu_bar)
@@ -2624,7 +2622,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2624 /* Don't bring up a menu if we already have another event. */ 2622 /* Don't bring up a menu if we already have another event. */
2625 && NILP (Vunread_command_events)) 2623 && NILP (Vunread_command_events))
2626 { 2624 {
2627 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 2625 c = read_char_x_menu_prompt (map, prev_event, used_mouse_menu);
2628 2626
2629 /* Now that we have read an event, Emacs is not idle. */ 2627 /* Now that we have read an event, Emacs is not idle. */
2630 if (!end_time) 2628 if (!end_time)
@@ -3002,7 +3000,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3002 3000
3003 /* If we are not reading a key sequence, 3001 /* If we are not reading a key sequence,
3004 never use the echo area. */ 3002 never use the echo area. */
3005 if (maps == 0) 3003 if (!KEYMAPP (map))
3006 { 3004 {
3007 specbind (Qinput_method_use_echo_area, Qt); 3005 specbind (Qinput_method_use_echo_area, Qt);
3008 } 3006 }
@@ -3095,7 +3093,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3095 last_input_event = c; 3093 last_input_event = c;
3096 num_input_events++; 3094 num_input_events++;
3097 3095
3098 /* Process the help character specially if enabled */ 3096 /* Process the help character specially if enabled. */
3099 if (!NILP (Vhelp_form) && help_char_p (c)) 3097 if (!NILP (Vhelp_form) && help_char_p (c))
3100 { 3098 {
3101 ptrdiff_t count = SPECPDL_INDEX (); 3099 ptrdiff_t count = SPECPDL_INDEX ();
@@ -3109,13 +3107,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3109 cancel_echoing (); 3107 cancel_echoing ();
3110 do 3108 do
3111 { 3109 {
3112 c = read_char (0, 0, 0, Qnil, 0, NULL); 3110 c = read_char (0, Qnil, Qnil, 0, NULL);
3113 if (EVENT_HAS_PARAMETERS (c) 3111 if (EVENT_HAS_PARAMETERS (c)
3114 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) 3112 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click))
3115 XSETCAR (help_form_saved_window_configs, Qnil); 3113 XSETCAR (help_form_saved_window_configs, Qnil);
3116 } 3114 }
3117 while (BUFFERP (c)); 3115 while (BUFFERP (c));
3118 /* Remove the help from the frame */ 3116 /* Remove the help from the frame. */
3119 unbind_to (count, Qnil); 3117 unbind_to (count, Qnil);
3120 3118
3121 redisplay (); 3119 redisplay ();
@@ -3123,7 +3121,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3123 { 3121 {
3124 cancel_echoing (); 3122 cancel_echoing ();
3125 do 3123 do
3126 c = read_char (0, 0, 0, Qnil, 0, NULL); 3124 c = read_char (0, Qnil, Qnil, 0, NULL);
3127 while (BUFFERP (c)); 3125 while (BUFFERP (c));
3128 } 3126 }
3129 } 3127 }
@@ -8313,9 +8311,9 @@ init_tool_bar_items (Lisp_Object reuse)
8313static void 8311static void
8314append_tool_bar_item (void) 8312append_tool_bar_item (void)
8315{ 8313{
8316 ptrdiff_t incr = 8314 ptrdiff_t incr
8317 (ntool_bar_items 8315 = (ntool_bar_items
8318 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); 8316 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS));
8319 8317
8320 /* Enlarge tool_bar_items_vector if necessary. */ 8318 /* Enlarge tool_bar_items_vector if necessary. */
8321 if (0 < incr) 8319 if (0 < incr)
@@ -8333,8 +8331,8 @@ append_tool_bar_item (void)
8333 8331
8334 8332
8335 8333
8336/* Read a character using menus based on maps in the array MAPS. 8334/* Read a character using menus based on the keymap MAP.
8337 NMAPS is the length of MAPS. Return nil if there are no menus in the maps. 8335 Return nil if there are no menus in the maps.
8338 Return t if we displayed a menu but the user rejected it. 8336 Return t if we displayed a menu but the user rejected it.
8339 8337
8340 PREV_EVENT is the previous input event, or nil if we are reading 8338 PREV_EVENT is the previous input event, or nil if we are reading
@@ -8354,7 +8352,7 @@ append_tool_bar_item (void)
8354 and do auto-saving in the inner call of read_char. */ 8352 and do auto-saving in the inner call of read_char. */
8355 8353
8356static Lisp_Object 8354static Lisp_Object
8357read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, 8355read_char_x_menu_prompt (Lisp_Object map,
8358 Lisp_Object prev_event, bool *used_mouse_menu) 8356 Lisp_Object prev_event, bool *used_mouse_menu)
8359{ 8357{
8360#ifdef HAVE_MENUS 8358#ifdef HAVE_MENUS
@@ -8364,18 +8362,11 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8364 if (used_mouse_menu) 8362 if (used_mouse_menu)
8365 *used_mouse_menu = 0; 8363 *used_mouse_menu = 0;
8366 8364
8367 /* Use local over global Menu maps */ 8365 /* Use local over global Menu maps. */
8368 8366
8369 if (! menu_prompting) 8367 if (! menu_prompting)
8370 return Qnil; 8368 return Qnil;
8371 8369
8372 /* Optionally disregard all but the global map. */
8373 if (inhibit_local_menu_bar_menus)
8374 {
8375 maps += (nmaps - 1);
8376 nmaps = 1;
8377 }
8378
8379#ifdef HAVE_MENUS 8370#ifdef HAVE_MENUS
8380 /* If we got to this point via a mouse click, 8371 /* If we got to this point via a mouse click,
8381 use a real menu for mouse selection. */ 8372 use a real menu for mouse selection. */
@@ -8384,16 +8375,9 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8384 && !EQ (XCAR (prev_event), Qtool_bar)) 8375 && !EQ (XCAR (prev_event), Qtool_bar))
8385 { 8376 {
8386 /* Display the menu and get the selection. */ 8377 /* Display the menu and get the selection. */
8387 Lisp_Object *realmaps = alloca (nmaps * sizeof *realmaps);
8388 Lisp_Object value; 8378 Lisp_Object value;
8389 ptrdiff_t nmaps1 = 0;
8390
8391 /* Use the maps that are not nil. */
8392 for (mapno = 0; mapno < nmaps; mapno++)
8393 if (!NILP (maps[mapno]))
8394 realmaps[nmaps1++] = maps[mapno];
8395 8379
8396 value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps)); 8380 value = Fx_popup_menu (prev_event, get_keymap (map, 0, 1));
8397 if (CONSP (value)) 8381 if (CONSP (value))
8398 { 8382 {
8399 Lisp_Object tem; 8383 Lisp_Object tem;
@@ -8435,9 +8419,8 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8435 8419
8436static Lisp_Object 8420static Lisp_Object
8437read_char_minibuf_menu_prompt (int commandflag, 8421read_char_minibuf_menu_prompt (int commandflag,
8438 ptrdiff_t nmaps, Lisp_Object *maps) 8422 Lisp_Object map)
8439{ 8423{
8440 ptrdiff_t mapno;
8441 register Lisp_Object name; 8424 register Lisp_Object name;
8442 ptrdiff_t nlength; 8425 ptrdiff_t nlength;
8443 /* FIXME: Use the minibuffer's frame width. */ 8426 /* FIXME: Use the minibuffer's frame width. */
@@ -8448,18 +8431,12 @@ read_char_minibuf_menu_prompt (int commandflag,
8448 Lisp_Object prompt_strings = Qnil; 8431 Lisp_Object prompt_strings = Qnil;
8449 8432
8450 vector = Qnil; 8433 vector = Qnil;
8451 name = Qnil;
8452 8434
8453 if (! menu_prompting) 8435 if (! menu_prompting)
8454 return Qnil; 8436 return Qnil;
8455 8437
8456 /* Get the menu name from the first map that has one (a prompt string). */ 8438 map = get_keymap (map, 0, 1);
8457 for (mapno = 0; mapno < nmaps; mapno++) 8439 name = Fkeymap_prompt (map);
8458 {
8459 name = Fkeymap_prompt (maps[mapno]);
8460 if (!NILP (name))
8461 break;
8462 }
8463 8440
8464 /* If we don't have any menus, just read a character normally. */ 8441 /* If we don't have any menus, just read a character normally. */
8465 if (!STRINGP (name)) 8442 if (!STRINGP (name))
@@ -8473,9 +8450,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8473 PUSH_C_STR (": ", prompt_strings); 8450 PUSH_C_STR (": ", prompt_strings);
8474 nlength = SCHARS (name) + 2; 8451 nlength = SCHARS (name) + 2;
8475 8452
8476 /* Start prompting at start of first map. */ 8453 rest = map;
8477 mapno = 0;
8478 rest = maps[mapno];
8479 8454
8480 /* Present the documented bindings, a line at a time. */ 8455 /* Present the documented bindings, a line at a time. */
8481 while (1) 8456 while (1)
@@ -8493,18 +8468,14 @@ read_char_minibuf_menu_prompt (int commandflag,
8493 8468
8494 /* FIXME: Use map_keymap to handle new keymap formats. */ 8469 /* FIXME: Use map_keymap to handle new keymap formats. */
8495 8470
8496 /* If reached end of map, start at beginning of next map. */ 8471 /* At end of map, wrap around if just starting,
8472 or end this line if already have something on it. */
8497 if (NILP (rest)) 8473 if (NILP (rest))
8498 { 8474 {
8499 mapno++; 8475 if (notfirst || nobindings)
8500 /* At end of last map, wrap around to first map if just starting, 8476 break;
8501 or end this line if already have something on it. */ 8477 else
8502 if (mapno == nmaps) 8478 rest = map;
8503 {
8504 mapno = 0;
8505 if (notfirst || nobindings) break;
8506 }
8507 rest = maps[mapno];
8508 } 8479 }
8509 8480
8510 /* Look at the next element of the map. */ 8481 /* Look at the next element of the map. */
@@ -8638,7 +8609,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8638 } 8609 }
8639 8610
8640 /* Prompt with that and read response. */ 8611 /* Prompt with that and read response. */
8641 message3_nolog (apply1 (intern ("concat"), menu_strings)); 8612 message3_nolog (apply1 (intern ("concat"), Fnreverse (menu_strings)));
8642 8613
8643 /* Make believe it's not a keyboard macro in case the help char 8614 /* Make believe it's not a keyboard macro in case the help char
8644 is pressed. Help characters are not recorded because menu prompting 8615 is pressed. Help characters are not recorded because menu prompting
@@ -8646,7 +8617,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8646 orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); 8617 orig_defn_macro = KVAR (current_kboard, defining_kbd_macro);
8647 kset_defining_kbd_macro (current_kboard, Qnil); 8618 kset_defining_kbd_macro (current_kboard, Qnil);
8648 do 8619 do
8649 obj = read_char (commandflag, 0, 0, Qt, 0, NULL); 8620 obj = read_char (commandflag, Qnil, Qt, 0, NULL);
8650 while (BUFFERP (obj)); 8621 while (BUFFERP (obj));
8651 kset_defining_kbd_macro (current_kboard, orig_defn_macro); 8622 kset_defining_kbd_macro (current_kboard, orig_defn_macro);
8652 8623
@@ -8667,46 +8638,18 @@ read_char_minibuf_menu_prompt (int commandflag,
8667 8638
8668/* Reading key sequences. */ 8639/* Reading key sequences. */
8669 8640
8670/* Follow KEY in the maps in CURRENT[0..NMAPS-1], placing its bindings 8641static Lisp_Object
8671 in DEFS[0..NMAPS-1]. Set NEXT[i] to DEFS[i] if DEFS[i] is a 8642follow_key (Lisp_Object keymap, Lisp_Object key)
8672 keymap, or nil otherwise. Return the index of the first keymap in
8673 which KEY has any binding, or NMAPS if no map has a binding.
8674
8675 If KEY is a meta ASCII character, treat it like meta-prefix-char
8676 followed by the corresponding non-meta character. Keymaps in
8677 CURRENT with non-prefix bindings for meta-prefix-char become nil in
8678 NEXT.
8679
8680 If KEY has no bindings in any of the CURRENT maps, NEXT is left
8681 unmodified.
8682
8683 NEXT may be the same array as CURRENT. */
8684
8685static int
8686follow_key (Lisp_Object key, ptrdiff_t nmaps, Lisp_Object *current,
8687 Lisp_Object *defs, Lisp_Object *next)
8688{ 8643{
8689 ptrdiff_t i, first_binding; 8644 return access_keymap (get_keymap (keymap, 0, 1),
8690 8645 key, 1, 0, 1);
8691 first_binding = nmaps; 8646}
8692 for (i = nmaps - 1; i >= 0; i--)
8693 {
8694 if (! NILP (current[i]))
8695 {
8696 defs[i] = access_keymap (current[i], key, 1, 0, 1);
8697 if (! NILP (defs[i]))
8698 first_binding = i;
8699 }
8700 else
8701 defs[i] = Qnil;
8702 }
8703
8704 /* Given the set of bindings we've found, produce the next set of maps. */
8705 if (first_binding < nmaps)
8706 for (i = 0; i < nmaps; i++)
8707 next[i] = NILP (defs[i]) ? Qnil : get_keymap (defs[i], 0, 1);
8708 8647
8709 return first_binding; 8648static Lisp_Object
8649active_maps (Lisp_Object first_event)
8650{
8651 Lisp_Object position = INTEGERP (first_event) ? Qnil : first_event;
8652 return Fcons (Qkeymap, Fcurrent_active_maps (Qt, position));
8710} 8653}
8711 8654
8712/* Structure used to keep track of partial application of key remapping 8655/* Structure used to keep track of partial application of key remapping
@@ -8838,8 +8781,9 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8838static bool 8781static bool
8839test_undefined (Lisp_Object binding) 8782test_undefined (Lisp_Object binding)
8840{ 8783{
8841 return (EQ (binding, Qundefined) 8784 return (NILP (binding)
8842 || (!NILP (binding) && SYMBOLP (binding) 8785 || EQ (binding, Qundefined)
8786 || (SYMBOLP (binding)
8843 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); 8787 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
8844} 8788}
8845 8789
@@ -8896,34 +8840,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8896 ptrdiff_t echo_start IF_LINT (= 0); 8840 ptrdiff_t echo_start IF_LINT (= 0);
8897 ptrdiff_t keys_start; 8841 ptrdiff_t keys_start;
8898 8842
8899 /* The number of keymaps we're scanning right now, and the number of 8843 Lisp_Object current_binding = Qnil;
8900 keymaps we have allocated space for. */ 8844 Lisp_Object first_event = Qnil;
8901 ptrdiff_t nmaps;
8902 ptrdiff_t nmaps_allocated = 0;
8903
8904 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in
8905 the current keymaps. */
8906 Lisp_Object *defs = NULL;
8907
8908 /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1]
8909 in the current keymaps, or nil where it is not a prefix. */
8910 Lisp_Object *submaps = NULL;
8911 8845
8912 /* The local map to start out with at start of key sequence. */
8913 Lisp_Object orig_local_map;
8914
8915 /* The map from the `keymap' property to start out with at start of
8916 key sequence. */
8917 Lisp_Object orig_keymap;
8918
8919 /* Positive if we have already considered switching to the local-map property
8920 of the place where a mouse click occurred. */
8921 int localized_local_map = 0;
8922
8923 /* The index in submaps[] of the first keymap that has a binding for
8924 this key sequence. In other words, the lowest i such that
8925 submaps[i] is non-nil. */
8926 ptrdiff_t first_binding;
8927 /* Index of the first key that has no binding. 8846 /* Index of the first key that has no binding.
8928 It is useless to try fkey.start larger than that. */ 8847 It is useless to try fkey.start larger than that. */
8929 int first_unbound; 8848 int first_unbound;
@@ -8966,11 +8885,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8966 While we're reading, we keep the event here. */ 8885 While we're reading, we keep the event here. */
8967 Lisp_Object delayed_switch_frame; 8886 Lisp_Object delayed_switch_frame;
8968 8887
8969 /* See the comment below... */
8970#if defined (GOBBLE_FIRST_EVENT)
8971 Lisp_Object first_event;
8972#endif
8973
8974 Lisp_Object original_uppercase IF_LINT (= Qnil); 8888 Lisp_Object original_uppercase IF_LINT (= Qnil);
8975 int original_uppercase_position = -1; 8889 int original_uppercase_position = -1;
8976 8890
@@ -8982,10 +8896,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8982 /* List of events for which a fake prefix key has been generated. */ 8896 /* List of events for which a fake prefix key has been generated. */
8983 Lisp_Object fake_prefixed_keys = Qnil; 8897 Lisp_Object fake_prefixed_keys = Qnil;
8984 8898
8985#if defined (GOBBLE_FIRST_EVENT)
8986 int junk;
8987#endif
8988
8989 struct gcpro gcpro1; 8899 struct gcpro gcpro1;
8990 8900
8991 GCPRO1 (fake_prefixed_keys); 8901 GCPRO1 (fake_prefixed_keys);
@@ -9021,19 +8931,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9021 keys_start = this_command_key_count; 8931 keys_start = this_command_key_count;
9022 this_single_command_key_start = keys_start; 8932 this_single_command_key_start = keys_start;
9023 8933
9024#if defined (GOBBLE_FIRST_EVENT)
9025 /* This doesn't quite work, because some of the things that read_char
9026 does cannot safely be bypassed. It seems too risky to try to make
9027 this work right. */
9028
9029 /* Read the first char of the sequence specially, before setting
9030 up any keymaps, in case a filter runs and switches buffers on us. */
9031 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event,
9032 &junk, NULL);
9033#endif /* GOBBLE_FIRST_EVENT */
9034
9035 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9036 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9037 from_string = Qnil; 8934 from_string = Qnil;
9038 8935
9039 /* We jump here when we need to reinitialize fkey and keytran; this 8936 /* We jump here when we need to reinitialize fkey and keytran; this
@@ -9060,60 +8957,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9060 keybuf with its symbol, or if the sequence starts with a mouse 8957 keybuf with its symbol, or if the sequence starts with a mouse
9061 click and we need to switch buffers, we jump back here to rebuild 8958 click and we need to switch buffers, we jump back here to rebuild
9062 the initial keymaps from the current buffer. */ 8959 the initial keymaps from the current buffer. */
9063 nmaps = 0; 8960 current_binding = active_maps (first_event);
9064 8961
9065 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
9066 {
9067 if (2 > nmaps_allocated)
9068 {
9069 submaps = alloca (2 * sizeof *submaps);
9070 defs = alloca (2 * sizeof *defs);
9071 nmaps_allocated = 2;
9072 }
9073 submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
9074 }
9075 else if (!NILP (Voverriding_local_map))
9076 {
9077 if (2 > nmaps_allocated)
9078 {
9079 submaps = alloca (2 * sizeof *submaps);
9080 defs = alloca (2 * sizeof *defs);
9081 nmaps_allocated = 2;
9082 }
9083 submaps[nmaps++] = Voverriding_local_map;
9084 }
9085 else
9086 {
9087 ptrdiff_t nminor;
9088 ptrdiff_t total;
9089 Lisp_Object *maps;
9090
9091 nminor = current_minor_maps (0, &maps);
9092 total = nminor + (!NILP (orig_keymap) ? 3 : 2);
9093
9094 if (total > nmaps_allocated)
9095 {
9096 submaps = alloca (total * sizeof *submaps);
9097 defs = alloca (total * sizeof *defs);
9098 nmaps_allocated = total;
9099 }
9100
9101 if (!NILP (orig_keymap))
9102 submaps[nmaps++] = orig_keymap;
9103
9104 memcpy (submaps + nmaps, maps, nminor * sizeof (submaps[0]));
9105
9106 nmaps += nminor;
9107
9108 submaps[nmaps++] = orig_local_map;
9109 }
9110 submaps[nmaps++] = current_global_map;
9111
9112 /* Find an accurate initial value for first_binding. */
9113 for (first_binding = 0; first_binding < nmaps; first_binding++)
9114 if (! NILP (submaps[first_binding]))
9115 break;
9116
9117 /* Start from the beginning in keybuf. */ 8962 /* Start from the beginning in keybuf. */
9118 t = 0; 8963 t = 0;
9119 8964
@@ -9126,9 +8971,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9126 /* If the best binding for the current key sequence is a keymap, or 8971 /* If the best binding for the current key sequence is a keymap, or
9127 we may be looking at a function key's escape sequence, keep on 8972 we may be looking at a function key's escape sequence, keep on
9128 reading. */ 8973 reading. */
9129 while (first_binding < nmaps 8974 while (!NILP (current_binding)
9130 /* Keep reading as long as there's a prefix binding. */ 8975 /* Keep reading as long as there's a prefix binding. */
9131 ? !NILP (submaps[first_binding]) 8976 ? KEYMAPP (current_binding)
9132 /* Don't return in the middle of a possible function key sequence, 8977 /* Don't return in the middle of a possible function key sequence,
9133 if the only bindings we found were via case conversion. 8978 if the only bindings we found were via case conversion.
9134 Thus, if ESC O a has a function-key-map translation 8979 Thus, if ESC O a has a function-key-map translation
@@ -9152,7 +8997,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9152 just one key. */ 8997 just one key. */
9153 ptrdiff_t echo_local_start IF_LINT (= 0); 8998 ptrdiff_t echo_local_start IF_LINT (= 0);
9154 int keys_local_start; 8999 int keys_local_start;
9155 ptrdiff_t local_first_binding; 9000 Lisp_Object new_binding;
9156 9001
9157 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); 9002 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input));
9158 eassert (indec.start <= indec.end); 9003 eassert (indec.start <= indec.end);
@@ -9189,7 +9034,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9189 if (INTERACTIVE) 9034 if (INTERACTIVE)
9190 echo_local_start = echo_length (); 9035 echo_local_start = echo_length ();
9191 keys_local_start = this_command_key_count; 9036 keys_local_start = this_command_key_count;
9192 local_first_binding = first_binding;
9193 9037
9194 replay_key: 9038 replay_key:
9195 /* These are no-ops, unless we throw away a keystroke below and 9039 /* These are no-ops, unless we throw away a keystroke below and
@@ -9199,7 +9043,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9199 if (INTERACTIVE && t < mock_input) 9043 if (INTERACTIVE && t < mock_input)
9200 echo_truncate (echo_local_start); 9044 echo_truncate (echo_local_start);
9201 this_command_key_count = keys_local_start; 9045 this_command_key_count = keys_local_start;
9202 first_binding = local_first_binding;
9203 9046
9204 /* By default, assume each event is "real". */ 9047 /* By default, assume each event is "real". */
9205 last_real_key_start = t; 9048 last_real_key_start = t;
@@ -9224,8 +9067,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9224 { 9067 {
9225 KBOARD *interrupted_kboard = current_kboard; 9068 KBOARD *interrupted_kboard = current_kboard;
9226 struct frame *interrupted_frame = SELECTED_FRAME (); 9069 struct frame *interrupted_frame = SELECTED_FRAME ();
9227 key = read_char (NILP (prompt), nmaps, 9070 key = read_char (NILP (prompt),
9228 (Lisp_Object *) submaps, last_nonmenu_event, 9071 current_binding, last_nonmenu_event,
9229 &used_mouse_menu, NULL); 9072 &used_mouse_menu, NULL);
9230 if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ 9073 if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
9231 /* When switching to a new tty (with a new keyboard), 9074 /* When switching to a new tty (with a new keyboard),
@@ -9280,8 +9123,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9280 KVAR (interrupted_kboard, kbd_queue))); 9123 KVAR (interrupted_kboard, kbd_queue)));
9281 } 9124 }
9282 mock_input = 0; 9125 mock_input = 0;
9283 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9284 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9285 goto replay_entire_sequence; 9126 goto replay_entire_sequence;
9286 } 9127 }
9287 } 9128 }
@@ -9322,12 +9163,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9322 { 9163 {
9323 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9164 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9324 Fkill_emacs (Qnil); 9165 Fkill_emacs (Qnil);
9325 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 9166 if (XBUFFER (XWINDOW (selected_window)->buffer)
9167 != current_buffer)
9326 Fset_buffer (XWINDOW (selected_window)->buffer); 9168 Fset_buffer (XWINDOW (selected_window)->buffer);
9327 } 9169 }
9328 9170
9329 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9330 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9331 goto replay_sequence; 9171 goto replay_sequence;
9332 } 9172 }
9333 9173
@@ -9344,8 +9184,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9344 keybuf[t++] = key; 9184 keybuf[t++] = key;
9345 mock_input = t; 9185 mock_input = t;
9346 Vquit_flag = Qnil; 9186 Vquit_flag = Qnil;
9347 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9348 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9349 goto replay_sequence; 9187 goto replay_sequence;
9350 } 9188 }
9351 9189
@@ -9365,6 +9203,22 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9365 } 9203 }
9366 } 9204 }
9367 9205
9206 if (NILP (first_event))
9207 {
9208 first_event = key;
9209 /* Even if first_event does not specify a particular
9210 window/position, it's important to recompute the maps here
9211 since a long time might have passed since we entered
9212 read_key_sequence, and a timer (or process-filter or
9213 special-event-map, ...) might have switched the current buffer
9214 or the selected window from under us in the mean time. */
9215 if (fix_current_buffer
9216 && (XBUFFER (XWINDOW (selected_window)->buffer)
9217 != current_buffer))
9218 Fset_buffer (XWINDOW (selected_window)->buffer);
9219 current_binding = active_maps (first_event);
9220 }
9221
9368 GROW_RAW_KEYBUF; 9222 GROW_RAW_KEYBUF;
9369 ASET (raw_keybuf, raw_keybuf_count, key); 9223 ASET (raw_keybuf, raw_keybuf_count, key);
9370 raw_keybuf_count++; 9224 raw_keybuf_count++;
@@ -9438,58 +9292,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9438 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9292 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9439 Fkill_emacs (Qnil); 9293 Fkill_emacs (Qnil);
9440 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 9294 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
9441 orig_local_map = get_local_map (PT, current_buffer,
9442 Qlocal_map);
9443 orig_keymap = get_local_map (PT, current_buffer,
9444 Qkeymap);
9445 goto replay_sequence; 9295 goto replay_sequence;
9446 } 9296 }
9447
9448 /* For a mouse click, get the local text-property keymap
9449 of the place clicked on, rather than point. */
9450 if (CONSP (XCDR (key))
9451 && ! localized_local_map)
9452 {
9453 Lisp_Object map_here, start, pos;
9454
9455 localized_local_map = 1;
9456 start = EVENT_START (key);
9457
9458 if (CONSP (start) && POSN_INBUFFER_P (start))
9459 {
9460 pos = POSN_BUFFER_POSN (start);
9461 if (INTEGERP (pos)
9462 && XINT (pos) >= BEGV
9463 && XINT (pos) <= ZV)
9464 {
9465 map_here = get_local_map (XINT (pos),
9466 current_buffer,
9467 Qlocal_map);
9468 if (!EQ (map_here, orig_local_map))
9469 {
9470 orig_local_map = map_here;
9471 ++localized_local_map;
9472 }
9473
9474 map_here = get_local_map (XINT (pos),
9475 current_buffer,
9476 Qkeymap);
9477 if (!EQ (map_here, orig_keymap))
9478 {
9479 orig_keymap = map_here;
9480 ++localized_local_map;
9481 }
9482
9483 if (localized_local_map > 1)
9484 {
9485 keybuf[t] = key;
9486 mock_input = t + 1;
9487
9488 goto replay_sequence;
9489 }
9490 }
9491 }
9492 }
9493 } 9297 }
9494 9298
9495 /* Expand mode-line and scroll-bar events into two events: 9299 /* Expand mode-line and scroll-bar events into two events:
@@ -9510,63 +9314,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9510 prevent proper action when the event is pushed 9314 prevent proper action when the event is pushed
9511 back into unread-command-events. */ 9315 back into unread-command-events. */
9512 fake_prefixed_keys = Fcons (key, fake_prefixed_keys); 9316 fake_prefixed_keys = Fcons (key, fake_prefixed_keys);
9513
9514 /* If on a mode line string with a local keymap,
9515 reconsider the key sequence with that keymap. */
9516 if (string = POSN_STRING (EVENT_START (key)),
9517 (CONSP (string) && STRINGP (XCAR (string))))
9518 {
9519 Lisp_Object pos, map, map2;
9520
9521 pos = XCDR (string);
9522 string = XCAR (string);
9523 if (XINT (pos) >= 0
9524 && XINT (pos) < SCHARS (string))
9525 {
9526 map = Fget_text_property (pos, Qlocal_map, string);
9527 if (!NILP (map))
9528 orig_local_map = map;
9529 map2 = Fget_text_property (pos, Qkeymap, string);
9530 if (!NILP (map2))
9531 orig_keymap = map2;
9532 if (!NILP (map) || !NILP (map2))
9533 goto replay_sequence;
9534 }
9535 }
9536
9537 goto replay_key; 9317 goto replay_key;
9538 } 9318 }
9539 else if (NILP (from_string)
9540 && (string = POSN_STRING (EVENT_START (key)),
9541 (CONSP (string) && STRINGP (XCAR (string)))))
9542 {
9543 /* For a click on a string, i.e. overlay string or a
9544 string displayed via the `display' property,
9545 consider `local-map' and `keymap' properties of
9546 that string. */
9547 Lisp_Object pos, map, map2;
9548
9549 pos = XCDR (string);
9550 string = XCAR (string);
9551 if (XINT (pos) >= 0
9552 && XINT (pos) < SCHARS (string))
9553 {
9554 map = Fget_text_property (pos, Qlocal_map, string);
9555 if (!NILP (map))
9556 orig_local_map = map;
9557 map2 = Fget_text_property (pos, Qkeymap, string);
9558 if (!NILP (map2))
9559 orig_keymap = map2;
9560
9561 if (!NILP (map) || !NILP (map2))
9562 {
9563 from_string = string;
9564 keybuf[t++] = key;
9565 mock_input = t;
9566 goto replay_sequence;
9567 }
9568 }
9569 }
9570 } 9319 }
9571 else if (CONSP (XCDR (key)) 9320 else if (CONSP (XCDR (key))
9572 && CONSP (EVENT_START (key)) 9321 && CONSP (EVENT_START (key))
@@ -9582,7 +9331,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9582 if (bufsize - t <= 1) 9331 if (bufsize - t <= 1)
9583 error ("Key sequence too long"); 9332 error ("Key sequence too long");
9584 keybuf[t] = posn; 9333 keybuf[t] = posn;
9585 keybuf[t+1] = key; 9334 keybuf[t + 1] = key;
9586 9335
9587 /* Zap the position in key, so we know that we've 9336 /* Zap the position in key, so we know that we've
9588 expanded it, and don't try to do so again. */ 9337 expanded it, and don't try to do so again. */
@@ -9605,15 +9354,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9605 9354
9606 /* We have finally decided that KEY is something we might want 9355 /* We have finally decided that KEY is something we might want
9607 to look up. */ 9356 to look up. */
9608 first_binding = (follow_key (key, 9357 new_binding = follow_key (current_binding, key);
9609 nmaps - first_binding,
9610 submaps + first_binding,
9611 defs + first_binding,
9612 submaps + first_binding)
9613 + first_binding);
9614 9358
9615 /* If KEY wasn't bound, we'll try some fallbacks. */ 9359 /* If KEY wasn't bound, we'll try some fallbacks. */
9616 if (first_binding < nmaps) 9360 if (!NILP (new_binding))
9617 /* This is needed for the following scenario: 9361 /* This is needed for the following scenario:
9618 event 0: a down-event that gets dropped by calling replay_key. 9362 event 0: a down-event that gets dropped by calling replay_key.
9619 event 1: some normal prefix like C-h. 9363 event 1: some normal prefix like C-h.
@@ -9750,20 +9494,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9750 new_click 9494 new_click
9751 = Fcons (new_head, Fcons (EVENT_START (key), Qnil)); 9495 = Fcons (new_head, Fcons (EVENT_START (key), Qnil));
9752 9496
9753 /* Look for a binding for this new key. follow_key 9497 /* Look for a binding for this new key. */
9754 promises that it didn't munge submaps the 9498 new_binding = follow_key (current_binding, new_click);
9755 last time we called it, since key was unbound. */
9756 first_binding
9757 = (follow_key (new_click,
9758 nmaps - local_first_binding,
9759 submaps + local_first_binding,
9760 defs + local_first_binding,
9761 submaps + local_first_binding)
9762 + local_first_binding);
9763 9499
9764 /* If that click is bound, go for it. */ 9500 /* If that click is bound, go for it. */
9765 if (first_binding < nmaps) 9501 if (!NILP (new_binding))
9766 { 9502 {
9503 current_binding = new_binding;
9767 key = new_click; 9504 key = new_click;
9768 break; 9505 break;
9769 } 9506 }
@@ -9772,6 +9509,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9772 } 9509 }
9773 } 9510 }
9774 } 9511 }
9512 current_binding = new_binding;
9775 9513
9776 keybuf[t++] = key; 9514 keybuf[t++] = key;
9777 /* Normally, last_nonmenu_event gets the previous key we read. 9515 /* Normally, last_nonmenu_event gets the previous key we read.
@@ -9803,9 +9541,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9803 } 9541 }
9804 } 9542 }
9805 9543
9806 if (first_binding < nmaps 9544 if (!KEYMAPP (current_binding)
9807 && NILP (submaps[first_binding]) 9545 && !test_undefined (current_binding)
9808 && !test_undefined (defs[first_binding])
9809 && indec.start >= t) 9546 && indec.start >= t)
9810 /* There is a binding and it's not a prefix. 9547 /* There is a binding and it's not a prefix.
9811 (and it doesn't have any input-decode-map translation pending). 9548 (and it doesn't have any input-decode-map translation pending).
@@ -9834,8 +9571,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9834 first_binding >= nmaps) we don't want 9571 first_binding >= nmaps) we don't want
9835 to apply this function-key-mapping. */ 9572 to apply this function-key-mapping. */
9836 fkey.end + 1 == t 9573 fkey.end + 1 == t
9837 && (first_binding >= nmaps 9574 && (test_undefined (current_binding)),
9838 || test_undefined (defs[first_binding])),
9839 &diff, prompt); 9575 &diff, prompt);
9840 UNGCPRO; 9576 UNGCPRO;
9841 if (done) 9577 if (done)
@@ -9878,7 +9614,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9878 and cannot be part of a function key or translation, 9614 and cannot be part of a function key or translation,
9879 and is an upper case letter 9615 and is an upper case letter
9880 use the corresponding lower-case letter instead. */ 9616 use the corresponding lower-case letter instead. */
9881 if (first_binding >= nmaps 9617 if (NILP (current_binding)
9882 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t 9618 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
9883 && INTEGERP (key) 9619 && INTEGERP (key)
9884 && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK)) 9620 && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK))
@@ -9909,7 +9645,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9909 and cannot be part of a function key or translation, 9645 and cannot be part of a function key or translation,
9910 and is a shifted function key, 9646 and is a shifted function key,
9911 use the corresponding unshifted function key instead. */ 9647 use the corresponding unshifted function key instead. */
9912 if (first_binding >= nmaps 9648 if (NILP (current_binding)
9913 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) 9649 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t)
9914 { 9650 {
9915 Lisp_Object breakdown = parse_modifiers (key); 9651 Lisp_Object breakdown = parse_modifiers (key);
@@ -9950,9 +9686,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9950 } 9686 }
9951 } 9687 }
9952 if (!dummyflag) 9688 if (!dummyflag)
9953 read_key_sequence_cmd = (first_binding < nmaps 9689 read_key_sequence_cmd = current_binding;
9954 ? defs[first_binding]
9955 : Qnil);
9956 read_key_sequence_remapped 9690 read_key_sequence_remapped
9957 /* Remap command through active keymaps. 9691 /* Remap command through active keymaps.
9958 Do the remapping here, before the unbind_to so it uses the keymaps 9692 Do the remapping here, before the unbind_to so it uses the keymaps
@@ -9966,7 +9700,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9966 9700
9967 /* Don't downcase the last character if the caller says don't. 9701 /* Don't downcase the last character if the caller says don't.
9968 Don't downcase it if the result is undefined, either. */ 9702 Don't downcase it if the result is undefined, either. */
9969 if ((dont_downcase_last || first_binding >= nmaps) 9703 if ((dont_downcase_last || NILP (current_binding))
9970 && t > 0 9704 && t > 0
9971 && t - 1 == original_uppercase_position) 9705 && t - 1 == original_uppercase_position)
9972 { 9706 {
@@ -10063,7 +9797,7 @@ will read just one key sequence. */)
10063 9797
10064 memset (keybuf, 0, sizeof keybuf); 9798 memset (keybuf, 0, sizeof keybuf);
10065 GCPRO1 (keybuf[0]); 9799 GCPRO1 (keybuf[0]);
10066 gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); 9800 gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
10067 9801
10068 if (NILP (continue_echo)) 9802 if (NILP (continue_echo))
10069 { 9803 {
@@ -11669,10 +11403,6 @@ This variable is also the threshold for motion of the mouse
11669to count as a drag. */); 11403to count as a drag. */);
11670 double_click_fuzz = 3; 11404 double_click_fuzz = 3;
11671 11405
11672 DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus,
11673 doc: /* Non-nil means inhibit local map menu bar menus. */);
11674 inhibit_local_menu_bar_menus = 0;
11675
11676 DEFVAR_INT ("num-input-keys", num_input_keys, 11406 DEFVAR_INT ("num-input-keys", num_input_keys,
11677 doc: /* Number of complete key sequences read as input so far. 11407 doc: /* Number of complete key sequences read as input so far.
11678This includes key sequences read from keyboard macros. 11408This includes key sequences read from keyboard macros.
diff --git a/src/keyboard.h b/src/keyboard.h
index 7ffb436754b..c6ade35dd52 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -482,7 +482,7 @@ struct input_event;
482 482
483extern Lisp_Object parse_modifiers (Lisp_Object); 483extern Lisp_Object parse_modifiers (Lisp_Object);
484extern Lisp_Object reorder_modifiers (Lisp_Object); 484extern Lisp_Object reorder_modifiers (Lisp_Object);
485extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object, 485extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object,
486 bool *, EMACS_TIME *); 486 bool *, EMACS_TIME *);
487extern int parse_solitary_modifier (Lisp_Object symbol); 487extern int parse_solitary_modifier (Lisp_Object symbol);
488 488
diff --git a/src/keymap.c b/src/keymap.c
index 1e201e06dc3..922c1703edf 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1244,7 +1244,7 @@ remapping in all currently active keymaps. */)
1244 return INTEGERP (command) ? Qnil : command; 1244 return INTEGERP (command) ? Qnil : command;
1245} 1245}
1246 1246
1247/* Value is number if KEY is too long; nil if valid but has no definition. */ 1247/* Value is number if KEY is too long; nil if valid but has no definition. */
1248/* GC is possible in this function. */ 1248/* GC is possible in this function. */
1249 1249
1250DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, 1250DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0,
@@ -1536,7 +1536,7 @@ DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps,
1536 doc: /* Return a list of the currently active keymaps. 1536 doc: /* Return a list of the currently active keymaps.
1537OLP if non-nil indicates that we should obey `overriding-local-map' and 1537OLP if non-nil indicates that we should obey `overriding-local-map' and
1538`overriding-terminal-local-map'. POSITION can specify a click position 1538`overriding-terminal-local-map'. POSITION can specify a click position
1539like in the respective argument of `key-binding'. */) 1539like in the respective argument of `key-binding'. */)
1540 (Lisp_Object olp, Lisp_Object position) 1540 (Lisp_Object olp, Lisp_Object position)
1541{ 1541{
1542 ptrdiff_t count = SPECPDL_INDEX (); 1542 ptrdiff_t count = SPECPDL_INDEX ();
@@ -1545,7 +1545,7 @@ like in the respective argument of `key-binding'. */)
1545 1545
1546 /* If a mouse click position is given, our variables are based on 1546 /* If a mouse click position is given, our variables are based on
1547 the buffer clicked on, not the current buffer. So we may have to 1547 the buffer clicked on, not the current buffer. So we may have to
1548 switch the buffer here. */ 1548 switch the buffer here. */
1549 1549
1550 if (CONSP (position)) 1550 if (CONSP (position))
1551 { 1551 {
diff --git a/src/lread.c b/src/lread.c
index c62c62a5e5a..e7af86aa664 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -614,17 +614,17 @@ read_filtered_event (bool no_switch_frame, bool ascii_required,
614 end_time = add_emacs_time (current_emacs_time (), wait_time); 614 end_time = add_emacs_time (current_emacs_time (), wait_time);
615 } 615 }
616 616
617/* Read until we get an acceptable event. */ 617 /* Read until we get an acceptable event. */
618 retry: 618 retry:
619 do 619 do
620 val = read_char (0, 0, 0, (input_method ? Qnil : Qt), 0, 620 val = read_char (0, Qnil, (input_method ? Qnil : Qt), 0,
621 NUMBERP (seconds) ? &end_time : NULL); 621 NUMBERP (seconds) ? &end_time : NULL);
622 while (INTEGERP (val) && XINT (val) == -2); /* wrong_kboard_jmpbuf */ 622 while (INTEGERP (val) && XINT (val) == -2); /* wrong_kboard_jmpbuf */
623 623
624 if (BUFFERP (val)) 624 if (BUFFERP (val))
625 goto retry; 625 goto retry;
626 626
627 /* switch-frame events are put off until after the next ASCII 627 /* `switch-frame' events are put off until after the next ASCII
628 character. This is better than signaling an error just because 628 character. This is better than signaling an error just because
629 the last characters were typed to a separate minibuffer frame, 629 the last characters were typed to a separate minibuffer frame,
630 for example. Eventually, some code which can deal with 630 for example. Eventually, some code which can deal with