diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 76 | ||||
| -rw-r--r-- | src/cm.c | 3 | ||||
| -rw-r--r-- | src/fileio.c | 5 | ||||
| -rw-r--r-- | src/keyboard.c | 472 | ||||
| -rw-r--r-- | src/keyboard.h | 2 | ||||
| -rw-r--r-- | src/keymap.c | 6 | ||||
| -rw-r--r-- | src/lread.c | 6 | ||||
| -rw-r--r-- | src/marker.c | 28 | ||||
| -rw-r--r-- | src/window.c | 20 | ||||
| -rw-r--r-- | src/xdisp.c | 16 |
10 files changed, 205 insertions, 429 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9d8540075de..b3d3958853b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,7 +1,47 @@ | |||
| 1 | 2013-02-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Clean up read_key_sequence a tiny bit more. | ||
| 4 | * keyboard.c (read_char_x_menu_prompt) [HAVE_MENUS]: | ||
| 5 | (read_key_sequence): Remove unused locals. | ||
| 6 | |||
| 7 | 2013-02-11 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 8 | |||
| 9 | Clean up read_key_sequence a bit; reread active keymaps after first event. | ||
| 10 | * keyboard.c (read_char, read_char_x_menu_prompt) | ||
| 11 | (read_char_minibuf_menu_prompt): | ||
| 12 | Replace nmaps+maps with a single `map' arg. | ||
| 13 | (follow_key): Operate on a single map. | ||
| 14 | (active_maps): New function. | ||
| 15 | (test_undefined): Also return true for nil bindings. | ||
| 16 | (read_key_sequence): Use active_maps to replace the arrays of keymaps with | ||
| 17 | a single (composed) keymap. Remember `first_event' to choose the right | ||
| 18 | set of active keymaps. Recompute the set of keymaps after receiving | ||
| 19 | the first event. Remove GOBBLE_FIRST_EVENT. | ||
| 20 | (syms_of_keyboard): Remove inhibit_local_menu_bar_menus. | ||
| 21 | * keyboard.h (read_char): Update declaration. | ||
| 22 | * lread.c (read_filtered_event): Adjust call to read_char. | ||
| 23 | |||
| 24 | 2013-02-11 Eli Zaretskii <eliz@gnu.org> | ||
| 25 | |||
| 26 | * xdisp.c (move_it_vertically_backward, move_it_by_lines): | ||
| 27 | Don't use the limitation on backwards movement when lines are truncated | ||
| 28 | in the window. (Bug#13675) | ||
| 29 | |||
| 30 | 2013-02-11 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 31 | |||
| 32 | * marker.c (set_marker_internal): If desired position is passed | ||
| 33 | as a marker, avoid call to buf_charpos_to_bytepos. | ||
| 34 | * window.c (Fset_window_point): Omit redundant type checking. | ||
| 35 | (Fset_window_start): Likewise. Format comment. | ||
| 36 | (window_scroll_pixel_based): Use set_marker_restricted_both | ||
| 37 | with character and byte positions obtained from an iterator. | ||
| 38 | (Fset_window_configuration): Use set_marker_restricted_both. | ||
| 39 | * xdisp.c (message_dolog): Likewise. | ||
| 40 | |||
| 1 | 2013-02-10 Eli Zaretskii <eliz@gnu.org> | 41 | 2013-02-10 Eli Zaretskii <eliz@gnu.org> |
| 2 | 42 | ||
| 3 | * xdisp.c (move_it_vertically_backward, move_it_by_lines): When | 43 | * xdisp.c (move_it_vertically_backward, move_it_by_lines): |
| 4 | text lines are longer than window's screen lines, don't move back | 44 | When text lines are longer than window's screen lines, don't move back |
| 5 | too far. This speeds up some redisplay operations. (Bug#13675) | 45 | too far. This speeds up some redisplay operations. (Bug#13675) |
| 6 | 46 | ||
| 7 | 2013-02-10 Dmitry Antipov <dmantipov@yandex.ru> | 47 | 2013-02-10 Dmitry Antipov <dmantipov@yandex.ru> |
| @@ -123,8 +163,8 @@ | |||
| 123 | * xdisp.c (window_buffer_changed): region_showing can be negative, | 163 | * xdisp.c (window_buffer_changed): region_showing can be negative, |
| 124 | which still means region is being displayed. | 164 | which still means region is being displayed. |
| 125 | (redisplay_internal): Resurrect code that forced redisplay of the | 165 | (redisplay_internal): Resurrect code that forced redisplay of the |
| 126 | whole window when showing region and the mark has changed. Record | 166 | whole window when showing region and the mark has changed. |
| 127 | the new mark position to allow redisplay optimizations. | 167 | Record the new mark position to allow redisplay optimizations. |
| 128 | (display_line): If it->region_beg_charpos is non-zero, set the | 168 | (display_line): If it->region_beg_charpos is non-zero, set the |
| 129 | window's region_showing member to -1. (Bug#13623) (Bug#13626) | 169 | window's region_showing member to -1. (Bug#13623) (Bug#13626) |
| 130 | 170 | ||
| @@ -179,8 +219,8 @@ | |||
| 179 | * dired.c (file_name_completion): Don't call Fdirectory_file_name | 219 | * dired.c (file_name_completion): Don't call Fdirectory_file_name |
| 180 | with an encoded file name. | 220 | with an encoded file name. |
| 181 | 221 | ||
| 182 | * w32proc.c (Fw32_short_file_name, Fw32_long_file_name): Adjust | 222 | * w32proc.c (Fw32_short_file_name, Fw32_long_file_name): |
| 183 | calls to dostounix_filename. | 223 | Adjust calls to dostounix_filename. |
| 184 | 224 | ||
| 185 | * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename. | 225 | * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename. |
| 186 | 226 | ||
| @@ -275,8 +315,8 @@ | |||
| 275 | closing it. (Bug#13546) | 315 | closing it. (Bug#13546) |
| 276 | 316 | ||
| 277 | * w32.c (parse_root, get_volume_info, readdir, read_unc_volume) | 317 | * w32.c (parse_root, get_volume_info, readdir, read_unc_volume) |
| 278 | (logon_network_drive, stat_worker, symlink, chase_symlinks): Use | 318 | (logon_network_drive, stat_worker, symlink, chase_symlinks): |
| 279 | CharNextExA and CharPrevExA to iterate over file names encoded in | 319 | Use CharNextExA and CharPrevExA to iterate over file names encoded in |
| 280 | DBCS. (Bug#13553) | 320 | DBCS. (Bug#13553) |
| 281 | 321 | ||
| 282 | * w32.c (w32_get_long_filename, init_environment, readlink): | 322 | * w32.c (w32_get_long_filename, init_environment, readlink): |
| @@ -316,8 +356,8 @@ | |||
| 316 | (normalize_filename, readdir): Use it to detect locales where ANSI | 356 | (normalize_filename, readdir): Use it to detect locales where ANSI |
| 317 | encoding of file names uses a double-byte character set (DBCS). | 357 | encoding of file names uses a double-byte character set (DBCS). |
| 318 | If a DBCS encoding is used, advance by characters using | 358 | If a DBCS encoding is used, advance by characters using |
| 319 | CharNextExA, instead of incrementing a 'char *' pointer. Use | 359 | CharNextExA, instead of incrementing a 'char *' pointer. |
| 320 | _mbslwr instead of _strlwr. (Bug#13515) | 360 | Use _mbslwr instead of _strlwr. (Bug#13515) |
| 321 | 361 | ||
| 322 | * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial | 362 | * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial |
| 323 | request of memory reservation to 1.7GB. (Bug#13065) | 363 | request of memory reservation to 1.7GB. (Bug#13065) |
| @@ -458,8 +498,8 @@ | |||
| 458 | segfault when there are lots of overlays. | 498 | segfault when there are lots of overlays. |
| 459 | 499 | ||
| 460 | * buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault | 500 | * buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault |
| 461 | when there are lots of overlays. See | 501 | when there are lots of overlays. |
| 462 | http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html | 502 | See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html |
| 463 | for the details and a way to reproduce. | 503 | for the details and a way to reproduce. |
| 464 | 504 | ||
| 465 | 2013-01-19 Paul Eggert <eggert@cs.ucla.edu> | 505 | 2013-01-19 Paul Eggert <eggert@cs.ucla.edu> |
| @@ -517,8 +557,8 @@ | |||
| 517 | 557 | ||
| 518 | 2013-01-18 Dmitry Antipov <dmantipov@yandex.ru> | 558 | 2013-01-18 Dmitry Antipov <dmantipov@yandex.ru> |
| 519 | 559 | ||
| 520 | Fix crash when inserting data from non-regular files. See | 560 | Fix crash when inserting data from non-regular files. |
| 521 | http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00406.html | 561 | See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00406.html |
| 522 | for the error description produced by valgrind. | 562 | for the error description produced by valgrind. |
| 523 | * fileio.c (read_non_regular): Rename to read_contents. | 563 | * fileio.c (read_non_regular): Rename to read_contents. |
| 524 | Free Lisp_Save_Value object used to pass parameters. | 564 | Free Lisp_Save_Value object used to pass parameters. |
| @@ -570,8 +610,8 @@ | |||
| 570 | (map_keymap_char_table_item): Adjust accordingly. | 610 | (map_keymap_char_table_item): Adjust accordingly. |
| 571 | * fileio.c (non_regular_fd, non_regular_inserted) | 611 | * fileio.c (non_regular_fd, non_regular_inserted) |
| 572 | (non_regular_nbytes): Remove. | 612 | (non_regular_nbytes): Remove. |
| 573 | (Finsert_file_contents): Convert trytry to ptrdiff_t. Use | 613 | (Finsert_file_contents): Convert trytry to ptrdiff_t. |
| 574 | format_save_value to pass parameters to read_non_regular. | 614 | Use format_save_value to pass parameters to read_non_regular. |
| 575 | (read_non_regular): Use XSAVE_ macros to extract parameters. | 615 | (read_non_regular): Use XSAVE_ macros to extract parameters. |
| 576 | Adjust comment. | 616 | Adjust comment. |
| 577 | * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Use | 617 | * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Use |
| @@ -698,8 +738,8 @@ | |||
| 698 | 738 | ||
| 699 | 2013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com> | 739 | 2013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com> |
| 700 | 740 | ||
| 701 | * insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix | 741 | * insdel.c (Fcombine_after_change_execute, syms_of_insdel): |
| 702 | ambiguous doc string cross-reference(s). | 742 | Fix ambiguous doc string cross-reference(s). |
| 703 | 743 | ||
| 704 | * keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous | 744 | * keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous |
| 705 | doc string cross-reference(s). | 745 | doc string cross-reference(s). |
| @@ -28,8 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 28 | #include "termchar.h" | 28 | #include "termchar.h" |
| 29 | #include "tparam.h" | 29 | #include "tparam.h" |
| 30 | 30 | ||
| 31 | #define BIG 9999 /* 9999 good on VAXen. For 16 bit machines | 31 | #define BIG 9999 /* Good on 32-bit hosts. */ |
| 32 | use about 2000.... */ | ||
| 33 | 32 | ||
| 34 | int cost; /* sums up costs */ | 33 | int cost; /* sums up costs */ |
| 35 | 34 | ||
diff --git a/src/fileio.c b/src/fileio.c index ddf23867104..98a9b32ea91 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -133,9 +133,6 @@ static Lisp_Object Qwrite_region_annotate_functions; | |||
| 133 | is added here. */ | 133 | is added here. */ |
| 134 | static Lisp_Object Vwrite_region_annotation_buffers; | 134 | static Lisp_Object Vwrite_region_annotation_buffers; |
| 135 | 135 | ||
| 136 | #ifdef HAVE_FSYNC | ||
| 137 | #endif | ||
| 138 | |||
| 139 | static Lisp_Object Qdelete_by_moving_to_trash; | 136 | static Lisp_Object Qdelete_by_moving_to_trash; |
| 140 | 137 | ||
| 141 | /* Lisp function for moving files to trash. */ | 138 | /* Lisp function for moving files to trash. */ |
| @@ -4965,7 +4962,7 @@ This calls `write-region-annotate-functions' at the start, and | |||
| 4965 | immediate_quit = 0; | 4962 | immediate_quit = 0; |
| 4966 | 4963 | ||
| 4967 | #ifdef HAVE_FSYNC | 4964 | #ifdef HAVE_FSYNC |
| 4968 | /* Note fsync appears to change the modtime on BSD4.2 (both vax and sun). | 4965 | /* fsync appears to change the modtime on BSD4.2. |
| 4969 | Disk full in NFS may be reported here. */ | 4966 | Disk full in NFS may be reported here. */ |
| 4970 | /* mib says that closing the file will try to write as fast as NFS can do | 4967 | /* mib says that closing the file will try to write as fast as NFS can do |
| 4971 | it, and that means the fsync here is not crucial for autosave files. */ | 4968 | it, and that means the fsync here is not crucial for autosave files. */ |
diff --git a/src/keyboard.c b/src/keyboard.c index f5728009cf7..4a92cea30c8 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -420,10 +420,9 @@ static void (*keyboard_init_hook) (void); | |||
| 420 | 420 | ||
| 421 | static bool get_input_pending (int); | 421 | static bool get_input_pending (int); |
| 422 | static bool readable_events (int); | 422 | static bool readable_events (int); |
| 423 | static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, | 423 | static Lisp_Object read_char_x_menu_prompt (Lisp_Object, |
| 424 | Lisp_Object, bool *); | 424 | Lisp_Object, bool *); |
| 425 | static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, | 425 | static Lisp_Object read_char_minibuf_menu_prompt (int, Lisp_Object); |
| 426 | Lisp_Object *); | ||
| 427 | static Lisp_Object make_lispy_event (struct input_event *); | 426 | static Lisp_Object make_lispy_event (struct input_event *); |
| 428 | static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, | 427 | static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, |
| 429 | enum scroll_bar_part, | 428 | enum scroll_bar_part, |
| @@ -2234,13 +2233,12 @@ do { if (! polling_stopped_here) stop_polling (); \ | |||
| 2234 | do { if (polling_stopped_here) start_polling (); \ | 2233 | do { if (polling_stopped_here) start_polling (); \ |
| 2235 | polling_stopped_here = 0; } while (0) | 2234 | polling_stopped_here = 0; } while (0) |
| 2236 | 2235 | ||
| 2237 | /* read a character from the keyboard; call the redisplay if needed */ | 2236 | /* Read a character from the keyboard; call the redisplay if needed. */ |
| 2238 | /* commandflag 0 means do not autosave, but do redisplay. | 2237 | /* commandflag 0 means do not autosave, but do redisplay. |
| 2239 | -1 means do not redisplay, but do autosave. | 2238 | -1 means do not redisplay, but do autosave. |
| 2240 | 1 means do both. */ | 2239 | 1 means do both. */ |
| 2241 | 2240 | ||
| 2242 | /* The arguments MAPS and NMAPS are for menu prompting. | 2241 | /* The arguments MAP is for menu prompting. MAP is a keymap. |
| 2243 | MAPS is an array of keymaps; NMAPS is the length of MAPS. | ||
| 2244 | 2242 | ||
| 2245 | PREV_EVENT is the previous input event, or nil if we are reading | 2243 | PREV_EVENT is the previous input event, or nil if we are reading |
| 2246 | the first event of a key sequence (or not reading a key sequence). | 2244 | the first event of a key sequence (or not reading a key sequence). |
| @@ -2262,7 +2260,7 @@ do { if (polling_stopped_here) start_polling (); \ | |||
| 2262 | Value is t if we showed a menu and the user rejected it. */ | 2260 | Value is t if we showed a menu and the user rejected it. */ |
| 2263 | 2261 | ||
| 2264 | Lisp_Object | 2262 | Lisp_Object |
| 2265 | read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | 2263 | read_char (int commandflag, Lisp_Object map, |
| 2266 | Lisp_Object prev_event, | 2264 | Lisp_Object prev_event, |
| 2267 | bool *used_mouse_menu, EMACS_TIME *end_time) | 2265 | bool *used_mouse_menu, EMACS_TIME *end_time) |
| 2268 | { | 2266 | { |
| @@ -2410,7 +2408,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2410 | goto reread_first; | 2408 | goto reread_first; |
| 2411 | } | 2409 | } |
| 2412 | 2410 | ||
| 2413 | /* if redisplay was requested */ | 2411 | /* If redisplay was requested. */ |
| 2414 | if (commandflag >= 0) | 2412 | if (commandflag >= 0) |
| 2415 | { | 2413 | { |
| 2416 | bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); | 2414 | bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); |
| @@ -2419,7 +2417,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2419 | user-visible, such as X selection_request events. */ | 2417 | user-visible, such as X selection_request events. */ |
| 2420 | if (input_pending | 2418 | if (input_pending |
| 2421 | || detect_input_pending_run_timers (0)) | 2419 | || detect_input_pending_run_timers (0)) |
| 2422 | swallow_events (0); /* may clear input_pending */ | 2420 | swallow_events (0); /* May clear input_pending. */ |
| 2423 | 2421 | ||
| 2424 | /* Redisplay if no pending input. */ | 2422 | /* Redisplay if no pending input. */ |
| 2425 | while (!input_pending) | 2423 | while (!input_pending) |
| @@ -2489,13 +2487,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2489 | menu prompting. If EVENT_HAS_PARAMETERS then we are reading | 2487 | menu prompting. If EVENT_HAS_PARAMETERS then we are reading |
| 2490 | after a mouse event so don't try a minibuf menu. */ | 2488 | after a mouse event so don't try a minibuf menu. */ |
| 2491 | c = Qnil; | 2489 | c = Qnil; |
| 2492 | if (nmaps > 0 && INTERACTIVE | 2490 | if (KEYMAPP (map) && INTERACTIVE |
| 2493 | && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) | 2491 | && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) |
| 2494 | /* Don't bring up a menu if we already have another event. */ | 2492 | /* Don't bring up a menu if we already have another event. */ |
| 2495 | && NILP (Vunread_command_events) | 2493 | && NILP (Vunread_command_events) |
| 2496 | && !detect_input_pending_run_timers (0)) | 2494 | && !detect_input_pending_run_timers (0)) |
| 2497 | { | 2495 | { |
| 2498 | c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); | 2496 | c = read_char_minibuf_menu_prompt (commandflag, map); |
| 2499 | 2497 | ||
| 2500 | if (INTEGERP (c) && XINT (c) == -2) | 2498 | if (INTEGERP (c) && XINT (c) == -2) |
| 2501 | return c; /* wrong_kboard_jmpbuf */ | 2499 | return c; /* wrong_kboard_jmpbuf */ |
| @@ -2619,7 +2617,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2619 | because the recursive call of read_char in read_char_minibuf_menu_prompt | 2617 | because the recursive call of read_char in read_char_minibuf_menu_prompt |
| 2620 | does not pass on any keymaps. */ | 2618 | does not pass on any keymaps. */ |
| 2621 | 2619 | ||
| 2622 | if (nmaps > 0 && INTERACTIVE | 2620 | if (KEYMAPP (map) && INTERACTIVE |
| 2623 | && !NILP (prev_event) | 2621 | && !NILP (prev_event) |
| 2624 | && EVENT_HAS_PARAMETERS (prev_event) | 2622 | && EVENT_HAS_PARAMETERS (prev_event) |
| 2625 | && !EQ (XCAR (prev_event), Qmenu_bar) | 2623 | && !EQ (XCAR (prev_event), Qmenu_bar) |
| @@ -2627,7 +2625,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2627 | /* Don't bring up a menu if we already have another event. */ | 2625 | /* Don't bring up a menu if we already have another event. */ |
| 2628 | && NILP (Vunread_command_events)) | 2626 | && NILP (Vunread_command_events)) |
| 2629 | { | 2627 | { |
| 2630 | c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); | 2628 | c = read_char_x_menu_prompt (map, prev_event, used_mouse_menu); |
| 2631 | 2629 | ||
| 2632 | /* Now that we have read an event, Emacs is not idle. */ | 2630 | /* Now that we have read an event, Emacs is not idle. */ |
| 2633 | if (!end_time) | 2631 | if (!end_time) |
| @@ -3005,7 +3003,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3005 | 3003 | ||
| 3006 | /* If we are not reading a key sequence, | 3004 | /* If we are not reading a key sequence, |
| 3007 | never use the echo area. */ | 3005 | never use the echo area. */ |
| 3008 | if (maps == 0) | 3006 | if (!KEYMAPP (map)) |
| 3009 | { | 3007 | { |
| 3010 | specbind (Qinput_method_use_echo_area, Qt); | 3008 | specbind (Qinput_method_use_echo_area, Qt); |
| 3011 | } | 3009 | } |
| @@ -3098,7 +3096,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3098 | last_input_event = c; | 3096 | last_input_event = c; |
| 3099 | num_input_events++; | 3097 | num_input_events++; |
| 3100 | 3098 | ||
| 3101 | /* Process the help character specially if enabled */ | 3099 | /* Process the help character specially if enabled. */ |
| 3102 | if (!NILP (Vhelp_form) && help_char_p (c)) | 3100 | if (!NILP (Vhelp_form) && help_char_p (c)) |
| 3103 | { | 3101 | { |
| 3104 | ptrdiff_t count = SPECPDL_INDEX (); | 3102 | ptrdiff_t count = SPECPDL_INDEX (); |
| @@ -3112,13 +3110,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3112 | cancel_echoing (); | 3110 | cancel_echoing (); |
| 3113 | do | 3111 | do |
| 3114 | { | 3112 | { |
| 3115 | c = read_char (0, 0, 0, Qnil, 0, NULL); | 3113 | c = read_char (0, Qnil, Qnil, 0, NULL); |
| 3116 | if (EVENT_HAS_PARAMETERS (c) | 3114 | if (EVENT_HAS_PARAMETERS (c) |
| 3117 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) | 3115 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) |
| 3118 | XSETCAR (help_form_saved_window_configs, Qnil); | 3116 | XSETCAR (help_form_saved_window_configs, Qnil); |
| 3119 | } | 3117 | } |
| 3120 | while (BUFFERP (c)); | 3118 | while (BUFFERP (c)); |
| 3121 | /* Remove the help from the frame */ | 3119 | /* Remove the help from the frame. */ |
| 3122 | unbind_to (count, Qnil); | 3120 | unbind_to (count, Qnil); |
| 3123 | 3121 | ||
| 3124 | redisplay (); | 3122 | redisplay (); |
| @@ -3126,7 +3124,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3126 | { | 3124 | { |
| 3127 | cancel_echoing (); | 3125 | cancel_echoing (); |
| 3128 | do | 3126 | do |
| 3129 | c = read_char (0, 0, 0, Qnil, 0, NULL); | 3127 | c = read_char (0, Qnil, Qnil, 0, NULL); |
| 3130 | while (BUFFERP (c)); | 3128 | while (BUFFERP (c)); |
| 3131 | } | 3129 | } |
| 3132 | } | 3130 | } |
| @@ -8332,9 +8330,9 @@ init_tool_bar_items (Lisp_Object reuse) | |||
| 8332 | static void | 8330 | static void |
| 8333 | append_tool_bar_item (void) | 8331 | append_tool_bar_item (void) |
| 8334 | { | 8332 | { |
| 8335 | ptrdiff_t incr = | 8333 | ptrdiff_t incr |
| 8336 | (ntool_bar_items | 8334 | = (ntool_bar_items |
| 8337 | - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); | 8335 | - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); |
| 8338 | 8336 | ||
| 8339 | /* Enlarge tool_bar_items_vector if necessary. */ | 8337 | /* Enlarge tool_bar_items_vector if necessary. */ |
| 8340 | if (0 < incr) | 8338 | if (0 < incr) |
| @@ -8352,8 +8350,8 @@ append_tool_bar_item (void) | |||
| 8352 | 8350 | ||
| 8353 | 8351 | ||
| 8354 | 8352 | ||
| 8355 | /* Read a character using menus based on maps in the array MAPS. | 8353 | /* Read a character using menus based on the keymap MAP. |
| 8356 | NMAPS is the length of MAPS. Return nil if there are no menus in the maps. | 8354 | Return nil if there are no menus in the maps. |
| 8357 | Return t if we displayed a menu but the user rejected it. | 8355 | Return t if we displayed a menu but the user rejected it. |
| 8358 | 8356 | ||
| 8359 | PREV_EVENT is the previous input event, or nil if we are reading | 8357 | PREV_EVENT is the previous input event, or nil if we are reading |
| @@ -8373,28 +8371,17 @@ append_tool_bar_item (void) | |||
| 8373 | and do auto-saving in the inner call of read_char. */ | 8371 | and do auto-saving in the inner call of read_char. */ |
| 8374 | 8372 | ||
| 8375 | static Lisp_Object | 8373 | static Lisp_Object |
| 8376 | read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | 8374 | read_char_x_menu_prompt (Lisp_Object map, |
| 8377 | Lisp_Object prev_event, bool *used_mouse_menu) | 8375 | Lisp_Object prev_event, bool *used_mouse_menu) |
| 8378 | { | 8376 | { |
| 8379 | #ifdef HAVE_MENUS | ||
| 8380 | ptrdiff_t mapno; | ||
| 8381 | #endif | ||
| 8382 | |||
| 8383 | if (used_mouse_menu) | 8377 | if (used_mouse_menu) |
| 8384 | *used_mouse_menu = 0; | 8378 | *used_mouse_menu = 0; |
| 8385 | 8379 | ||
| 8386 | /* Use local over global Menu maps */ | 8380 | /* Use local over global Menu maps. */ |
| 8387 | 8381 | ||
| 8388 | if (! menu_prompting) | 8382 | if (! menu_prompting) |
| 8389 | return Qnil; | 8383 | return Qnil; |
| 8390 | 8384 | ||
| 8391 | /* Optionally disregard all but the global map. */ | ||
| 8392 | if (inhibit_local_menu_bar_menus) | ||
| 8393 | { | ||
| 8394 | maps += (nmaps - 1); | ||
| 8395 | nmaps = 1; | ||
| 8396 | } | ||
| 8397 | |||
| 8398 | #ifdef HAVE_MENUS | 8385 | #ifdef HAVE_MENUS |
| 8399 | /* If we got to this point via a mouse click, | 8386 | /* If we got to this point via a mouse click, |
| 8400 | use a real menu for mouse selection. */ | 8387 | use a real menu for mouse selection. */ |
| @@ -8403,16 +8390,9 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 8403 | && !EQ (XCAR (prev_event), Qtool_bar)) | 8390 | && !EQ (XCAR (prev_event), Qtool_bar)) |
| 8404 | { | 8391 | { |
| 8405 | /* Display the menu and get the selection. */ | 8392 | /* Display the menu and get the selection. */ |
| 8406 | Lisp_Object *realmaps = alloca (nmaps * sizeof *realmaps); | ||
| 8407 | Lisp_Object value; | 8393 | Lisp_Object value; |
| 8408 | ptrdiff_t nmaps1 = 0; | ||
| 8409 | 8394 | ||
| 8410 | /* Use the maps that are not nil. */ | 8395 | value = Fx_popup_menu (prev_event, get_keymap (map, 0, 1)); |
| 8411 | for (mapno = 0; mapno < nmaps; mapno++) | ||
| 8412 | if (!NILP (maps[mapno])) | ||
| 8413 | realmaps[nmaps1++] = maps[mapno]; | ||
| 8414 | |||
| 8415 | value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps)); | ||
| 8416 | if (CONSP (value)) | 8396 | if (CONSP (value)) |
| 8417 | { | 8397 | { |
| 8418 | Lisp_Object tem; | 8398 | Lisp_Object tem; |
| @@ -8454,9 +8434,8 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 8454 | 8434 | ||
| 8455 | static Lisp_Object | 8435 | static Lisp_Object |
| 8456 | read_char_minibuf_menu_prompt (int commandflag, | 8436 | read_char_minibuf_menu_prompt (int commandflag, |
| 8457 | ptrdiff_t nmaps, Lisp_Object *maps) | 8437 | Lisp_Object map) |
| 8458 | { | 8438 | { |
| 8459 | ptrdiff_t mapno; | ||
| 8460 | register Lisp_Object name; | 8439 | register Lisp_Object name; |
| 8461 | ptrdiff_t nlength; | 8440 | ptrdiff_t nlength; |
| 8462 | /* FIXME: Use the minibuffer's frame width. */ | 8441 | /* FIXME: Use the minibuffer's frame width. */ |
| @@ -8467,18 +8446,12 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8467 | Lisp_Object prompt_strings = Qnil; | 8446 | Lisp_Object prompt_strings = Qnil; |
| 8468 | 8447 | ||
| 8469 | vector = Qnil; | 8448 | vector = Qnil; |
| 8470 | name = Qnil; | ||
| 8471 | 8449 | ||
| 8472 | if (! menu_prompting) | 8450 | if (! menu_prompting) |
| 8473 | return Qnil; | 8451 | return Qnil; |
| 8474 | 8452 | ||
| 8475 | /* Get the menu name from the first map that has one (a prompt string). */ | 8453 | map = get_keymap (map, 0, 1); |
| 8476 | for (mapno = 0; mapno < nmaps; mapno++) | 8454 | name = Fkeymap_prompt (map); |
| 8477 | { | ||
| 8478 | name = Fkeymap_prompt (maps[mapno]); | ||
| 8479 | if (!NILP (name)) | ||
| 8480 | break; | ||
| 8481 | } | ||
| 8482 | 8455 | ||
| 8483 | /* If we don't have any menus, just read a character normally. */ | 8456 | /* If we don't have any menus, just read a character normally. */ |
| 8484 | if (!STRINGP (name)) | 8457 | if (!STRINGP (name)) |
| @@ -8486,15 +8459,13 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8486 | 8459 | ||
| 8487 | #define PUSH_C_STR(str, listvar) \ | 8460 | #define PUSH_C_STR(str, listvar) \ |
| 8488 | listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar) | 8461 | listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar) |
| 8489 | 8462 | ||
| 8490 | /* Prompt string always starts with map's prompt, and a space. */ | 8463 | /* Prompt string always starts with map's prompt, and a space. */ |
| 8491 | prompt_strings = Fcons (name, prompt_strings); | 8464 | prompt_strings = Fcons (name, prompt_strings); |
| 8492 | PUSH_C_STR (": ", prompt_strings); | 8465 | PUSH_C_STR (": ", prompt_strings); |
| 8493 | nlength = SCHARS (name) + 2; | 8466 | nlength = SCHARS (name) + 2; |
| 8494 | 8467 | ||
| 8495 | /* Start prompting at start of first map. */ | 8468 | rest = map; |
| 8496 | mapno = 0; | ||
| 8497 | rest = maps[mapno]; | ||
| 8498 | 8469 | ||
| 8499 | /* Present the documented bindings, a line at a time. */ | 8470 | /* Present the documented bindings, a line at a time. */ |
| 8500 | while (1) | 8471 | while (1) |
| @@ -8512,18 +8483,14 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8512 | 8483 | ||
| 8513 | /* FIXME: Use map_keymap to handle new keymap formats. */ | 8484 | /* FIXME: Use map_keymap to handle new keymap formats. */ |
| 8514 | 8485 | ||
| 8515 | /* If reached end of map, start at beginning of next map. */ | 8486 | /* At end of map, wrap around if just starting, |
| 8487 | or end this line if already have something on it. */ | ||
| 8516 | if (NILP (rest)) | 8488 | if (NILP (rest)) |
| 8517 | { | 8489 | { |
| 8518 | mapno++; | 8490 | if (notfirst || nobindings) |
| 8519 | /* At end of last map, wrap around to first map if just starting, | 8491 | break; |
| 8520 | or end this line if already have something on it. */ | 8492 | else |
| 8521 | if (mapno == nmaps) | 8493 | rest = map; |
| 8522 | { | ||
| 8523 | mapno = 0; | ||
| 8524 | if (notfirst || nobindings) break; | ||
| 8525 | } | ||
| 8526 | rest = maps[mapno]; | ||
| 8527 | } | 8494 | } |
| 8528 | 8495 | ||
| 8529 | /* Look at the next element of the map. */ | 8496 | /* Look at the next element of the map. */ |
| @@ -8657,7 +8624,7 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8657 | } | 8624 | } |
| 8658 | 8625 | ||
| 8659 | /* Prompt with that and read response. */ | 8626 | /* Prompt with that and read response. */ |
| 8660 | message3_nolog (apply1 (intern ("concat"), menu_strings)); | 8627 | message3_nolog (apply1 (intern ("concat"), Fnreverse (menu_strings))); |
| 8661 | 8628 | ||
| 8662 | /* Make believe it's not a keyboard macro in case the help char | 8629 | /* Make believe it's not a keyboard macro in case the help char |
| 8663 | is pressed. Help characters are not recorded because menu prompting | 8630 | is pressed. Help characters are not recorded because menu prompting |
| @@ -8665,7 +8632,7 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8665 | orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); | 8632 | orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); |
| 8666 | kset_defining_kbd_macro (current_kboard, Qnil); | 8633 | kset_defining_kbd_macro (current_kboard, Qnil); |
| 8667 | do | 8634 | do |
| 8668 | obj = read_char (commandflag, 0, 0, Qt, 0, NULL); | 8635 | obj = read_char (commandflag, Qnil, Qt, 0, NULL); |
| 8669 | while (BUFFERP (obj)); | 8636 | while (BUFFERP (obj)); |
| 8670 | kset_defining_kbd_macro (current_kboard, orig_defn_macro); | 8637 | kset_defining_kbd_macro (current_kboard, orig_defn_macro); |
| 8671 | 8638 | ||
| @@ -8686,46 +8653,18 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8686 | 8653 | ||
| 8687 | /* Reading key sequences. */ | 8654 | /* Reading key sequences. */ |
| 8688 | 8655 | ||
| 8689 | /* Follow KEY in the maps in CURRENT[0..NMAPS-1], placing its bindings | 8656 | static Lisp_Object |
| 8690 | in DEFS[0..NMAPS-1]. Set NEXT[i] to DEFS[i] if DEFS[i] is a | 8657 | follow_key (Lisp_Object keymap, Lisp_Object key) |
| 8691 | keymap, or nil otherwise. Return the index of the first keymap in | ||
| 8692 | which KEY has any binding, or NMAPS if no map has a binding. | ||
| 8693 | |||
| 8694 | If KEY is a meta ASCII character, treat it like meta-prefix-char | ||
| 8695 | followed by the corresponding non-meta character. Keymaps in | ||
| 8696 | CURRENT with non-prefix bindings for meta-prefix-char become nil in | ||
| 8697 | NEXT. | ||
| 8698 | |||
| 8699 | If KEY has no bindings in any of the CURRENT maps, NEXT is left | ||
| 8700 | unmodified. | ||
| 8701 | |||
| 8702 | NEXT may be the same array as CURRENT. */ | ||
| 8703 | |||
| 8704 | static int | ||
| 8705 | follow_key (Lisp_Object key, ptrdiff_t nmaps, Lisp_Object *current, | ||
| 8706 | Lisp_Object *defs, Lisp_Object *next) | ||
| 8707 | { | 8658 | { |
| 8708 | ptrdiff_t i, first_binding; | 8659 | return access_keymap (get_keymap (keymap, 0, 1), |
| 8709 | 8660 | key, 1, 0, 1); | |
| 8710 | first_binding = nmaps; | 8661 | } |
| 8711 | for (i = nmaps - 1; i >= 0; i--) | ||
| 8712 | { | ||
| 8713 | if (! NILP (current[i])) | ||
| 8714 | { | ||
| 8715 | defs[i] = access_keymap (current[i], key, 1, 0, 1); | ||
| 8716 | if (! NILP (defs[i])) | ||
| 8717 | first_binding = i; | ||
| 8718 | } | ||
| 8719 | else | ||
| 8720 | defs[i] = Qnil; | ||
| 8721 | } | ||
| 8722 | |||
| 8723 | /* Given the set of bindings we've found, produce the next set of maps. */ | ||
| 8724 | if (first_binding < nmaps) | ||
| 8725 | for (i = 0; i < nmaps; i++) | ||
| 8726 | next[i] = NILP (defs[i]) ? Qnil : get_keymap (defs[i], 0, 1); | ||
| 8727 | 8662 | ||
| 8728 | return first_binding; | 8663 | static Lisp_Object |
| 8664 | active_maps (Lisp_Object first_event) | ||
| 8665 | { | ||
| 8666 | Lisp_Object position = INTEGERP (first_event) ? Qnil : first_event; | ||
| 8667 | return Fcons (Qkeymap, Fcurrent_active_maps (Qt, position)); | ||
| 8729 | } | 8668 | } |
| 8730 | 8669 | ||
| 8731 | /* Structure used to keep track of partial application of key remapping | 8670 | /* Structure used to keep track of partial application of key remapping |
| @@ -8857,8 +8796,9 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, | |||
| 8857 | static bool | 8796 | static bool |
| 8858 | test_undefined (Lisp_Object binding) | 8797 | test_undefined (Lisp_Object binding) |
| 8859 | { | 8798 | { |
| 8860 | return (EQ (binding, Qundefined) | 8799 | return (NILP (binding) |
| 8861 | || (!NILP (binding) && SYMBOLP (binding) | 8800 | || EQ (binding, Qundefined) |
| 8801 | || (SYMBOLP (binding) | ||
| 8862 | && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); | 8802 | && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); |
| 8863 | } | 8803 | } |
| 8864 | 8804 | ||
| @@ -8904,7 +8844,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8904 | bool dont_downcase_last, bool can_return_switch_frame, | 8844 | bool dont_downcase_last, bool can_return_switch_frame, |
| 8905 | bool fix_current_buffer) | 8845 | bool fix_current_buffer) |
| 8906 | { | 8846 | { |
| 8907 | Lisp_Object from_string; | ||
| 8908 | ptrdiff_t count = SPECPDL_INDEX (); | 8847 | ptrdiff_t count = SPECPDL_INDEX (); |
| 8909 | 8848 | ||
| 8910 | /* How many keys there are in the current key sequence. */ | 8849 | /* How many keys there are in the current key sequence. */ |
| @@ -8915,34 +8854,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8915 | ptrdiff_t echo_start IF_LINT (= 0); | 8854 | ptrdiff_t echo_start IF_LINT (= 0); |
| 8916 | ptrdiff_t keys_start; | 8855 | ptrdiff_t keys_start; |
| 8917 | 8856 | ||
| 8918 | /* The number of keymaps we're scanning right now, and the number of | 8857 | Lisp_Object current_binding = Qnil; |
| 8919 | keymaps we have allocated space for. */ | 8858 | Lisp_Object first_event = Qnil; |
| 8920 | ptrdiff_t nmaps; | ||
| 8921 | ptrdiff_t nmaps_allocated = 0; | ||
| 8922 | |||
| 8923 | /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in | ||
| 8924 | the current keymaps. */ | ||
| 8925 | Lisp_Object *defs = NULL; | ||
| 8926 | |||
| 8927 | /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] | ||
| 8928 | in the current keymaps, or nil where it is not a prefix. */ | ||
| 8929 | Lisp_Object *submaps = NULL; | ||
| 8930 | |||
| 8931 | /* The local map to start out with at start of key sequence. */ | ||
| 8932 | Lisp_Object orig_local_map; | ||
| 8933 | 8859 | ||
| 8934 | /* The map from the `keymap' property to start out with at start of | ||
| 8935 | key sequence. */ | ||
| 8936 | Lisp_Object orig_keymap; | ||
| 8937 | |||
| 8938 | /* Positive if we have already considered switching to the local-map property | ||
| 8939 | of the place where a mouse click occurred. */ | ||
| 8940 | int localized_local_map = 0; | ||
| 8941 | |||
| 8942 | /* The index in submaps[] of the first keymap that has a binding for | ||
| 8943 | this key sequence. In other words, the lowest i such that | ||
| 8944 | submaps[i] is non-nil. */ | ||
| 8945 | ptrdiff_t first_binding; | ||
| 8946 | /* Index of the first key that has no binding. | 8860 | /* Index of the first key that has no binding. |
| 8947 | It is useless to try fkey.start larger than that. */ | 8861 | It is useless to try fkey.start larger than that. */ |
| 8948 | int first_unbound; | 8862 | int first_unbound; |
| @@ -8985,11 +8899,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8985 | While we're reading, we keep the event here. */ | 8899 | While we're reading, we keep the event here. */ |
| 8986 | Lisp_Object delayed_switch_frame; | 8900 | Lisp_Object delayed_switch_frame; |
| 8987 | 8901 | ||
| 8988 | /* See the comment below... */ | ||
| 8989 | #if defined (GOBBLE_FIRST_EVENT) | ||
| 8990 | Lisp_Object first_event; | ||
| 8991 | #endif | ||
| 8992 | |||
| 8993 | Lisp_Object original_uppercase IF_LINT (= Qnil); | 8902 | Lisp_Object original_uppercase IF_LINT (= Qnil); |
| 8994 | int original_uppercase_position = -1; | 8903 | int original_uppercase_position = -1; |
| 8995 | 8904 | ||
| @@ -9001,10 +8910,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9001 | /* List of events for which a fake prefix key has been generated. */ | 8910 | /* List of events for which a fake prefix key has been generated. */ |
| 9002 | Lisp_Object fake_prefixed_keys = Qnil; | 8911 | Lisp_Object fake_prefixed_keys = Qnil; |
| 9003 | 8912 | ||
| 9004 | #if defined (GOBBLE_FIRST_EVENT) | ||
| 9005 | int junk; | ||
| 9006 | #endif | ||
| 9007 | |||
| 9008 | struct gcpro gcpro1; | 8913 | struct gcpro gcpro1; |
| 9009 | 8914 | ||
| 9010 | GCPRO1 (fake_prefixed_keys); | 8915 | GCPRO1 (fake_prefixed_keys); |
| @@ -9040,21 +8945,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9040 | keys_start = this_command_key_count; | 8945 | keys_start = this_command_key_count; |
| 9041 | this_single_command_key_start = keys_start; | 8946 | this_single_command_key_start = keys_start; |
| 9042 | 8947 | ||
| 9043 | #if defined (GOBBLE_FIRST_EVENT) | ||
| 9044 | /* This doesn't quite work, because some of the things that read_char | ||
| 9045 | does cannot safely be bypassed. It seems too risky to try to make | ||
| 9046 | this work right. */ | ||
| 9047 | |||
| 9048 | /* Read the first char of the sequence specially, before setting | ||
| 9049 | up any keymaps, in case a filter runs and switches buffers on us. */ | ||
| 9050 | first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, | ||
| 9051 | &junk, NULL); | ||
| 9052 | #endif /* GOBBLE_FIRST_EVENT */ | ||
| 9053 | |||
| 9054 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9055 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9056 | from_string = Qnil; | ||
| 9057 | |||
| 9058 | /* We jump here when we need to reinitialize fkey and keytran; this | 8948 | /* We jump here when we need to reinitialize fkey and keytran; this |
| 9059 | happens if we switch keyboards between rescans. */ | 8949 | happens if we switch keyboards between rescans. */ |
| 9060 | replay_entire_sequence: | 8950 | replay_entire_sequence: |
| @@ -9079,59 +8969,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9079 | keybuf with its symbol, or if the sequence starts with a mouse | 8969 | keybuf with its symbol, or if the sequence starts with a mouse |
| 9080 | click and we need to switch buffers, we jump back here to rebuild | 8970 | click and we need to switch buffers, we jump back here to rebuild |
| 9081 | the initial keymaps from the current buffer. */ | 8971 | the initial keymaps from the current buffer. */ |
| 9082 | nmaps = 0; | 8972 | current_binding = active_maps (first_event); |
| 9083 | |||
| 9084 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) | ||
| 9085 | { | ||
| 9086 | if (2 > nmaps_allocated) | ||
| 9087 | { | ||
| 9088 | submaps = alloca (2 * sizeof *submaps); | ||
| 9089 | defs = alloca (2 * sizeof *defs); | ||
| 9090 | nmaps_allocated = 2; | ||
| 9091 | } | ||
| 9092 | submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); | ||
| 9093 | } | ||
| 9094 | else if (!NILP (Voverriding_local_map)) | ||
| 9095 | { | ||
| 9096 | if (2 > nmaps_allocated) | ||
| 9097 | { | ||
| 9098 | submaps = alloca (2 * sizeof *submaps); | ||
| 9099 | defs = alloca (2 * sizeof *defs); | ||
| 9100 | nmaps_allocated = 2; | ||
| 9101 | } | ||
| 9102 | submaps[nmaps++] = Voverriding_local_map; | ||
| 9103 | } | ||
| 9104 | else | ||
| 9105 | { | ||
| 9106 | ptrdiff_t nminor; | ||
| 9107 | ptrdiff_t total; | ||
| 9108 | Lisp_Object *maps; | ||
| 9109 | |||
| 9110 | nminor = current_minor_maps (0, &maps); | ||
| 9111 | total = nminor + (!NILP (orig_keymap) ? 3 : 2); | ||
| 9112 | |||
| 9113 | if (total > nmaps_allocated) | ||
| 9114 | { | ||
| 9115 | submaps = alloca (total * sizeof *submaps); | ||
| 9116 | defs = alloca (total * sizeof *defs); | ||
| 9117 | nmaps_allocated = total; | ||
| 9118 | } | ||
| 9119 | |||
| 9120 | if (!NILP (orig_keymap)) | ||
| 9121 | submaps[nmaps++] = orig_keymap; | ||
| 9122 | |||
| 9123 | memcpy (submaps + nmaps, maps, nminor * sizeof (submaps[0])); | ||
| 9124 | |||
| 9125 | nmaps += nminor; | ||
| 9126 | |||
| 9127 | submaps[nmaps++] = orig_local_map; | ||
| 9128 | } | ||
| 9129 | submaps[nmaps++] = current_global_map; | ||
| 9130 | |||
| 9131 | /* Find an accurate initial value for first_binding. */ | ||
| 9132 | for (first_binding = 0; first_binding < nmaps; first_binding++) | ||
| 9133 | if (! NILP (submaps[first_binding])) | ||
| 9134 | break; | ||
| 9135 | 8973 | ||
| 9136 | /* Start from the beginning in keybuf. */ | 8974 | /* Start from the beginning in keybuf. */ |
| 9137 | t = 0; | 8975 | t = 0; |
| @@ -9145,9 +8983,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9145 | /* If the best binding for the current key sequence is a keymap, or | 8983 | /* If the best binding for the current key sequence is a keymap, or |
| 9146 | we may be looking at a function key's escape sequence, keep on | 8984 | we may be looking at a function key's escape sequence, keep on |
| 9147 | reading. */ | 8985 | reading. */ |
| 9148 | while (first_binding < nmaps | 8986 | while (!NILP (current_binding) |
| 9149 | /* Keep reading as long as there's a prefix binding. */ | 8987 | /* Keep reading as long as there's a prefix binding. */ |
| 9150 | ? !NILP (submaps[first_binding]) | 8988 | ? KEYMAPP (current_binding) |
| 9151 | /* Don't return in the middle of a possible function key sequence, | 8989 | /* Don't return in the middle of a possible function key sequence, |
| 9152 | if the only bindings we found were via case conversion. | 8990 | if the only bindings we found were via case conversion. |
| 9153 | Thus, if ESC O a has a function-key-map translation | 8991 | Thus, if ESC O a has a function-key-map translation |
| @@ -9171,7 +9009,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9171 | just one key. */ | 9009 | just one key. */ |
| 9172 | ptrdiff_t echo_local_start IF_LINT (= 0); | 9010 | ptrdiff_t echo_local_start IF_LINT (= 0); |
| 9173 | int keys_local_start; | 9011 | int keys_local_start; |
| 9174 | ptrdiff_t local_first_binding; | 9012 | Lisp_Object new_binding; |
| 9175 | 9013 | ||
| 9176 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); | 9014 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); |
| 9177 | eassert (indec.start <= indec.end); | 9015 | eassert (indec.start <= indec.end); |
| @@ -9208,7 +9046,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9208 | if (INTERACTIVE) | 9046 | if (INTERACTIVE) |
| 9209 | echo_local_start = echo_length (); | 9047 | echo_local_start = echo_length (); |
| 9210 | keys_local_start = this_command_key_count; | 9048 | keys_local_start = this_command_key_count; |
| 9211 | local_first_binding = first_binding; | ||
| 9212 | 9049 | ||
| 9213 | replay_key: | 9050 | replay_key: |
| 9214 | /* These are no-ops, unless we throw away a keystroke below and | 9051 | /* These are no-ops, unless we throw away a keystroke below and |
| @@ -9218,7 +9055,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9218 | if (INTERACTIVE && t < mock_input) | 9055 | if (INTERACTIVE && t < mock_input) |
| 9219 | echo_truncate (echo_local_start); | 9056 | echo_truncate (echo_local_start); |
| 9220 | this_command_key_count = keys_local_start; | 9057 | this_command_key_count = keys_local_start; |
| 9221 | first_binding = local_first_binding; | ||
| 9222 | 9058 | ||
| 9223 | /* By default, assume each event is "real". */ | 9059 | /* By default, assume each event is "real". */ |
| 9224 | last_real_key_start = t; | 9060 | last_real_key_start = t; |
| @@ -9243,8 +9079,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9243 | { | 9079 | { |
| 9244 | KBOARD *interrupted_kboard = current_kboard; | 9080 | KBOARD *interrupted_kboard = current_kboard; |
| 9245 | struct frame *interrupted_frame = SELECTED_FRAME (); | 9081 | struct frame *interrupted_frame = SELECTED_FRAME (); |
| 9246 | key = read_char (NILP (prompt), nmaps, | 9082 | key = read_char (NILP (prompt), |
| 9247 | (Lisp_Object *) submaps, last_nonmenu_event, | 9083 | current_binding, last_nonmenu_event, |
| 9248 | &used_mouse_menu, NULL); | 9084 | &used_mouse_menu, NULL); |
| 9249 | if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ | 9085 | if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ |
| 9250 | /* When switching to a new tty (with a new keyboard), | 9086 | /* When switching to a new tty (with a new keyboard), |
| @@ -9299,8 +9135,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9299 | KVAR (interrupted_kboard, kbd_queue))); | 9135 | KVAR (interrupted_kboard, kbd_queue))); |
| 9300 | } | 9136 | } |
| 9301 | mock_input = 0; | 9137 | mock_input = 0; |
| 9302 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9303 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9304 | goto replay_entire_sequence; | 9138 | goto replay_entire_sequence; |
| 9305 | } | 9139 | } |
| 9306 | } | 9140 | } |
| @@ -9341,12 +9175,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9341 | { | 9175 | { |
| 9342 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 9176 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 9343 | Fkill_emacs (Qnil); | 9177 | Fkill_emacs (Qnil); |
| 9344 | if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) | 9178 | if (XBUFFER (XWINDOW (selected_window)->buffer) |
| 9179 | != current_buffer) | ||
| 9345 | Fset_buffer (XWINDOW (selected_window)->buffer); | 9180 | Fset_buffer (XWINDOW (selected_window)->buffer); |
| 9346 | } | 9181 | } |
| 9347 | 9182 | ||
| 9348 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9349 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9350 | goto replay_sequence; | 9183 | goto replay_sequence; |
| 9351 | } | 9184 | } |
| 9352 | 9185 | ||
| @@ -9363,8 +9196,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9363 | keybuf[t++] = key; | 9196 | keybuf[t++] = key; |
| 9364 | mock_input = t; | 9197 | mock_input = t; |
| 9365 | Vquit_flag = Qnil; | 9198 | Vquit_flag = Qnil; |
| 9366 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9367 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9368 | goto replay_sequence; | 9199 | goto replay_sequence; |
| 9369 | } | 9200 | } |
| 9370 | 9201 | ||
| @@ -9384,6 +9215,22 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9384 | } | 9215 | } |
| 9385 | } | 9216 | } |
| 9386 | 9217 | ||
| 9218 | if (NILP (first_event)) | ||
| 9219 | { | ||
| 9220 | first_event = key; | ||
| 9221 | /* Even if first_event does not specify a particular | ||
| 9222 | window/position, it's important to recompute the maps here | ||
| 9223 | since a long time might have passed since we entered | ||
| 9224 | read_key_sequence, and a timer (or process-filter or | ||
| 9225 | special-event-map, ...) might have switched the current buffer | ||
| 9226 | or the selected window from under us in the mean time. */ | ||
| 9227 | if (fix_current_buffer | ||
| 9228 | && (XBUFFER (XWINDOW (selected_window)->buffer) | ||
| 9229 | != current_buffer)) | ||
| 9230 | Fset_buffer (XWINDOW (selected_window)->buffer); | ||
| 9231 | current_binding = active_maps (first_event); | ||
| 9232 | } | ||
| 9233 | |||
| 9387 | GROW_RAW_KEYBUF; | 9234 | GROW_RAW_KEYBUF; |
| 9388 | ASET (raw_keybuf, raw_keybuf_count, key); | 9235 | ASET (raw_keybuf, raw_keybuf_count, key); |
| 9389 | raw_keybuf_count++; | 9236 | raw_keybuf_count++; |
| @@ -9405,16 +9252,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9405 | or when user programs play with this-command-keys. */ | 9252 | or when user programs play with this-command-keys. */ |
| 9406 | if (EVENT_HAS_PARAMETERS (key)) | 9253 | if (EVENT_HAS_PARAMETERS (key)) |
| 9407 | { | 9254 | { |
| 9408 | Lisp_Object kind; | 9255 | Lisp_Object kind = EVENT_HEAD_KIND (EVENT_HEAD (key)); |
| 9409 | Lisp_Object string; | ||
| 9410 | |||
| 9411 | kind = EVENT_HEAD_KIND (EVENT_HEAD (key)); | ||
| 9412 | if (EQ (kind, Qmouse_click)) | 9256 | if (EQ (kind, Qmouse_click)) |
| 9413 | { | 9257 | { |
| 9414 | Lisp_Object window, posn; | 9258 | Lisp_Object window = POSN_WINDOW (EVENT_START (key)); |
| 9415 | 9259 | Lisp_Object posn = POSN_POSN (EVENT_START (key)); | |
| 9416 | window = POSN_WINDOW (EVENT_START (key)); | ||
| 9417 | posn = POSN_POSN (EVENT_START (key)); | ||
| 9418 | 9260 | ||
| 9419 | if (CONSP (posn) | 9261 | if (CONSP (posn) |
| 9420 | || (!NILP (fake_prefixed_keys) | 9262 | || (!NILP (fake_prefixed_keys) |
| @@ -9457,58 +9299,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9457 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 9299 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 9458 | Fkill_emacs (Qnil); | 9300 | Fkill_emacs (Qnil); |
| 9459 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 9301 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); |
| 9460 | orig_local_map = get_local_map (PT, current_buffer, | ||
| 9461 | Qlocal_map); | ||
| 9462 | orig_keymap = get_local_map (PT, current_buffer, | ||
| 9463 | Qkeymap); | ||
| 9464 | goto replay_sequence; | 9302 | goto replay_sequence; |
| 9465 | } | 9303 | } |
| 9466 | |||
| 9467 | /* For a mouse click, get the local text-property keymap | ||
| 9468 | of the place clicked on, rather than point. */ | ||
| 9469 | if (CONSP (XCDR (key)) | ||
| 9470 | && ! localized_local_map) | ||
| 9471 | { | ||
| 9472 | Lisp_Object map_here, start, pos; | ||
| 9473 | |||
| 9474 | localized_local_map = 1; | ||
| 9475 | start = EVENT_START (key); | ||
| 9476 | |||
| 9477 | if (CONSP (start) && POSN_INBUFFER_P (start)) | ||
| 9478 | { | ||
| 9479 | pos = POSN_BUFFER_POSN (start); | ||
| 9480 | if (INTEGERP (pos) | ||
| 9481 | && XINT (pos) >= BEGV | ||
| 9482 | && XINT (pos) <= ZV) | ||
| 9483 | { | ||
| 9484 | map_here = get_local_map (XINT (pos), | ||
| 9485 | current_buffer, | ||
| 9486 | Qlocal_map); | ||
| 9487 | if (!EQ (map_here, orig_local_map)) | ||
| 9488 | { | ||
| 9489 | orig_local_map = map_here; | ||
| 9490 | ++localized_local_map; | ||
| 9491 | } | ||
| 9492 | |||
| 9493 | map_here = get_local_map (XINT (pos), | ||
| 9494 | current_buffer, | ||
| 9495 | Qkeymap); | ||
| 9496 | if (!EQ (map_here, orig_keymap)) | ||
| 9497 | { | ||
| 9498 | orig_keymap = map_here; | ||
| 9499 | ++localized_local_map; | ||
| 9500 | } | ||
| 9501 | |||
| 9502 | if (localized_local_map > 1) | ||
| 9503 | { | ||
| 9504 | keybuf[t] = key; | ||
| 9505 | mock_input = t + 1; | ||
| 9506 | |||
| 9507 | goto replay_sequence; | ||
| 9508 | } | ||
| 9509 | } | ||
| 9510 | } | ||
| 9511 | } | ||
| 9512 | } | 9304 | } |
| 9513 | 9305 | ||
| 9514 | /* Expand mode-line and scroll-bar events into two events: | 9306 | /* Expand mode-line and scroll-bar events into two events: |
| @@ -9529,63 +9321,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9529 | prevent proper action when the event is pushed | 9321 | prevent proper action when the event is pushed |
| 9530 | back into unread-command-events. */ | 9322 | back into unread-command-events. */ |
| 9531 | fake_prefixed_keys = Fcons (key, fake_prefixed_keys); | 9323 | fake_prefixed_keys = Fcons (key, fake_prefixed_keys); |
| 9532 | |||
| 9533 | /* If on a mode line string with a local keymap, | ||
| 9534 | reconsider the key sequence with that keymap. */ | ||
| 9535 | if (string = POSN_STRING (EVENT_START (key)), | ||
| 9536 | (CONSP (string) && STRINGP (XCAR (string)))) | ||
| 9537 | { | ||
| 9538 | Lisp_Object pos, map, map2; | ||
| 9539 | |||
| 9540 | pos = XCDR (string); | ||
| 9541 | string = XCAR (string); | ||
| 9542 | if (XINT (pos) >= 0 | ||
| 9543 | && XINT (pos) < SCHARS (string)) | ||
| 9544 | { | ||
| 9545 | map = Fget_text_property (pos, Qlocal_map, string); | ||
| 9546 | if (!NILP (map)) | ||
| 9547 | orig_local_map = map; | ||
| 9548 | map2 = Fget_text_property (pos, Qkeymap, string); | ||
| 9549 | if (!NILP (map2)) | ||
| 9550 | orig_keymap = map2; | ||
| 9551 | if (!NILP (map) || !NILP (map2)) | ||
| 9552 | goto replay_sequence; | ||
| 9553 | } | ||
| 9554 | } | ||
| 9555 | |||
| 9556 | goto replay_key; | 9324 | goto replay_key; |
| 9557 | } | 9325 | } |
| 9558 | else if (NILP (from_string) | ||
| 9559 | && (string = POSN_STRING (EVENT_START (key)), | ||
| 9560 | (CONSP (string) && STRINGP (XCAR (string))))) | ||
| 9561 | { | ||
| 9562 | /* For a click on a string, i.e. overlay string or a | ||
| 9563 | string displayed via the `display' property, | ||
| 9564 | consider `local-map' and `keymap' properties of | ||
| 9565 | that string. */ | ||
| 9566 | Lisp_Object pos, map, map2; | ||
| 9567 | |||
| 9568 | pos = XCDR (string); | ||
| 9569 | string = XCAR (string); | ||
| 9570 | if (XINT (pos) >= 0 | ||
| 9571 | && XINT (pos) < SCHARS (string)) | ||
| 9572 | { | ||
| 9573 | map = Fget_text_property (pos, Qlocal_map, string); | ||
| 9574 | if (!NILP (map)) | ||
| 9575 | orig_local_map = map; | ||
| 9576 | map2 = Fget_text_property (pos, Qkeymap, string); | ||
| 9577 | if (!NILP (map2)) | ||
| 9578 | orig_keymap = map2; | ||
| 9579 | |||
| 9580 | if (!NILP (map) || !NILP (map2)) | ||
| 9581 | { | ||
| 9582 | from_string = string; | ||
| 9583 | keybuf[t++] = key; | ||
| 9584 | mock_input = t; | ||
| 9585 | goto replay_sequence; | ||
| 9586 | } | ||
| 9587 | } | ||
| 9588 | } | ||
| 9589 | } | 9326 | } |
| 9590 | else if (CONSP (XCDR (key)) | 9327 | else if (CONSP (XCDR (key)) |
| 9591 | && CONSP (EVENT_START (key)) | 9328 | && CONSP (EVENT_START (key)) |
| @@ -9601,7 +9338,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9601 | if (bufsize - t <= 1) | 9338 | if (bufsize - t <= 1) |
| 9602 | error ("Key sequence too long"); | 9339 | error ("Key sequence too long"); |
| 9603 | keybuf[t] = posn; | 9340 | keybuf[t] = posn; |
| 9604 | keybuf[t+1] = key; | 9341 | keybuf[t + 1] = key; |
| 9605 | 9342 | ||
| 9606 | /* Zap the position in key, so we know that we've | 9343 | /* Zap the position in key, so we know that we've |
| 9607 | expanded it, and don't try to do so again. */ | 9344 | expanded it, and don't try to do so again. */ |
| @@ -9624,15 +9361,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9624 | 9361 | ||
| 9625 | /* We have finally decided that KEY is something we might want | 9362 | /* We have finally decided that KEY is something we might want |
| 9626 | to look up. */ | 9363 | to look up. */ |
| 9627 | first_binding = (follow_key (key, | 9364 | new_binding = follow_key (current_binding, key); |
| 9628 | nmaps - first_binding, | ||
| 9629 | submaps + first_binding, | ||
| 9630 | defs + first_binding, | ||
| 9631 | submaps + first_binding) | ||
| 9632 | + first_binding); | ||
| 9633 | 9365 | ||
| 9634 | /* If KEY wasn't bound, we'll try some fallbacks. */ | 9366 | /* If KEY wasn't bound, we'll try some fallbacks. */ |
| 9635 | if (first_binding < nmaps) | 9367 | if (!NILP (new_binding)) |
| 9636 | /* This is needed for the following scenario: | 9368 | /* This is needed for the following scenario: |
| 9637 | event 0: a down-event that gets dropped by calling replay_key. | 9369 | event 0: a down-event that gets dropped by calling replay_key. |
| 9638 | event 1: some normal prefix like C-h. | 9370 | event 1: some normal prefix like C-h. |
| @@ -9769,20 +9501,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9769 | new_click | 9501 | new_click |
| 9770 | = Fcons (new_head, Fcons (EVENT_START (key), Qnil)); | 9502 | = Fcons (new_head, Fcons (EVENT_START (key), Qnil)); |
| 9771 | 9503 | ||
| 9772 | /* Look for a binding for this new key. follow_key | 9504 | /* Look for a binding for this new key. */ |
| 9773 | promises that it didn't munge submaps the | 9505 | new_binding = follow_key (current_binding, new_click); |
| 9774 | last time we called it, since key was unbound. */ | ||
| 9775 | first_binding | ||
| 9776 | = (follow_key (new_click, | ||
| 9777 | nmaps - local_first_binding, | ||
| 9778 | submaps + local_first_binding, | ||
| 9779 | defs + local_first_binding, | ||
| 9780 | submaps + local_first_binding) | ||
| 9781 | + local_first_binding); | ||
| 9782 | 9506 | ||
| 9783 | /* If that click is bound, go for it. */ | 9507 | /* If that click is bound, go for it. */ |
| 9784 | if (first_binding < nmaps) | 9508 | if (!NILP (new_binding)) |
| 9785 | { | 9509 | { |
| 9510 | current_binding = new_binding; | ||
| 9786 | key = new_click; | 9511 | key = new_click; |
| 9787 | break; | 9512 | break; |
| 9788 | } | 9513 | } |
| @@ -9791,6 +9516,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9791 | } | 9516 | } |
| 9792 | } | 9517 | } |
| 9793 | } | 9518 | } |
| 9519 | current_binding = new_binding; | ||
| 9794 | 9520 | ||
| 9795 | keybuf[t++] = key; | 9521 | keybuf[t++] = key; |
| 9796 | /* Normally, last_nonmenu_event gets the previous key we read. | 9522 | /* Normally, last_nonmenu_event gets the previous key we read. |
| @@ -9822,9 +9548,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9822 | } | 9548 | } |
| 9823 | } | 9549 | } |
| 9824 | 9550 | ||
| 9825 | if (first_binding < nmaps | 9551 | if (!KEYMAPP (current_binding) |
| 9826 | && NILP (submaps[first_binding]) | 9552 | && !test_undefined (current_binding) |
| 9827 | && !test_undefined (defs[first_binding]) | ||
| 9828 | && indec.start >= t) | 9553 | && indec.start >= t) |
| 9829 | /* There is a binding and it's not a prefix. | 9554 | /* There is a binding and it's not a prefix. |
| 9830 | (and it doesn't have any input-decode-map translation pending). | 9555 | (and it doesn't have any input-decode-map translation pending). |
| @@ -9853,8 +9578,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9853 | first_binding >= nmaps) we don't want | 9578 | first_binding >= nmaps) we don't want |
| 9854 | to apply this function-key-mapping. */ | 9579 | to apply this function-key-mapping. */ |
| 9855 | fkey.end + 1 == t | 9580 | fkey.end + 1 == t |
| 9856 | && (first_binding >= nmaps | 9581 | && (test_undefined (current_binding)), |
| 9857 | || test_undefined (defs[first_binding])), | ||
| 9858 | &diff, prompt); | 9582 | &diff, prompt); |
| 9859 | UNGCPRO; | 9583 | UNGCPRO; |
| 9860 | if (done) | 9584 | if (done) |
| @@ -9897,7 +9621,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9897 | and cannot be part of a function key or translation, | 9621 | and cannot be part of a function key or translation, |
| 9898 | and is an upper case letter | 9622 | and is an upper case letter |
| 9899 | use the corresponding lower-case letter instead. */ | 9623 | use the corresponding lower-case letter instead. */ |
| 9900 | if (first_binding >= nmaps | 9624 | if (NILP (current_binding) |
| 9901 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t | 9625 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t |
| 9902 | && INTEGERP (key) | 9626 | && INTEGERP (key) |
| 9903 | && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK)) | 9627 | && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK)) |
| @@ -9928,7 +9652,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9928 | and cannot be part of a function key or translation, | 9652 | and cannot be part of a function key or translation, |
| 9929 | and is a shifted function key, | 9653 | and is a shifted function key, |
| 9930 | use the corresponding unshifted function key instead. */ | 9654 | use the corresponding unshifted function key instead. */ |
| 9931 | if (first_binding >= nmaps | 9655 | if (NILP (current_binding) |
| 9932 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) | 9656 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) |
| 9933 | { | 9657 | { |
| 9934 | Lisp_Object breakdown = parse_modifiers (key); | 9658 | Lisp_Object breakdown = parse_modifiers (key); |
| @@ -9969,9 +9693,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9969 | } | 9693 | } |
| 9970 | } | 9694 | } |
| 9971 | if (!dummyflag) | 9695 | if (!dummyflag) |
| 9972 | read_key_sequence_cmd = (first_binding < nmaps | 9696 | read_key_sequence_cmd = current_binding; |
| 9973 | ? defs[first_binding] | ||
| 9974 | : Qnil); | ||
| 9975 | read_key_sequence_remapped | 9697 | read_key_sequence_remapped |
| 9976 | /* Remap command through active keymaps. | 9698 | /* Remap command through active keymaps. |
| 9977 | Do the remapping here, before the unbind_to so it uses the keymaps | 9699 | Do the remapping here, before the unbind_to so it uses the keymaps |
| @@ -9985,7 +9707,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9985 | 9707 | ||
| 9986 | /* Don't downcase the last character if the caller says don't. | 9708 | /* Don't downcase the last character if the caller says don't. |
| 9987 | Don't downcase it if the result is undefined, either. */ | 9709 | Don't downcase it if the result is undefined, either. */ |
| 9988 | if ((dont_downcase_last || first_binding >= nmaps) | 9710 | if ((dont_downcase_last || NILP (current_binding)) |
| 9989 | && t > 0 | 9711 | && t > 0 |
| 9990 | && t - 1 == original_uppercase_position) | 9712 | && t - 1 == original_uppercase_position) |
| 9991 | { | 9713 | { |
| @@ -10082,7 +9804,7 @@ will read just one key sequence. */) | |||
| 10082 | 9804 | ||
| 10083 | memset (keybuf, 0, sizeof keybuf); | 9805 | memset (keybuf, 0, sizeof keybuf); |
| 10084 | GCPRO1 (keybuf[0]); | 9806 | GCPRO1 (keybuf[0]); |
| 10085 | gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); | 9807 | gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0])); |
| 10086 | 9808 | ||
| 10087 | if (NILP (continue_echo)) | 9809 | if (NILP (continue_echo)) |
| 10088 | { | 9810 | { |
| @@ -11692,10 +11414,6 @@ This variable is also the threshold for motion of the mouse | |||
| 11692 | to count as a drag. */); | 11414 | to count as a drag. */); |
| 11693 | double_click_fuzz = 3; | 11415 | double_click_fuzz = 3; |
| 11694 | 11416 | ||
| 11695 | DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus, | ||
| 11696 | doc: /* Non-nil means inhibit local map menu bar menus. */); | ||
| 11697 | inhibit_local_menu_bar_menus = 0; | ||
| 11698 | |||
| 11699 | DEFVAR_INT ("num-input-keys", num_input_keys, | 11417 | DEFVAR_INT ("num-input-keys", num_input_keys, |
| 11700 | doc: /* Number of complete key sequences read as input so far. | 11418 | doc: /* Number of complete key sequences read as input so far. |
| 11701 | This includes key sequences read from keyboard macros. | 11419 | This 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 | ||
| 483 | extern Lisp_Object parse_modifiers (Lisp_Object); | 483 | extern Lisp_Object parse_modifiers (Lisp_Object); |
| 484 | extern Lisp_Object reorder_modifiers (Lisp_Object); | 484 | extern Lisp_Object reorder_modifiers (Lisp_Object); |
| 485 | extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object, | 485 | extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object, |
| 486 | bool *, EMACS_TIME *); | 486 | bool *, EMACS_TIME *); |
| 487 | extern int parse_solitary_modifier (Lisp_Object symbol); | 487 | extern 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 | ||
| 1250 | DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, | 1250 | DEFUN ("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. |
| 1537 | OLP if non-nil indicates that we should obey `overriding-local-map' and | 1537 | OLP 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 |
| 1539 | like in the respective argument of `key-binding'. */) | 1539 | like 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 |
diff --git a/src/marker.c b/src/marker.c index a03a0b104ca..0d992c0abfa 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -499,11 +499,29 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position, | |||
| 499 | { | 499 | { |
| 500 | register ptrdiff_t charpos, bytepos; | 500 | register ptrdiff_t charpos, bytepos; |
| 501 | 501 | ||
| 502 | CHECK_NUMBER_COERCE_MARKER (position); | 502 | /* Do not use CHECK_NUMBER_COERCE_MARKER because we |
| 503 | charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), | 503 | don't want to call buf_charpos_to_bytepos if POSTION |
| 504 | XINT (position), | 504 | is a marker and so we know the bytepos already. */ |
| 505 | restricted ? BUF_ZV (b) : BUF_Z (b)); | 505 | if (INTEGERP (position)) |
| 506 | bytepos = buf_charpos_to_bytepos (b, charpos); | 506 | charpos = XINT (position), bytepos = -1; |
| 507 | else if (MARKERP (position)) | ||
| 508 | { | ||
| 509 | charpos = XMARKER (position)->charpos; | ||
| 510 | bytepos = XMARKER (position)->bytepos; | ||
| 511 | } | ||
| 512 | else | ||
| 513 | wrong_type_argument (Qinteger_or_marker_p, position); | ||
| 514 | |||
| 515 | charpos = clip_to_bounds | ||
| 516 | (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos, | ||
| 517 | restricted ? BUF_ZV (b) : BUF_Z (b)); | ||
| 518 | if (bytepos == -1) | ||
| 519 | bytepos = buf_charpos_to_bytepos (b, charpos); | ||
| 520 | else | ||
| 521 | bytepos = clip_to_bounds | ||
| 522 | (restricted ? BUF_BEGV_BYTE (b) : BUF_BEG_BYTE (b), | ||
| 523 | bytepos, restricted ? BUF_ZV_BYTE (b) : BUF_Z_BYTE (b)); | ||
| 524 | |||
| 507 | attach_marker (m, b, charpos, bytepos); | 525 | attach_marker (m, b, charpos, bytepos); |
| 508 | } | 526 | } |
| 509 | return marker; | 527 | return marker; |
diff --git a/src/window.c b/src/window.c index 68dcf28f52f..587ed8365c6 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1545,7 +1545,7 @@ Return POS. */) | |||
| 1545 | { | 1545 | { |
| 1546 | register struct window *w = decode_live_window (window); | 1546 | register struct window *w = decode_live_window (window); |
| 1547 | 1547 | ||
| 1548 | CHECK_NUMBER_COERCE_MARKER (pos); | 1548 | /* Type of POS is checked by Fgoto_char or set_marker_restricted ... */ |
| 1549 | 1549 | ||
| 1550 | if (w == XWINDOW (selected_window)) | 1550 | if (w == XWINDOW (selected_window)) |
| 1551 | { | 1551 | { |
| @@ -1555,6 +1555,8 @@ Return POS. */) | |||
| 1555 | { | 1555 | { |
| 1556 | struct buffer *old_buffer = current_buffer; | 1556 | struct buffer *old_buffer = current_buffer; |
| 1557 | 1557 | ||
| 1558 | /* ... but here we want to catch type error before buffer change. */ | ||
| 1559 | CHECK_NUMBER_COERCE_MARKER (pos); | ||
| 1558 | set_buffer_internal (XBUFFER (w->buffer)); | 1560 | set_buffer_internal (XBUFFER (w->buffer)); |
| 1559 | Fgoto_char (pos); | 1561 | Fgoto_char (pos); |
| 1560 | set_buffer_internal (old_buffer); | 1562 | set_buffer_internal (old_buffer); |
| @@ -1580,9 +1582,8 @@ overriding motion of point in order to display at this exact start. */) | |||
| 1580 | { | 1582 | { |
| 1581 | register struct window *w = decode_live_window (window); | 1583 | register struct window *w = decode_live_window (window); |
| 1582 | 1584 | ||
| 1583 | CHECK_NUMBER_COERCE_MARKER (pos); | ||
| 1584 | set_marker_restricted (w->start, pos, w->buffer); | 1585 | set_marker_restricted (w->start, pos, w->buffer); |
| 1585 | /* this is not right, but much easier than doing what is right. */ | 1586 | /* This is not right, but much easier than doing what is right. */ |
| 1586 | w->start_at_line_beg = 0; | 1587 | w->start_at_line_beg = 0; |
| 1587 | if (NILP (noforce)) | 1588 | if (NILP (noforce)) |
| 1588 | w->force_start = 1; | 1589 | w->force_start = 1; |
| @@ -4619,8 +4620,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4619 | } | 4620 | } |
| 4620 | 4621 | ||
| 4621 | /* Set the window start, and set up the window for redisplay. */ | 4622 | /* Set the window start, and set up the window for redisplay. */ |
| 4622 | set_marker_restricted (w->start, make_number (pos), | 4623 | set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), |
| 4623 | w->buffer); | 4624 | IT_BYTEPOS (it)); |
| 4624 | bytepos = marker_byte_position (w->start); | 4625 | bytepos = marker_byte_position (w->start); |
| 4625 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); | 4626 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); |
| 4626 | w->update_mode_line = 1; | 4627 | w->update_mode_line = 1; |
| @@ -5799,8 +5800,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5799 | { | 5800 | { |
| 5800 | /* Set window markers at start of visible range. */ | 5801 | /* Set window markers at start of visible range. */ |
| 5801 | if (XMARKER (w->start)->buffer == 0) | 5802 | if (XMARKER (w->start)->buffer == 0) |
| 5802 | set_marker_restricted (w->start, make_number (0), | 5803 | set_marker_restricted_both (w->start, w->buffer, 0, 0); |
| 5803 | w->buffer); | ||
| 5804 | if (XMARKER (w->pointm)->buffer == 0) | 5804 | if (XMARKER (w->pointm)->buffer == 0) |
| 5805 | set_marker_restricted_both | 5805 | set_marker_restricted_both |
| 5806 | (w->pointm, w->buffer, | 5806 | (w->pointm, w->buffer, |
| @@ -5818,10 +5818,8 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5818 | wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); | 5818 | wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); |
| 5819 | /* This will set the markers to beginning of visible | 5819 | /* This will set the markers to beginning of visible |
| 5820 | range. */ | 5820 | range. */ |
| 5821 | set_marker_restricted (w->start, | 5821 | set_marker_restricted_both (w->start, w->buffer, 0, 0); |
| 5822 | make_number (0), w->buffer); | 5822 | set_marker_restricted_both (w->pointm, w->buffer, 0, 0); |
| 5823 | set_marker_restricted (w->pointm, | ||
| 5824 | make_number (0), w->buffer); | ||
| 5825 | w->start_at_line_beg = 1; | 5823 | w->start_at_line_beg = 1; |
| 5826 | if (!NILP (w->dedicated)) | 5824 | if (!NILP (w->dedicated)) |
| 5827 | /* Record this window as dead. */ | 5825 | /* Record this window as dead. */ |
diff --git a/src/xdisp.c b/src/xdisp.c index 5b2eb1e84c8..2e357a6e321 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -9057,7 +9057,10 @@ move_it_vertically_backward (struct it *it, int dy) | |||
| 9057 | 9057 | ||
| 9058 | /* Estimate how many newlines we must move back. */ | 9058 | /* Estimate how many newlines we must move back. */ |
| 9059 | nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f)); | 9059 | nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f)); |
| 9060 | pos_limit = max (start_pos - nlines * nchars_per_row, BEGV); | 9060 | if (it->line_wrap == TRUNCATE) |
| 9061 | pos_limit = BEGV; | ||
| 9062 | else | ||
| 9063 | pos_limit = max (start_pos - nlines * nchars_per_row, BEGV); | ||
| 9061 | 9064 | ||
| 9062 | /* Set the iterator's position that many lines back. But don't go | 9065 | /* Set the iterator's position that many lines back. But don't go |
| 9063 | back more than NLINES full screen lines -- this wins a day with | 9066 | back more than NLINES full screen lines -- this wins a day with |
| @@ -9307,7 +9310,10 @@ move_it_by_lines (struct it *it, ptrdiff_t dvpos) | |||
| 9307 | /* Go back -DVPOS buffer lines, but no farther than -DVPOS full | 9310 | /* Go back -DVPOS buffer lines, but no farther than -DVPOS full |
| 9308 | screen lines, and reseat the iterator there. */ | 9311 | screen lines, and reseat the iterator there. */ |
| 9309 | start_charpos = IT_CHARPOS (*it); | 9312 | start_charpos = IT_CHARPOS (*it); |
| 9310 | pos_limit = max (start_charpos + dvpos * nchars_per_row, BEGV); | 9313 | if (it->line_wrap == TRUNCATE) |
| 9314 | pos_limit = BEGV; | ||
| 9315 | else | ||
| 9316 | pos_limit = max (start_charpos + dvpos * nchars_per_row, BEGV); | ||
| 9311 | for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > pos_limit; --i) | 9317 | for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > pos_limit; --i) |
| 9312 | back_to_previous_visible_line_start (it); | 9318 | back_to_previous_visible_line_start (it); |
| 9313 | reseat (it, it->current.pos, 1); | 9319 | reseat (it, it->current.pos, 1); |
| @@ -9450,11 +9456,11 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte) | |||
| 9450 | bset_undo_list (current_buffer, Qt); | 9456 | bset_undo_list (current_buffer, Qt); |
| 9451 | 9457 | ||
| 9452 | oldpoint = message_dolog_marker1; | 9458 | oldpoint = message_dolog_marker1; |
| 9453 | set_marker_restricted (oldpoint, make_number (PT), Qnil); | 9459 | set_marker_restricted_both (oldpoint, Qnil, PT, PT_BYTE); |
| 9454 | oldbegv = message_dolog_marker2; | 9460 | oldbegv = message_dolog_marker2; |
| 9455 | set_marker_restricted (oldbegv, make_number (BEGV), Qnil); | 9461 | set_marker_restricted_both (oldbegv, Qnil, BEGV, BEGV_BYTE); |
| 9456 | oldzv = message_dolog_marker3; | 9462 | oldzv = message_dolog_marker3; |
| 9457 | set_marker_restricted (oldzv, make_number (ZV), Qnil); | 9463 | set_marker_restricted_both (oldzv, Qnil, ZV, ZV_BYTE); |
| 9458 | GCPRO1 (old_deactivate_mark); | 9464 | GCPRO1 (old_deactivate_mark); |
| 9459 | 9465 | ||
| 9460 | if (PT == Z) | 9466 | if (PT == Z) |