diff options
| author | Stefan Monnier | 2011-03-21 12:42:16 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2011-03-21 12:42:16 -0400 |
| commit | cafdcef32d55cbb44389d7e322e7f973cbb72dfd (patch) | |
| tree | 7ee0c41ea8a589650ce6f4311fb10e61a63807b9 /src/keymap.c | |
| parent | a08a25d7aaf251aa18f2ef747be53734bc55cae9 (diff) | |
| parent | 4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e (diff) | |
| download | emacs-cafdcef32d55cbb44389d7e322e7f973cbb72dfd.tar.gz emacs-cafdcef32d55cbb44389d7e322e7f973cbb72dfd.zip | |
Merge from trunk
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/src/keymap.c b/src/keymap.c index 4459ef07d68..06968a0d944 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -34,9 +34,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 34 | #include "keymap.h" | 34 | #include "keymap.h" |
| 35 | #include "window.h" | 35 | #include "window.h" |
| 36 | 36 | ||
| 37 | /* The number of elements in keymap vectors. */ | ||
| 38 | #define DENSE_TABLE_SIZE (0200) | ||
| 39 | |||
| 40 | /* Actually allocate storage for these variables */ | 37 | /* Actually allocate storage for these variables */ |
| 41 | 38 | ||
| 42 | Lisp_Object current_global_map; /* Current global keymap */ | 39 | Lisp_Object current_global_map; /* Current global keymap */ |
| @@ -191,8 +188,9 @@ when reading a key-sequence to be looked-up in this keymap. */) | |||
| 191 | If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR | 188 | If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR |
| 192 | is zero as well), return Qt. | 189 | is zero as well), return Qt. |
| 193 | 190 | ||
| 194 | ERROR controls how we respond if OBJECT isn't a keymap. | 191 | ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap. |
| 195 | If ERROR is non-zero, signal an error; otherwise, just return Qnil. | 192 | If ERROR_IF_NOT_KEYMAP is non-zero, signal an error; otherwise, |
| 193 | just return Qnil. | ||
| 196 | 194 | ||
| 197 | Note that most of the time, we don't want to pursue autoloads. | 195 | Note that most of the time, we don't want to pursue autoloads. |
| 198 | Functions like Faccessible_keymaps which scan entire keymap trees | 196 | Functions like Faccessible_keymaps which scan entire keymap trees |
| @@ -204,7 +202,7 @@ when reading a key-sequence to be looked-up in this keymap. */) | |||
| 204 | do_autoload which can GC. */ | 202 | do_autoload which can GC. */ |
| 205 | 203 | ||
| 206 | Lisp_Object | 204 | Lisp_Object |
| 207 | get_keymap (Lisp_Object object, int error, int autoload) | 205 | get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) |
| 208 | { | 206 | { |
| 209 | Lisp_Object tem; | 207 | Lisp_Object tem; |
| 210 | 208 | ||
| @@ -222,7 +220,7 @@ get_keymap (Lisp_Object object, int error, int autoload) | |||
| 222 | 220 | ||
| 223 | /* Should we do an autoload? Autoload forms for keymaps have | 221 | /* Should we do an autoload? Autoload forms for keymaps have |
| 224 | Qkeymap as their fifth element. */ | 222 | Qkeymap as their fifth element. */ |
| 225 | if ((autoload || !error) && EQ (XCAR (tem), Qautoload) | 223 | if ((autoload || !error_if_not_keymap) && EQ (XCAR (tem), Qautoload) |
| 226 | && SYMBOLP (object)) | 224 | && SYMBOLP (object)) |
| 227 | { | 225 | { |
| 228 | Lisp_Object tail; | 226 | Lisp_Object tail; |
| @@ -247,7 +245,7 @@ get_keymap (Lisp_Object object, int error, int autoload) | |||
| 247 | } | 245 | } |
| 248 | 246 | ||
| 249 | end: | 247 | end: |
| 250 | if (error) | 248 | if (error_if_not_keymap) |
| 251 | wrong_type_argument (Qkeymapp, object); | 249 | wrong_type_argument (Qkeymapp, object); |
| 252 | return Qnil; | 250 | return Qnil; |
| 253 | } | 251 | } |
| @@ -255,7 +253,7 @@ get_keymap (Lisp_Object object, int error, int autoload) | |||
| 255 | /* Return the parent map of KEYMAP, or nil if it has none. | 253 | /* Return the parent map of KEYMAP, or nil if it has none. |
| 256 | We assume that KEYMAP is a valid keymap. */ | 254 | We assume that KEYMAP is a valid keymap. */ |
| 257 | 255 | ||
| 258 | Lisp_Object | 256 | static Lisp_Object |
| 259 | keymap_parent (Lisp_Object keymap, int autoload) | 257 | keymap_parent (Lisp_Object keymap, int autoload) |
| 260 | { | 258 | { |
| 261 | Lisp_Object list; | 259 | Lisp_Object list; |
| @@ -283,7 +281,7 @@ If KEYMAP has no parent, return nil. */) | |||
| 283 | } | 281 | } |
| 284 | 282 | ||
| 285 | /* Check whether MAP is one of MAPS parents. */ | 283 | /* Check whether MAP is one of MAPS parents. */ |
| 286 | int | 284 | static int |
| 287 | keymap_memberp (Lisp_Object map, Lisp_Object maps) | 285 | keymap_memberp (Lisp_Object map, Lisp_Object maps) |
| 288 | { | 286 | { |
| 289 | if (NILP (map)) return 0; | 287 | if (NILP (map)) return 0; |
| @@ -468,19 +466,19 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au | |||
| 468 | /* See if there is a meta-map. If there's none, there is | 466 | /* See if there is a meta-map. If there's none, there is |
| 469 | no binding for IDX, unless a default binding exists in MAP. */ | 467 | no binding for IDX, unless a default binding exists in MAP. */ |
| 470 | struct gcpro gcpro1; | 468 | struct gcpro gcpro1; |
| 471 | Lisp_Object meta_map; | 469 | Lisp_Object event_meta_map; |
| 472 | GCPRO1 (map); | 470 | GCPRO1 (map); |
| 473 | /* A strange value in which Meta is set would cause | 471 | /* A strange value in which Meta is set would cause |
| 474 | infinite recursion. Protect against that. */ | 472 | infinite recursion. Protect against that. */ |
| 475 | if (XINT (meta_prefix_char) & CHAR_META) | 473 | if (XINT (meta_prefix_char) & CHAR_META) |
| 476 | meta_prefix_char = make_number (27); | 474 | meta_prefix_char = make_number (27); |
| 477 | meta_map = get_keymap (access_keymap (map, meta_prefix_char, | 475 | event_meta_map = get_keymap (access_keymap (map, meta_prefix_char, |
| 478 | t_ok, noinherit, autoload), | 476 | t_ok, noinherit, autoload), |
| 479 | 0, autoload); | 477 | 0, autoload); |
| 480 | UNGCPRO; | 478 | UNGCPRO; |
| 481 | if (CONSP (meta_map)) | 479 | if (CONSP (event_meta_map)) |
| 482 | { | 480 | { |
| 483 | map = meta_map; | 481 | map = event_meta_map; |
| 484 | idx = make_number (XUINT (idx) & ~meta_modifier); | 482 | idx = make_number (XUINT (idx) & ~meta_modifier); |
| 485 | } | 483 | } |
| 486 | else if (t_ok) | 484 | else if (t_ok) |
| @@ -598,7 +596,7 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val) | |||
| 598 | 596 | ||
| 599 | /* Call FUN for every binding in MAP and stop at (and return) the parent. | 597 | /* Call FUN for every binding in MAP and stop at (and return) the parent. |
| 600 | FUN is called with 4 arguments: FUN (KEY, BINDING, ARGS, DATA). */ | 598 | FUN is called with 4 arguments: FUN (KEY, BINDING, ARGS, DATA). */ |
| 601 | Lisp_Object | 599 | static Lisp_Object |
| 602 | map_keymap_internal (Lisp_Object map, | 600 | map_keymap_internal (Lisp_Object map, |
| 603 | map_keymap_function_t fun, | 601 | map_keymap_function_t fun, |
| 604 | Lisp_Object args, | 602 | Lisp_Object args, |
| @@ -960,7 +958,7 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def) | |||
| 960 | 958 | ||
| 961 | EXFUN (Fcopy_keymap, 1); | 959 | EXFUN (Fcopy_keymap, 1); |
| 962 | 960 | ||
| 963 | Lisp_Object | 961 | static Lisp_Object |
| 964 | copy_keymap_item (Lisp_Object elt) | 962 | copy_keymap_item (Lisp_Object elt) |
| 965 | { | 963 | { |
| 966 | Lisp_Object res, tem; | 964 | Lisp_Object res, tem; |
| @@ -1142,10 +1140,10 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1142 | int i = ASIZE (def); | 1140 | int i = ASIZE (def); |
| 1143 | while (--i >= 0) | 1141 | while (--i >= 0) |
| 1144 | { | 1142 | { |
| 1145 | Lisp_Object c = AREF (def, i); | 1143 | Lisp_Object defi = AREF (def, i); |
| 1146 | if (CONSP (c) && lucid_event_type_list_p (c)) | 1144 | if (CONSP (defi) && lucid_event_type_list_p (defi)) |
| 1147 | c = Fevent_convert_list (c); | 1145 | defi = Fevent_convert_list (defi); |
| 1148 | ASET (tmp, i, c); | 1146 | ASET (tmp, i, defi); |
| 1149 | } | 1147 | } |
| 1150 | def = tmp; | 1148 | def = tmp; |
| 1151 | } | 1149 | } |
| @@ -1337,7 +1335,7 @@ define_as_prefix (Lisp_Object keymap, Lisp_Object c) | |||
| 1337 | 1335 | ||
| 1338 | /* Append a key to the end of a key sequence. We always make a vector. */ | 1336 | /* Append a key to the end of a key sequence. We always make a vector. */ |
| 1339 | 1337 | ||
| 1340 | Lisp_Object | 1338 | static Lisp_Object |
| 1341 | append_key (Lisp_Object key_sequence, Lisp_Object key) | 1339 | append_key (Lisp_Object key_sequence, Lisp_Object key) |
| 1342 | { | 1340 | { |
| 1343 | Lisp_Object args[2]; | 1341 | Lisp_Object args[2]; |
| @@ -2439,7 +2437,7 @@ around function keys and event symbols. */) | |||
| 2439 | return Qnil; | 2437 | return Qnil; |
| 2440 | } | 2438 | } |
| 2441 | 2439 | ||
| 2442 | char * | 2440 | static char * |
| 2443 | push_text_char_description (register unsigned int c, register char *p) | 2441 | push_text_char_description (register unsigned int c, register char *p) |
| 2444 | { | 2442 | { |
| 2445 | if (c >= 0200) | 2443 | if (c >= 0200) |
| @@ -2774,8 +2772,8 @@ remapped command in the returned list. */) | |||
| 2774 | considered remapped sequences yet, copy them over and | 2772 | considered remapped sequences yet, copy them over and |
| 2775 | process them. */ | 2773 | process them. */ |
| 2776 | || (!remapped && (sequences = remapped_sequences, | 2774 | || (!remapped && (sequences = remapped_sequences, |
| 2777 | remapped = 1), | 2775 | remapped = 1, |
| 2778 | CONSP (sequences))) | 2776 | CONSP (sequences)))) |
| 2779 | { | 2777 | { |
| 2780 | Lisp_Object sequence, function; | 2778 | Lisp_Object sequence, function; |
| 2781 | 2779 | ||
| @@ -2815,9 +2813,9 @@ remapped command in the returned list. */) | |||
| 2815 | seems to be only one menu item to report. */ | 2813 | seems to be only one menu item to report. */ |
| 2816 | if (! NILP (sequence)) | 2814 | if (! NILP (sequence)) |
| 2817 | { | 2815 | { |
| 2818 | Lisp_Object tem; | 2816 | Lisp_Object tem1; |
| 2819 | tem = Faref (sequence, make_number (ASIZE (sequence) - 1)); | 2817 | tem1 = Faref (sequence, make_number (ASIZE (sequence) - 1)); |
| 2820 | if (STRINGP (tem)) | 2818 | if (STRINGP (tem1)) |
| 2821 | Faset (sequence, make_number (ASIZE (sequence) - 1), | 2819 | Faset (sequence, make_number (ASIZE (sequence) - 1), |
| 2822 | build_string ("(any string)")); | 2820 | build_string ("(any string)")); |
| 2823 | } | 2821 | } |
| @@ -3122,13 +3120,13 @@ key binding\n\ | |||
| 3122 | /* Delete from MAPS each element that is for the menu bar. */ | 3120 | /* Delete from MAPS each element that is for the menu bar. */ |
| 3123 | for (list = maps; CONSP (list); list = XCDR (list)) | 3121 | for (list = maps; CONSP (list); list = XCDR (list)) |
| 3124 | { | 3122 | { |
| 3125 | Lisp_Object elt, prefix, tem; | 3123 | Lisp_Object elt, elt_prefix, tem; |
| 3126 | 3124 | ||
| 3127 | elt = XCAR (list); | 3125 | elt = XCAR (list); |
| 3128 | prefix = Fcar (elt); | 3126 | elt_prefix = Fcar (elt); |
| 3129 | if (XVECTOR (prefix)->size >= 1) | 3127 | if (XVECTOR (elt_prefix)->size >= 1) |
| 3130 | { | 3128 | { |
| 3131 | tem = Faref (prefix, make_number (0)); | 3129 | tem = Faref (elt_prefix, make_number (0)); |
| 3132 | if (EQ (tem, Qmenu_bar)) | 3130 | if (EQ (tem, Qmenu_bar)) |
| 3133 | maps = Fdelq (elt, maps); | 3131 | maps = Fdelq (elt, maps); |
| 3134 | } | 3132 | } |
| @@ -3153,10 +3151,10 @@ key binding\n\ | |||
| 3153 | 3151 | ||
| 3154 | for (; CONSP (maps); maps = XCDR (maps)) | 3152 | for (; CONSP (maps); maps = XCDR (maps)) |
| 3155 | { | 3153 | { |
| 3156 | register Lisp_Object elt, prefix, tail; | 3154 | register Lisp_Object elt, elt_prefix, tail; |
| 3157 | 3155 | ||
| 3158 | elt = XCAR (maps); | 3156 | elt = XCAR (maps); |
| 3159 | prefix = Fcar (elt); | 3157 | elt_prefix = Fcar (elt); |
| 3160 | 3158 | ||
| 3161 | sub_shadows = Qnil; | 3159 | sub_shadows = Qnil; |
| 3162 | 3160 | ||
| @@ -3168,8 +3166,8 @@ key binding\n\ | |||
| 3168 | 3166 | ||
| 3169 | /* If the sequence by which we reach this keymap is zero-length, | 3167 | /* If the sequence by which we reach this keymap is zero-length, |
| 3170 | then the shadow map for this keymap is just SHADOW. */ | 3168 | then the shadow map for this keymap is just SHADOW. */ |
| 3171 | if ((STRINGP (prefix) && SCHARS (prefix) == 0) | 3169 | if ((STRINGP (elt_prefix) && SCHARS (elt_prefix) == 0) |
| 3172 | || (VECTORP (prefix) && XVECTOR (prefix)->size == 0)) | 3170 | || (VECTORP (elt_prefix) && XVECTOR (elt_prefix)->size == 0)) |
| 3173 | ; | 3171 | ; |
| 3174 | /* If the sequence by which we reach this keymap actually has | 3172 | /* If the sequence by which we reach this keymap actually has |
| 3175 | some elements, then the sequence's definition in SHADOW is | 3173 | some elements, then the sequence's definition in SHADOW is |
| @@ -3195,12 +3193,12 @@ key binding\n\ | |||
| 3195 | for (tail = orig_maps; !EQ (tail, maps); tail = XCDR (tail)) | 3193 | for (tail = orig_maps; !EQ (tail, maps); tail = XCDR (tail)) |
| 3196 | { | 3194 | { |
| 3197 | Lisp_Object tem; | 3195 | Lisp_Object tem; |
| 3198 | tem = Fequal (Fcar (XCAR (tail)), prefix); | 3196 | tem = Fequal (Fcar (XCAR (tail)), elt_prefix); |
| 3199 | if (!NILP (tem)) | 3197 | if (!NILP (tem)) |
| 3200 | sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows); | 3198 | sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows); |
| 3201 | } | 3199 | } |
| 3202 | 3200 | ||
| 3203 | describe_map (Fcdr (elt), prefix, | 3201 | describe_map (Fcdr (elt), elt_prefix, |
| 3204 | transl ? describe_translation : describe_command, | 3202 | transl ? describe_translation : describe_command, |
| 3205 | partial, sub_shadows, &seen, nomenu, mention_shadow); | 3203 | partial, sub_shadows, &seen, nomenu, mention_shadow); |
| 3206 | 3204 | ||