aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 29898fe7a8e..413de76f7d5 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1179,7 +1179,7 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1179 if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt)) 1179 if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt))
1180 Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands); 1180 Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands);
1181 1181
1182 meta_bit = (VECTORP (key) || STRINGP (key) && STRING_MULTIBYTE (key) 1182 meta_bit = (VECTORP (key) || (STRINGP (key) && STRING_MULTIBYTE (key))
1183 ? meta_modifier : 0x80); 1183 ? meta_modifier : 0x80);
1184 1184
1185 if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0))) 1185 if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0)))
@@ -2079,12 +2079,23 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_
2079 2079
2080/* Help functions for describing and documenting keymaps. */ 2080/* Help functions for describing and documenting keymaps. */
2081 2081
2082struct accessible_keymaps_data {
2083 Lisp_Object maps, tail, thisseq;
2084 /* Does the current sequence end in the meta-prefix-char? */
2085 int is_metized;
2086};
2082 2087
2083static void 2088static void
2084accessible_keymaps_1 (key, cmd, maps, tail, thisseq, is_metized) 2089accessible_keymaps_1 (key, cmd, args, data)
2085 Lisp_Object maps, tail, thisseq, key, cmd; 2090 Lisp_Object key, cmd, args;
2086 int is_metized; /* If 1, `key' is assumed to be INTEGERP. */ 2091 /* Use void* to be compatible with map_keymap_function_t. */
2092 void *data;
2087{ 2093{
2094 struct accessible_keymaps_data *d = data; /* Cast! */
2095 Lisp_Object maps = d->maps;
2096 Lisp_Object tail = d->tail;
2097 Lisp_Object thisseq = d->thisseq;
2098 int is_metized = d->is_metized && INTEGERP (key);
2088 Lisp_Object tem; 2099 Lisp_Object tem;
2089 2100
2090 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0); 2101 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0);
@@ -2138,17 +2149,6 @@ accessible_keymaps_1 (key, cmd, maps, tail, thisseq, is_metized)
2138 } 2149 }
2139} 2150}
2140 2151
2141static void
2142accessible_keymaps_char_table (args, index, cmd)
2143 Lisp_Object args, index, cmd;
2144{
2145 accessible_keymaps_1 (index, cmd,
2146 XCAR (XCAR (args)),
2147 XCAR (XCDR (args)),
2148 XCDR (XCDR (args)),
2149 XINT (XCDR (XCAR (args))));
2150}
2151
2152/* This function cannot GC. */ 2152/* This function cannot GC. */
2153 2153
2154DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps, 2154DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps,
@@ -2163,14 +2163,11 @@ then the value includes only maps for prefixes that start with PREFIX. */)
2163 Lisp_Object keymap, prefix; 2163 Lisp_Object keymap, prefix;
2164{ 2164{
2165 Lisp_Object maps, tail; 2165 Lisp_Object maps, tail;
2166 int prefixlen = 0; 2166 int prefixlen = XINT (Flength (prefix));
2167 2167
2168 /* no need for gcpro because we don't autoload any keymaps. */ 2168 /* no need for gcpro because we don't autoload any keymaps. */
2169 2169
2170 if (!NILP (prefix)) 2170 if (!NILP (prefix))
2171 prefixlen = XINT (Flength (prefix));
2172
2173 if (!NILP (prefix))
2174 { 2171 {
2175 /* If a prefix was specified, start with the keymap (if any) for 2172 /* If a prefix was specified, start with the keymap (if any) for
2176 that prefix, so we don't waste time considering other prefixes. */ 2173 that prefix, so we don't waste time considering other prefixes. */
@@ -2180,7 +2177,9 @@ then the value includes only maps for prefixes that start with PREFIX. */)
2180 if the prefix is not defined in this particular map. 2177 if the prefix is not defined in this particular map.
2181 It might even give us a list that isn't a keymap. */ 2178 It might even give us a list that isn't a keymap. */
2182 tem = get_keymap (tem, 0, 0); 2179 tem = get_keymap (tem, 0, 0);
2183 if (CONSP (tem)) 2180 /* If the keymap is autoloaded `tem' is not a cons-cell, but we still
2181 want to return it. */
2182 if (!NILP (tem))
2184 { 2183 {
2185 /* Convert PREFIX to a vector now, so that later on 2184 /* Convert PREFIX to a vector now, so that later on
2186 we don't have to deal with the possibility of a string. */ 2185 we don't have to deal with the possibility of a string. */
@@ -2620,8 +2619,8 @@ ascii_sequence_p (seq)
2620/* where-is - finding a command in a set of keymaps. */ 2619/* where-is - finding a command in a set of keymaps. */
2621 2620
2622static Lisp_Object where_is_internal (); 2621static Lisp_Object where_is_internal ();
2623static Lisp_Object where_is_internal_1 (); 2622static void where_is_internal_1 P_ ((Lisp_Object key, Lisp_Object binding,
2624static void where_is_internal_2 (); 2623 Lisp_Object args, void *data));
2625 2624
2626/* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map. 2625/* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map.
2627 Returns the first non-nil binding found in any of those maps. */ 2626 Returns the first non-nil binding found in any of those maps. */
@@ -2650,6 +2649,12 @@ shadow_lookup (shadow, key, flag)
2650 2649
2651static Lisp_Object Vmouse_events; 2650static Lisp_Object Vmouse_events;
2652 2651
2652struct where_is_internal_data {
2653 Lisp_Object definition, noindirect, this, last;
2654 int last_is_meta;
2655 Lisp_Object sequences;
2656};
2657
2653/* This function can GC if Flookup_key autoloads any keymaps. */ 2658/* This function can GC if Flookup_key autoloads any keymaps. */
2654 2659
2655static Lisp_Object 2660static Lisp_Object
@@ -2687,6 +2692,7 @@ where_is_internal (definition, keymaps, firstonly, noindirect, no_remap)
2687 { 2692 {
2688 /* Key sequence to reach map, and the map that it reaches */ 2693 /* Key sequence to reach map, and the map that it reaches */
2689 register Lisp_Object this, map, tem; 2694 register Lisp_Object this, map, tem;
2695 struct where_is_internal_data data;
2690 2696
2691 /* In order to fold [META-PREFIX-CHAR CHAR] sequences into 2697 /* In order to fold [META-PREFIX-CHAR CHAR] sequences into
2692 [M-CHAR] sequences, check if last character of the sequence 2698 [M-CHAR] sequences, check if last character of the sequence
@@ -3059,7 +3065,7 @@ where_is_internal_1 (binding, key, definition, noindirect, this, last,
3059 || EQ (binding, definition) 3065 || EQ (binding, definition)
3060 || (CONSP (definition) && !NILP (Fequal (binding, definition))))) 3066 || (CONSP (definition) && !NILP (Fequal (binding, definition)))))
3061 /* Doesn't match. */ 3067 /* Doesn't match. */
3062 return Qnil; 3068 return;
3063 3069
3064 /* We have found a match. Construct the key sequence where we found it. */ 3070 /* We have found a match. Construct the key sequence where we found it. */
3065 if (INTEGERP (key) && last_is_meta) 3071 if (INTEGERP (key) && last_is_meta)
@@ -3074,10 +3080,9 @@ where_is_internal_1 (binding, key, definition, noindirect, this, last,
3074 { 3080 {
3075 Lisp_Object sequences = Fgethash (binding, where_is_cache, Qnil); 3081 Lisp_Object sequences = Fgethash (binding, where_is_cache, Qnil);
3076 Fputhash (binding, Fcons (sequence, sequences), where_is_cache); 3082 Fputhash (binding, Fcons (sequence, sequences), where_is_cache);
3077 return Qnil;
3078 } 3083 }
3079 else 3084 else
3080 return sequence; 3085 d->sequences = Fcons (sequence, d->sequences);
3081} 3086}
3082 3087
3083/* describe-bindings - summarizing all the bindings in a set of keymaps. */ 3088/* describe-bindings - summarizing all the bindings in a set of keymaps. */