diff options
| author | Dave Love | 2000-05-29 11:48:25 +0000 |
|---|---|---|
| committer | Dave Love | 2000-05-29 11:48:25 +0000 |
| commit | 306904961b677ccaa4a291119c7e253bdcc5da39 (patch) | |
| tree | 3b21148f62e72d26bac05e513498581c0cf74e3c /src | |
| parent | b4030d7b9d8aab418472f2adac3d7fc4d059a5a7 (diff) | |
| download | emacs-306904961b677ccaa4a291119c7e253bdcc5da39.tar.gz emacs-306904961b677ccaa4a291119c7e253bdcc5da39.zip | |
(menu_bar_items, tool_bar_items, Fexecute_extended_command): Deal with
`keymap' property.
(read_key_sequence): Track map from `keymap' property as well as
`local_map'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 117 |
1 files changed, 85 insertions, 32 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index d08fb8bebee..9a00e7c89ce 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1695,7 +1695,7 @@ static Lisp_Object | |||
| 1695 | safe_run_hooks_error (data) | 1695 | safe_run_hooks_error (data) |
| 1696 | Lisp_Object data; | 1696 | Lisp_Object data; |
| 1697 | { | 1697 | { |
| 1698 | Fset (Vinhibit_quit, Qnil); | 1698 | return Fset (Vinhibit_quit, Qnil); |
| 1699 | } | 1699 | } |
| 1700 | 1700 | ||
| 1701 | /* If we get an error while running the hook, cause the hook variable | 1701 | /* If we get an error while running the hook, cause the hook variable |
| @@ -2873,6 +2873,7 @@ tracking_off (old_value) | |||
| 2873 | get_input_pending (&input_pending, 1); | 2873 | get_input_pending (&input_pending, 1); |
| 2874 | } | 2874 | } |
| 2875 | } | 2875 | } |
| 2876 | return Qnil; | ||
| 2876 | } | 2877 | } |
| 2877 | 2878 | ||
| 2878 | DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, | 2879 | DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, |
| @@ -5951,11 +5952,18 @@ menu_bar_items (old) | |||
| 5951 | } | 5952 | } |
| 5952 | else | 5953 | else |
| 5953 | { | 5954 | { |
| 5954 | /* No, so use major and minor mode keymaps. */ | 5955 | /* No, so use major and minor mode keymaps and keymap property. */ |
| 5956 | int extra_maps = 2; | ||
| 5957 | Lisp_Object map = get_local_map (PT, current_buffer, keymap); | ||
| 5958 | if (!NILP (map)) | ||
| 5959 | extra_maps = 3; | ||
| 5955 | nmaps = current_minor_maps (NULL, &tmaps); | 5960 | nmaps = current_minor_maps (NULL, &tmaps); |
| 5956 | maps = (Lisp_Object *) alloca ((nmaps + 2) * sizeof (maps[0])); | 5961 | maps = (Lisp_Object *) alloca ((nmaps + extra_maps) |
| 5962 | * sizeof (maps[0])); | ||
| 5957 | bcopy (tmaps, maps, nmaps * sizeof (maps[0])); | 5963 | bcopy (tmaps, maps, nmaps * sizeof (maps[0])); |
| 5958 | maps[nmaps++] = get_local_map (PT, current_buffer); | 5964 | if (!NILP (map)) |
| 5965 | maps[nmaps++] = get_local_map (PT, current_buffer, keymap); | ||
| 5966 | maps[nmaps++] = get_local_map (PT, current_buffer, local_map); | ||
| 5959 | } | 5967 | } |
| 5960 | maps[nmaps++] = current_global_map; | 5968 | maps[nmaps++] = current_global_map; |
| 5961 | } | 5969 | } |
| @@ -6603,11 +6611,18 @@ tool_bar_items (reuse, nitems) | |||
| 6603 | } | 6611 | } |
| 6604 | else | 6612 | else |
| 6605 | { | 6613 | { |
| 6606 | /* No, so use major and minor mode keymaps. */ | 6614 | /* No, so use major and minor mode keymaps and keymap property. */ |
| 6615 | int extra_maps = 2; | ||
| 6616 | Lisp_Object map = get_local_map (PT, current_buffer, keymap); | ||
| 6617 | if (!NILP (map)) | ||
| 6618 | extra_maps = 3; | ||
| 6607 | nmaps = current_minor_maps (NULL, &tmaps); | 6619 | nmaps = current_minor_maps (NULL, &tmaps); |
| 6608 | maps = (Lisp_Object *) alloca ((nmaps + 2) * sizeof (maps[0])); | 6620 | maps = (Lisp_Object *) alloca ((nmaps + extra_maps) |
| 6621 | * sizeof (maps[0])); | ||
| 6609 | bcopy (tmaps, maps, nmaps * sizeof (maps[0])); | 6622 | bcopy (tmaps, maps, nmaps * sizeof (maps[0])); |
| 6610 | maps[nmaps++] = get_local_map (PT, current_buffer); | 6623 | if (!NILP (map)) |
| 6624 | maps[nmaps++] = get_local_map (PT, current_buffer, keymap); | ||
| 6625 | maps[nmaps++] = get_local_map (PT, current_buffer, local_map); | ||
| 6611 | } | 6626 | } |
| 6612 | 6627 | ||
| 6613 | /* Add global keymap at the end. */ | 6628 | /* Add global keymap at the end. */ |
| @@ -7421,6 +7436,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7421 | /* The local map to start out with at start of key sequence. */ | 7436 | /* The local map to start out with at start of key sequence. */ |
| 7422 | Lisp_Object orig_local_map; | 7437 | Lisp_Object orig_local_map; |
| 7423 | 7438 | ||
| 7439 | /* The map from the `keymap' property to start out with at start of | ||
| 7440 | key sequence. */ | ||
| 7441 | Lisp_Object orig_keymap; | ||
| 7442 | |||
| 7424 | /* 1 if we have already considered switching to the local-map property | 7443 | /* 1 if we have already considered switching to the local-map property |
| 7425 | of the place where a mouse click occurred. */ | 7444 | of the place where a mouse click occurred. */ |
| 7426 | int localized_local_map = 0; | 7445 | int localized_local_map = 0; |
| @@ -7542,7 +7561,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7542 | &junk); | 7561 | &junk); |
| 7543 | #endif /* GOBBLE_FIRST_EVENT */ | 7562 | #endif /* GOBBLE_FIRST_EVENT */ |
| 7544 | 7563 | ||
| 7545 | orig_local_map = get_local_map (PT, current_buffer); | 7564 | orig_local_map = get_local_map (PT, current_buffer, local_map); |
| 7565 | orig_keymap = get_local_map (PT, current_buffer, keymap); | ||
| 7546 | 7566 | ||
| 7547 | /* We jump here when the key sequence has been thoroughly changed, and | 7567 | /* We jump here when the key sequence has been thoroughly changed, and |
| 7548 | we need to rescan it starting from the beginning. When we jump here, | 7568 | we need to rescan it starting from the beginning. When we jump here, |
| @@ -7578,14 +7598,21 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7578 | } | 7598 | } |
| 7579 | else | 7599 | else |
| 7580 | { | 7600 | { |
| 7601 | int extra_maps = 2; | ||
| 7581 | nmaps = current_minor_maps (0, &maps); | 7602 | nmaps = current_minor_maps (0, &maps); |
| 7582 | if (nmaps + 2 > nmaps_allocated) | 7603 | if (!NILP (orig_keymap)) |
| 7604 | extra_maps = 3; | ||
| 7605 | if (nmaps + extra_maps > nmaps_allocated) | ||
| 7583 | { | 7606 | { |
| 7584 | submaps = (Lisp_Object *) alloca ((nmaps+2) * sizeof (submaps[0])); | 7607 | submaps = (Lisp_Object *) alloca ((nmaps+extra_maps) |
| 7585 | defs = (Lisp_Object *) alloca ((nmaps+2) * sizeof (defs[0])); | 7608 | * sizeof (submaps[0])); |
| 7586 | nmaps_allocated = nmaps + 2; | 7609 | defs = (Lisp_Object *) alloca ((nmaps+extra_maps) |
| 7610 | * sizeof (defs[0])); | ||
| 7611 | nmaps_allocated = nmaps + extra_maps; | ||
| 7587 | } | 7612 | } |
| 7588 | bcopy (maps, submaps, nmaps * sizeof (submaps[0])); | 7613 | bcopy (maps, submaps, nmaps * sizeof (submaps[0])); |
| 7614 | if (!NILP (orig_keymap)) | ||
| 7615 | submaps[nmaps++] = orig_keymap; | ||
| 7589 | submaps[nmaps++] = orig_local_map; | 7616 | submaps[nmaps++] = orig_local_map; |
| 7590 | } | 7617 | } |
| 7591 | submaps[nmaps++] = current_global_map; | 7618 | submaps[nmaps++] = current_global_map; |
| @@ -7704,7 +7731,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7704 | interrupted_kboard->kbd_queue); | 7731 | interrupted_kboard->kbd_queue); |
| 7705 | } | 7732 | } |
| 7706 | mock_input = 0; | 7733 | mock_input = 0; |
| 7707 | orig_local_map = get_local_map (PT, current_buffer); | 7734 | orig_local_map = get_local_map (PT, current_buffer, local_map); |
| 7735 | orig_keymap = get_local_map (PT, current_buffer, keymap); | ||
| 7708 | goto replay_sequence; | 7736 | goto replay_sequence; |
| 7709 | } | 7737 | } |
| 7710 | #endif | 7738 | #endif |
| @@ -7749,7 +7777,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7749 | Fset_buffer (XWINDOW (selected_window)->buffer); | 7777 | Fset_buffer (XWINDOW (selected_window)->buffer); |
| 7750 | } | 7778 | } |
| 7751 | 7779 | ||
| 7752 | orig_local_map = get_local_map (PT, current_buffer); | 7780 | orig_local_map = get_local_map (PT, current_buffer, local_map); |
| 7781 | orig_keymap = get_local_map (PT, current_buffer, keymap); | ||
| 7753 | goto replay_sequence; | 7782 | goto replay_sequence; |
| 7754 | } | 7783 | } |
| 7755 | 7784 | ||
| @@ -7763,7 +7792,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7763 | keybuf[t++] = key; | 7792 | keybuf[t++] = key; |
| 7764 | mock_input = t; | 7793 | mock_input = t; |
| 7765 | Vquit_flag = Qnil; | 7794 | Vquit_flag = Qnil; |
| 7766 | orig_local_map = get_local_map (PT, current_buffer); | 7795 | orig_local_map = get_local_map (PT, current_buffer, local_map); |
| 7796 | orig_keymap = get_local_map (PT, current_buffer, keymap); | ||
| 7767 | goto replay_sequence; | 7797 | goto replay_sequence; |
| 7768 | } | 7798 | } |
| 7769 | 7799 | ||
| @@ -7848,8 +7878,12 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7848 | 7878 | ||
| 7849 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 7879 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 7850 | Fkill_emacs (Qnil); | 7880 | Fkill_emacs (Qnil); |
| 7851 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 7881 | set_buffer_internal (XBUFFER (XWINDOW |
| 7852 | orig_local_map = get_local_map (PT, current_buffer); | 7882 | (window)->buffer) |
| 7883 | ); | ||
| 7884 | orig_local_map = get_local_map (PT, current_buffer, | ||
| 7885 | local_map); | ||
| 7886 | orig_keymap = get_local_map (PT, current_buffer, keymap); | ||
| 7853 | goto replay_sequence; | 7887 | goto replay_sequence; |
| 7854 | } | 7888 | } |
| 7855 | 7889 | ||
| @@ -7870,7 +7904,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7870 | if (INTEGERP (pos) | 7904 | if (INTEGERP (pos) |
| 7871 | && XINT (pos) >= BEG && XINT (pos) <= Z) | 7905 | && XINT (pos) >= BEG && XINT (pos) <= Z) |
| 7872 | { | 7906 | { |
| 7873 | map_here = get_local_map (XINT (pos), current_buffer); | 7907 | map_here = get_local_map (XINT (pos), |
| 7908 | current_buffer, local_map); | ||
| 7874 | if (!EQ (map_here, orig_local_map)) | 7909 | if (!EQ (map_here, orig_local_map)) |
| 7875 | { | 7910 | { |
| 7876 | orig_local_map = map_here; | 7911 | orig_local_map = map_here; |
| @@ -7879,6 +7914,16 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7879 | 7914 | ||
| 7880 | goto replay_sequence; | 7915 | goto replay_sequence; |
| 7881 | } | 7916 | } |
| 7917 | map_here = get_local_map (XINT (pos), | ||
| 7918 | current_buffer, keymap); | ||
| 7919 | if (!EQ (map_here, orig_keymap)) | ||
| 7920 | { | ||
| 7921 | orig_keymap = map_here; | ||
| 7922 | keybuf[t] = key; | ||
| 7923 | mock_input = t + 1; | ||
| 7924 | |||
| 7925 | goto replay_sequence; | ||
| 7926 | } | ||
| 7882 | } | 7927 | } |
| 7883 | } | 7928 | } |
| 7884 | } | 7929 | } |
| @@ -7902,21 +7947,22 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7902 | reconsider the key sequence with that keymap. */ | 7947 | reconsider the key sequence with that keymap. */ |
| 7903 | if (CONSP (POSN_STRING (EVENT_START (key)))) | 7948 | if (CONSP (POSN_STRING (EVENT_START (key)))) |
| 7904 | { | 7949 | { |
| 7905 | Lisp_Object string, pos, map; | 7950 | Lisp_Object string, pos, map, map2; |
| 7906 | 7951 | ||
| 7907 | string = POSN_STRING (EVENT_START (key)); | 7952 | string = POSN_STRING (EVENT_START (key)); |
| 7908 | pos = XCDR (string); | 7953 | pos = XCDR (string); |
| 7909 | string = XCAR (string); | 7954 | string = XCAR (string); |
| 7910 | 7955 | if (pos >= 0 && pos < XSTRING (string)->size) | |
| 7911 | if (XINT (pos) >= 0 | 7956 | { |
| 7912 | && XINT (pos) < XSTRING (string)->size | 7957 | map = Fget_text_property (pos, Qlocal_map, string); |
| 7913 | && (map = Fget_text_property (pos, Qlocal_map, | 7958 | if (!NILP (map)) |
| 7914 | string), | 7959 | orig_local_map = map; |
| 7915 | !NILP (map))) | 7960 | map2 = Fget_text_property (pos, Qkeymap, string); |
| 7916 | { | 7961 | if (!NILP (map2)) |
| 7917 | orig_local_map = map; | 7962 | orig_keymap = map2; |
| 7918 | goto replay_sequence; | 7963 | if (!NILP (map) || !NILP (map2)) |
| 7919 | } | 7964 | goto replay_sequence; |
| 7965 | } | ||
| 7920 | } | 7966 | } |
| 7921 | 7967 | ||
| 7922 | goto replay_key; | 7968 | goto replay_key; |
| @@ -8896,11 +8942,18 @@ current_active_maps (maps_p) | |||
| 8896 | } | 8942 | } |
| 8897 | else | 8943 | else |
| 8898 | { | 8944 | { |
| 8899 | /* No, so use major and minor mode keymaps. */ | 8945 | /* No, so use major and minor mode keymaps and keymap property. */ |
| 8946 | int extra_maps = 2; | ||
| 8947 | Lisp_Object map = get_local_map (PT, current_buffer, keymap); | ||
| 8948 | if (!NILP (map)) | ||
| 8949 | extra_maps = 3; | ||
| 8900 | nmaps = current_minor_maps (NULL, &tmaps); | 8950 | nmaps = current_minor_maps (NULL, &tmaps); |
| 8901 | maps = (Lisp_Object *) xmalloc ((nmaps + 2) * sizeof (maps[0])); | 8951 | maps = (Lisp_Object *) alloca ((nmaps + extra_maps) |
| 8952 | * sizeof (maps[0])); | ||
| 8902 | bcopy (tmaps, maps, nmaps * sizeof (maps[0])); | 8953 | bcopy (tmaps, maps, nmaps * sizeof (maps[0])); |
| 8903 | maps[nmaps++] = get_local_map (PT, current_buffer); | 8954 | if (!NILP (map)) |
| 8955 | maps[nmaps++] = get_local_map (PT, current_buffer, keymap); | ||
| 8956 | maps[nmaps++] = get_local_map (PT, current_buffer, local_map); | ||
| 8904 | } | 8957 | } |
| 8905 | maps[nmaps++] = current_global_map; | 8958 | maps[nmaps++] = current_global_map; |
| 8906 | 8959 | ||