diff options
| author | Joakim Verona | 2011-06-16 00:22:07 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-06-16 00:22:07 +0200 |
| commit | a7513ade3bc0fe79430d5541d88c9dcda0932bec (patch) | |
| tree | 4383951ba698a11e9f8933a9d8c72e00aa872a10 /src/keymap.c | |
| parent | 4bd51ad5c3445b644dfb017d5b57b10a90aa325f (diff) | |
| parent | 4bba86e6210a74326e843a8fdc8409127105e1fe (diff) | |
| download | emacs-a7513ade3bc0fe79430d5541d88c9dcda0932bec.tar.gz emacs-a7513ade3bc0fe79430d5541d88c9dcda0932bec.zip | |
merge from upstream
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 177 |
1 files changed, 86 insertions, 91 deletions
diff --git a/src/keymap.c b/src/keymap.c index 1e6b76a4642..6ef2a716b6d 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 */ |
| @@ -59,8 +56,9 @@ Lisp_Object control_x_map; /* The keymap used for globally bound | |||
| 59 | 56 | ||
| 60 | /* keymap used for minibuffers when doing completion */ | 57 | /* keymap used for minibuffers when doing completion */ |
| 61 | /* keymap used for minibuffers when doing completion and require a match */ | 58 | /* keymap used for minibuffers when doing completion and require a match */ |
| 62 | Lisp_Object Qkeymapp, Qkeymap, Qnon_ascii, Qmenu_item, Qremap; | 59 | static Lisp_Object Qkeymapp, Qnon_ascii; |
| 63 | Lisp_Object QCadvertised_binding; | 60 | Lisp_Object Qkeymap, Qmenu_item, Qremap; |
| 61 | static Lisp_Object QCadvertised_binding; | ||
| 64 | 62 | ||
| 65 | /* Alist of elements like (DEL . "\d"). */ | 63 | /* Alist of elements like (DEL . "\d"). */ |
| 66 | static Lisp_Object exclude_keys; | 64 | static Lisp_Object exclude_keys; |
| @@ -73,6 +71,7 @@ static Lisp_Object where_is_cache; | |||
| 73 | /* Which keymaps are reverse-stored in the cache. */ | 71 | /* Which keymaps are reverse-stored in the cache. */ |
| 74 | static Lisp_Object where_is_cache_keymaps; | 72 | static Lisp_Object where_is_cache_keymaps; |
| 75 | 73 | ||
| 74 | static Lisp_Object Flookup_key (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 76 | static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); | 75 | static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); |
| 77 | static void fix_submap_inheritance (Lisp_Object, Lisp_Object, Lisp_Object); | 76 | static void fix_submap_inheritance (Lisp_Object, Lisp_Object, Lisp_Object); |
| 78 | 77 | ||
| @@ -84,8 +83,7 @@ static void describe_map (Lisp_Object, Lisp_Object, | |||
| 84 | int, Lisp_Object, Lisp_Object*, int, int); | 83 | int, Lisp_Object, Lisp_Object*, int, int); |
| 85 | static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, | 84 | static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, |
| 86 | void (*) (Lisp_Object, Lisp_Object), int, | 85 | void (*) (Lisp_Object, Lisp_Object), int, |
| 87 | Lisp_Object, Lisp_Object, int *, | 86 | Lisp_Object, Lisp_Object, int, int); |
| 88 | int, int, int); | ||
| 89 | static void silly_event_symbol_error (Lisp_Object); | 87 | static void silly_event_symbol_error (Lisp_Object); |
| 90 | static Lisp_Object get_keyelt (Lisp_Object, int); | 88 | static Lisp_Object get_keyelt (Lisp_Object, int); |
| 91 | 89 | ||
| @@ -191,8 +189,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 | 189 | If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR |
| 192 | is zero as well), return Qt. | 190 | is zero as well), return Qt. |
| 193 | 191 | ||
| 194 | ERROR controls how we respond if OBJECT isn't a keymap. | 192 | 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. | 193 | If ERROR_IF_NOT_KEYMAP is non-zero, signal an error; otherwise, |
| 194 | just return Qnil. | ||
| 196 | 195 | ||
| 197 | Note that most of the time, we don't want to pursue autoloads. | 196 | Note that most of the time, we don't want to pursue autoloads. |
| 198 | Functions like Faccessible_keymaps which scan entire keymap trees | 197 | Functions like Faccessible_keymaps which scan entire keymap trees |
| @@ -204,7 +203,7 @@ when reading a key-sequence to be looked-up in this keymap. */) | |||
| 204 | do_autoload which can GC. */ | 203 | do_autoload which can GC. */ |
| 205 | 204 | ||
| 206 | Lisp_Object | 205 | Lisp_Object |
| 207 | get_keymap (Lisp_Object object, int error, int autoload) | 206 | get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) |
| 208 | { | 207 | { |
| 209 | Lisp_Object tem; | 208 | Lisp_Object tem; |
| 210 | 209 | ||
| @@ -222,7 +221,7 @@ get_keymap (Lisp_Object object, int error, int autoload) | |||
| 222 | 221 | ||
| 223 | /* Should we do an autoload? Autoload forms for keymaps have | 222 | /* Should we do an autoload? Autoload forms for keymaps have |
| 224 | Qkeymap as their fifth element. */ | 223 | Qkeymap as their fifth element. */ |
| 225 | if ((autoload || !error) && EQ (XCAR (tem), Qautoload) | 224 | if ((autoload || !error_if_not_keymap) && EQ (XCAR (tem), Qautoload) |
| 226 | && SYMBOLP (object)) | 225 | && SYMBOLP (object)) |
| 227 | { | 226 | { |
| 228 | Lisp_Object tail; | 227 | Lisp_Object tail; |
| @@ -247,7 +246,7 @@ get_keymap (Lisp_Object object, int error, int autoload) | |||
| 247 | } | 246 | } |
| 248 | 247 | ||
| 249 | end: | 248 | end: |
| 250 | if (error) | 249 | if (error_if_not_keymap) |
| 251 | wrong_type_argument (Qkeymapp, object); | 250 | wrong_type_argument (Qkeymapp, object); |
| 252 | return Qnil; | 251 | return Qnil; |
| 253 | } | 252 | } |
| @@ -255,7 +254,7 @@ get_keymap (Lisp_Object object, int error, int autoload) | |||
| 255 | /* Return the parent map of KEYMAP, or nil if it has none. | 254 | /* Return the parent map of KEYMAP, or nil if it has none. |
| 256 | We assume that KEYMAP is a valid keymap. */ | 255 | We assume that KEYMAP is a valid keymap. */ |
| 257 | 256 | ||
| 258 | Lisp_Object | 257 | static Lisp_Object |
| 259 | keymap_parent (Lisp_Object keymap, int autoload) | 258 | keymap_parent (Lisp_Object keymap, int autoload) |
| 260 | { | 259 | { |
| 261 | Lisp_Object list; | 260 | Lisp_Object list; |
| @@ -283,7 +282,7 @@ If KEYMAP has no parent, return nil. */) | |||
| 283 | } | 282 | } |
| 284 | 283 | ||
| 285 | /* Check whether MAP is one of MAPS parents. */ | 284 | /* Check whether MAP is one of MAPS parents. */ |
| 286 | int | 285 | static int |
| 287 | keymap_memberp (Lisp_Object map, Lisp_Object maps) | 286 | keymap_memberp (Lisp_Object map, Lisp_Object maps) |
| 288 | { | 287 | { |
| 289 | if (NILP (map)) return 0; | 288 | if (NILP (map)) return 0; |
| @@ -360,7 +359,7 @@ Return PARENT. PARENT should be nil or another keymap. */) | |||
| 360 | XCDR (XCAR (list))); | 359 | XCDR (XCAR (list))); |
| 361 | 360 | ||
| 362 | if (VECTORP (XCAR (list))) | 361 | if (VECTORP (XCAR (list))) |
| 363 | for (i = 0; i < XVECTOR (XCAR (list))->size; i++) | 362 | for (i = 0; i < ASIZE (XCAR (list)); i++) |
| 364 | if (CONSP (XVECTOR (XCAR (list))->contents[i])) | 363 | if (CONSP (XVECTOR (XCAR (list))->contents[i])) |
| 365 | fix_submap_inheritance (keymap, make_number (i), | 364 | fix_submap_inheritance (keymap, make_number (i), |
| 366 | XVECTOR (XCAR (list))->contents[i]); | 365 | XVECTOR (XCAR (list))->contents[i]); |
| @@ -463,25 +462,25 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au | |||
| 463 | XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1))); | 462 | XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1))); |
| 464 | 463 | ||
| 465 | /* Handle the special meta -> esc mapping. */ | 464 | /* Handle the special meta -> esc mapping. */ |
| 466 | if (INTEGERP (idx) && XUINT (idx) & meta_modifier) | 465 | if (INTEGERP (idx) && XFASTINT (idx) & meta_modifier) |
| 467 | { | 466 | { |
| 468 | /* See if there is a meta-map. If there's none, there is | 467 | /* 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. */ | 468 | no binding for IDX, unless a default binding exists in MAP. */ |
| 470 | struct gcpro gcpro1; | 469 | struct gcpro gcpro1; |
| 471 | Lisp_Object meta_map; | 470 | Lisp_Object event_meta_map; |
| 472 | GCPRO1 (map); | 471 | GCPRO1 (map); |
| 473 | /* A strange value in which Meta is set would cause | 472 | /* A strange value in which Meta is set would cause |
| 474 | infinite recursion. Protect against that. */ | 473 | infinite recursion. Protect against that. */ |
| 475 | if (XINT (meta_prefix_char) & CHAR_META) | 474 | if (XINT (meta_prefix_char) & CHAR_META) |
| 476 | meta_prefix_char = make_number (27); | 475 | meta_prefix_char = make_number (27); |
| 477 | meta_map = get_keymap (access_keymap (map, meta_prefix_char, | 476 | event_meta_map = get_keymap (access_keymap (map, meta_prefix_char, |
| 478 | t_ok, noinherit, autoload), | 477 | t_ok, noinherit, autoload), |
| 479 | 0, autoload); | 478 | 0, autoload); |
| 480 | UNGCPRO; | 479 | UNGCPRO; |
| 481 | if (CONSP (meta_map)) | 480 | if (CONSP (event_meta_map)) |
| 482 | { | 481 | { |
| 483 | map = meta_map; | 482 | map = event_meta_map; |
| 484 | idx = make_number (XUINT (idx) & ~meta_modifier); | 483 | idx = make_number (XFASTINT (idx) & ~meta_modifier); |
| 485 | } | 484 | } |
| 486 | else if (t_ok) | 485 | else if (t_ok) |
| 487 | /* Set IDX to t, so that we only find a default binding. */ | 486 | /* Set IDX to t, so that we only find a default binding. */ |
| @@ -530,7 +529,7 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au | |||
| 530 | } | 529 | } |
| 531 | else if (VECTORP (binding)) | 530 | else if (VECTORP (binding)) |
| 532 | { | 531 | { |
| 533 | if (NATNUMP (idx) && XFASTINT (idx) < ASIZE (binding)) | 532 | if (INTEGERP (idx) && XFASTINT (idx) < ASIZE (binding)) |
| 534 | val = AREF (binding, XFASTINT (idx)); | 533 | val = AREF (binding, XFASTINT (idx)); |
| 535 | } | 534 | } |
| 536 | else if (CHAR_TABLE_P (binding)) | 535 | else if (CHAR_TABLE_P (binding)) |
| @@ -538,7 +537,7 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au | |||
| 538 | /* Character codes with modifiers | 537 | /* Character codes with modifiers |
| 539 | are not included in a char-table. | 538 | are not included in a char-table. |
| 540 | All character codes without modifiers are included. */ | 539 | All character codes without modifiers are included. */ |
| 541 | if (NATNUMP (idx) && (XFASTINT (idx) & CHAR_MODIFIER_MASK) == 0) | 540 | if (INTEGERP (idx) && (XFASTINT (idx) & CHAR_MODIFIER_MASK) == 0) |
| 542 | { | 541 | { |
| 543 | val = Faref (binding, idx); | 542 | val = Faref (binding, idx); |
| 544 | /* `nil' has a special meaning for char-tables, so | 543 | /* `nil' has a special meaning for char-tables, so |
| @@ -584,7 +583,8 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val) | |||
| 584 | { | 583 | { |
| 585 | if (!NILP (val)) | 584 | if (!NILP (val)) |
| 586 | { | 585 | { |
| 587 | map_keymap_function_t fun = XSAVE_VALUE (XCAR (args))->pointer; | 586 | map_keymap_function_t fun = |
| 587 | (map_keymap_function_t) XSAVE_VALUE (XCAR (args))->pointer; | ||
| 588 | args = XCDR (args); | 588 | args = XCDR (args); |
| 589 | /* If the key is a range, make a copy since map_char_table modifies | 589 | /* If the key is a range, make a copy since map_char_table modifies |
| 590 | it in place. */ | 590 | it in place. */ |
| @@ -597,7 +597,7 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val) | |||
| 597 | 597 | ||
| 598 | /* Call FUN for every binding in MAP and stop at (and return) the parent. | 598 | /* Call FUN for every binding in MAP and stop at (and return) the parent. |
| 599 | FUN is called with 4 arguments: FUN (KEY, BINDING, ARGS, DATA). */ | 599 | FUN is called with 4 arguments: FUN (KEY, BINDING, ARGS, DATA). */ |
| 600 | Lisp_Object | 600 | static Lisp_Object |
| 601 | map_keymap_internal (Lisp_Object map, | 601 | map_keymap_internal (Lisp_Object map, |
| 602 | map_keymap_function_t fun, | 602 | map_keymap_function_t fun, |
| 603 | Lisp_Object args, | 603 | Lisp_Object args, |
| @@ -629,7 +629,7 @@ map_keymap_internal (Lisp_Object map, | |||
| 629 | else if (CHAR_TABLE_P (binding)) | 629 | else if (CHAR_TABLE_P (binding)) |
| 630 | { | 630 | { |
| 631 | map_char_table (map_keymap_char_table_item, Qnil, binding, | 631 | map_char_table (map_keymap_char_table_item, Qnil, binding, |
| 632 | Fcons (make_save_value (fun, 0), | 632 | Fcons (make_save_value ((void *) fun, 0), |
| 633 | Fcons (make_save_value (data, 0), | 633 | Fcons (make_save_value (data, 0), |
| 634 | args))); | 634 | args))); |
| 635 | } | 635 | } |
| @@ -660,7 +660,7 @@ map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void * | |||
| 660 | UNGCPRO; | 660 | UNGCPRO; |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | Lisp_Object Qkeymap_canonicalize; | 663 | static Lisp_Object Qkeymap_canonicalize; |
| 664 | 664 | ||
| 665 | /* Same as map_keymap, but does it right, properly eliminating duplicate | 665 | /* Same as map_keymap, but does it right, properly eliminating duplicate |
| 666 | bindings due to inheritance. */ | 666 | bindings due to inheritance. */ |
| @@ -957,9 +957,9 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def) | |||
| 957 | return def; | 957 | return def; |
| 958 | } | 958 | } |
| 959 | 959 | ||
| 960 | EXFUN (Fcopy_keymap, 1); | 960 | static Lisp_Object Fcopy_keymap (Lisp_Object); |
| 961 | 961 | ||
| 962 | Lisp_Object | 962 | static Lisp_Object |
| 963 | copy_keymap_item (Lisp_Object elt) | 963 | copy_keymap_item (Lisp_Object elt) |
| 964 | { | 964 | { |
| 965 | Lisp_Object res, tem; | 965 | Lisp_Object res, tem; |
| @@ -1141,10 +1141,10 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1141 | int i = ASIZE (def); | 1141 | int i = ASIZE (def); |
| 1142 | while (--i >= 0) | 1142 | while (--i >= 0) |
| 1143 | { | 1143 | { |
| 1144 | Lisp_Object c = AREF (def, i); | 1144 | Lisp_Object defi = AREF (def, i); |
| 1145 | if (CONSP (c) && lucid_event_type_list_p (c)) | 1145 | if (CONSP (defi) && lucid_event_type_list_p (defi)) |
| 1146 | c = Fevent_convert_list (c); | 1146 | defi = Fevent_convert_list (defi); |
| 1147 | ASET (tmp, i, c); | 1147 | ASET (tmp, i, defi); |
| 1148 | } | 1148 | } |
| 1149 | def = tmp; | 1149 | def = tmp; |
| 1150 | } | 1150 | } |
| @@ -1336,7 +1336,7 @@ define_as_prefix (Lisp_Object keymap, Lisp_Object c) | |||
| 1336 | 1336 | ||
| 1337 | /* Append a key to the end of a key sequence. We always make a vector. */ | 1337 | /* Append a key to the end of a key sequence. We always make a vector. */ |
| 1338 | 1338 | ||
| 1339 | Lisp_Object | 1339 | static Lisp_Object |
| 1340 | append_key (Lisp_Object key_sequence, Lisp_Object key) | 1340 | append_key (Lisp_Object key_sequence, Lisp_Object key) |
| 1341 | { | 1341 | { |
| 1342 | Lisp_Object args[2]; | 1342 | Lisp_Object args[2]; |
| @@ -1357,7 +1357,7 @@ silly_event_symbol_error (Lisp_Object c) | |||
| 1357 | int modifiers; | 1357 | int modifiers; |
| 1358 | 1358 | ||
| 1359 | parsed = parse_modifiers (c); | 1359 | parsed = parse_modifiers (c); |
| 1360 | modifiers = (int) XUINT (XCAR (XCDR (parsed))); | 1360 | modifiers = XFASTINT (XCAR (XCDR (parsed))); |
| 1361 | base = XCAR (parsed); | 1361 | base = XCAR (parsed); |
| 1362 | name = Fsymbol_name (base); | 1362 | name = Fsymbol_name (base); |
| 1363 | /* This alist includes elements such as ("RET" . "\\r"). */ | 1363 | /* This alist includes elements such as ("RET" . "\\r"). */ |
| @@ -1564,8 +1564,8 @@ like in the respective argument of `key-binding'. */) | |||
| 1564 | 1564 | ||
| 1565 | if (!NILP (olp)) | 1565 | if (!NILP (olp)) |
| 1566 | { | 1566 | { |
| 1567 | if (!NILP (current_kboard->Voverriding_terminal_local_map)) | 1567 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) |
| 1568 | keymaps = Fcons (current_kboard->Voverriding_terminal_local_map, keymaps); | 1568 | keymaps = Fcons (KVAR (current_kboard, Voverriding_terminal_local_map), keymaps); |
| 1569 | /* The doc said that overriding-terminal-local-map should | 1569 | /* The doc said that overriding-terminal-local-map should |
| 1570 | override overriding-local-map. The code used them both, | 1570 | override overriding-local-map. The code used them both, |
| 1571 | but it seems clearer to use just one. rms, jan 2005. */ | 1571 | but it seems clearer to use just one. rms, jan 2005. */ |
| @@ -1744,9 +1744,9 @@ specified buffer position instead of point are used. | |||
| 1744 | } | 1744 | } |
| 1745 | } | 1745 | } |
| 1746 | 1746 | ||
| 1747 | if (! NILP (current_kboard->Voverriding_terminal_local_map)) | 1747 | if (! NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) |
| 1748 | { | 1748 | { |
| 1749 | value = Flookup_key (current_kboard->Voverriding_terminal_local_map, | 1749 | value = Flookup_key (KVAR (current_kboard, Voverriding_terminal_local_map), |
| 1750 | key, accept_default); | 1750 | key, accept_default); |
| 1751 | if (! NILP (value) && !INTEGERP (value)) | 1751 | if (! NILP (value) && !INTEGERP (value)) |
| 1752 | goto done; | 1752 | goto done; |
| @@ -1882,7 +1882,7 @@ bindings; see the description of `lookup-key' for more details about this. */) | |||
| 1882 | (Lisp_Object keys, Lisp_Object accept_default) | 1882 | (Lisp_Object keys, Lisp_Object accept_default) |
| 1883 | { | 1883 | { |
| 1884 | register Lisp_Object map; | 1884 | register Lisp_Object map; |
| 1885 | map = current_buffer->keymap; | 1885 | map = BVAR (current_buffer, keymap); |
| 1886 | if (NILP (map)) | 1886 | if (NILP (map)) |
| 1887 | return Qnil; | 1887 | return Qnil; |
| 1888 | return Flookup_key (map, keys, accept_default); | 1888 | return Flookup_key (map, keys, accept_default); |
| @@ -1987,7 +1987,7 @@ If KEYMAP is nil, that means no local keymap. */) | |||
| 1987 | if (!NILP (keymap)) | 1987 | if (!NILP (keymap)) |
| 1988 | keymap = get_keymap (keymap, 1, 1); | 1988 | keymap = get_keymap (keymap, 1, 1); |
| 1989 | 1989 | ||
| 1990 | current_buffer->keymap = keymap; | 1990 | BVAR (current_buffer, keymap) = keymap; |
| 1991 | 1991 | ||
| 1992 | return Qnil; | 1992 | return Qnil; |
| 1993 | } | 1993 | } |
| @@ -1997,7 +1997,7 @@ DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0, | |||
| 1997 | Normally the local keymap is set by the major mode with `use-local-map'. */) | 1997 | Normally the local keymap is set by the major mode with `use-local-map'. */) |
| 1998 | (void) | 1998 | (void) |
| 1999 | { | 1999 | { |
| 2000 | return current_buffer->keymap; | 2000 | return BVAR (current_buffer, keymap); |
| 2001 | } | 2001 | } |
| 2002 | 2002 | ||
| 2003 | DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0, | 2003 | DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0, |
| @@ -2176,7 +2176,7 @@ then the value includes only maps for prefixes that start with PREFIX. */) | |||
| 2176 | } | 2176 | } |
| 2177 | return maps; | 2177 | return maps; |
| 2178 | } | 2178 | } |
| 2179 | Lisp_Object Qsingle_key_description, Qkey_description; | 2179 | static Lisp_Object Qsingle_key_description, Qkey_description; |
| 2180 | 2180 | ||
| 2181 | /* This function cannot GC. */ | 2181 | /* This function cannot GC. */ |
| 2182 | 2182 | ||
| @@ -2226,7 +2226,7 @@ spaces are put between sequence elements, etc. */) | |||
| 2226 | if (STRINGP (list)) | 2226 | if (STRINGP (list)) |
| 2227 | size = SCHARS (list); | 2227 | size = SCHARS (list); |
| 2228 | else if (VECTORP (list)) | 2228 | else if (VECTORP (list)) |
| 2229 | size = XVECTOR (list)->size; | 2229 | size = ASIZE (list); |
| 2230 | else if (CONSP (list)) | 2230 | else if (CONSP (list)) |
| 2231 | size = XINT (Flength (list)); | 2231 | size = XINT (Flength (list)); |
| 2232 | else | 2232 | else |
| @@ -2378,7 +2378,7 @@ push_key_description (register unsigned int c, register char *p, int force_multi | |||
| 2378 | *p++ = 'C'; | 2378 | *p++ = 'C'; |
| 2379 | } | 2379 | } |
| 2380 | else if (c < 128 | 2380 | else if (c < 128 |
| 2381 | || (NILP (current_buffer->enable_multibyte_characters) | 2381 | || (NILP (BVAR (current_buffer, enable_multibyte_characters)) |
| 2382 | && SINGLE_BYTE_CHAR_P (c) | 2382 | && SINGLE_BYTE_CHAR_P (c) |
| 2383 | && !force_multibyte)) | 2383 | && !force_multibyte)) |
| 2384 | { | 2384 | { |
| @@ -2387,9 +2387,9 @@ push_key_description (register unsigned int c, register char *p, int force_multi | |||
| 2387 | else | 2387 | else |
| 2388 | { | 2388 | { |
| 2389 | /* Now we are sure that C is a valid character code. */ | 2389 | /* Now we are sure that C is a valid character code. */ |
| 2390 | if (NILP (current_buffer->enable_multibyte_characters) | 2390 | if (NILP (BVAR (current_buffer, enable_multibyte_characters)) |
| 2391 | && ! force_multibyte) | 2391 | && ! force_multibyte) |
| 2392 | *p++ = multibyte_char_to_unibyte (c, Qnil); | 2392 | *p++ = multibyte_char_to_unibyte (c); |
| 2393 | else | 2393 | else |
| 2394 | p += CHAR_STRING (c, (unsigned char *) p); | 2394 | p += CHAR_STRING (c, (unsigned char *) p); |
| 2395 | } | 2395 | } |
| @@ -2416,7 +2416,7 @@ around function keys and event symbols. */) | |||
| 2416 | { | 2416 | { |
| 2417 | char tem[KEY_DESCRIPTION_SIZE]; | 2417 | char tem[KEY_DESCRIPTION_SIZE]; |
| 2418 | 2418 | ||
| 2419 | *push_key_description (XUINT (key), tem, 1) = 0; | 2419 | *push_key_description (XINT (key), tem, 1) = 0; |
| 2420 | return build_string (tem); | 2420 | return build_string (tem); |
| 2421 | } | 2421 | } |
| 2422 | else if (SYMBOLP (key)) /* Function key or event-symbol */ | 2422 | else if (SYMBOLP (key)) /* Function key or event-symbol */ |
| @@ -2438,7 +2438,7 @@ around function keys and event symbols. */) | |||
| 2438 | return Qnil; | 2438 | return Qnil; |
| 2439 | } | 2439 | } |
| 2440 | 2440 | ||
| 2441 | char * | 2441 | static char * |
| 2442 | push_text_char_description (register unsigned int c, register char *p) | 2442 | push_text_char_description (register unsigned int c, register char *p) |
| 2443 | { | 2443 | { |
| 2444 | if (c >= 0200) | 2444 | if (c >= 0200) |
| @@ -2474,7 +2474,7 @@ See Info node `(elisp)Describing Characters' for examples. */) | |||
| 2474 | (Lisp_Object character) | 2474 | (Lisp_Object character) |
| 2475 | { | 2475 | { |
| 2476 | /* Currently MAX_MULTIBYTE_LENGTH is 4 (< 6). */ | 2476 | /* Currently MAX_MULTIBYTE_LENGTH is 4 (< 6). */ |
| 2477 | unsigned char str[6]; | 2477 | char str[6]; |
| 2478 | int c; | 2478 | int c; |
| 2479 | 2479 | ||
| 2480 | CHECK_NUMBER (character); | 2480 | CHECK_NUMBER (character); |
| @@ -2482,7 +2482,7 @@ See Info node `(elisp)Describing Characters' for examples. */) | |||
| 2482 | c = XINT (character); | 2482 | c = XINT (character); |
| 2483 | if (!ASCII_CHAR_P (c)) | 2483 | if (!ASCII_CHAR_P (c)) |
| 2484 | { | 2484 | { |
| 2485 | int len = CHAR_STRING (c, str); | 2485 | int len = CHAR_STRING (c, (unsigned char *) str); |
| 2486 | 2486 | ||
| 2487 | return make_multibyte_string (str, 1, len); | 2487 | return make_multibyte_string (str, 1, len); |
| 2488 | } | 2488 | } |
| @@ -2515,7 +2515,7 @@ preferred_sequence_p (Lisp_Object seq) | |||
| 2515 | return 0; | 2515 | return 0; |
| 2516 | else | 2516 | else |
| 2517 | { | 2517 | { |
| 2518 | int modifiers = XUINT (elt) & (CHAR_MODIFIER_MASK & ~CHAR_META); | 2518 | int modifiers = XINT (elt) & (CHAR_MODIFIER_MASK & ~CHAR_META); |
| 2519 | if (modifiers == where_is_preferred_modifier) | 2519 | if (modifiers == where_is_preferred_modifier) |
| 2520 | result = 2; | 2520 | result = 2; |
| 2521 | else if (modifiers) | 2521 | else if (modifiers) |
| @@ -2755,7 +2755,7 @@ remapped command in the returned list. */) | |||
| 2755 | && !NILP (firstonly) | 2755 | && !NILP (firstonly) |
| 2756 | && !NILP (tem = Fget (definition, QCadvertised_binding))) | 2756 | && !NILP (tem = Fget (definition, QCadvertised_binding))) |
| 2757 | { | 2757 | { |
| 2758 | /* We have a list of advertized bindings. */ | 2758 | /* We have a list of advertised bindings. */ |
| 2759 | while (CONSP (tem)) | 2759 | while (CONSP (tem)) |
| 2760 | if (EQ (shadow_lookup (keymaps, XCAR (tem), Qnil, 0), definition)) | 2760 | if (EQ (shadow_lookup (keymaps, XCAR (tem), Qnil, 0), definition)) |
| 2761 | return XCAR (tem); | 2761 | return XCAR (tem); |
| @@ -2773,8 +2773,8 @@ remapped command in the returned list. */) | |||
| 2773 | considered remapped sequences yet, copy them over and | 2773 | considered remapped sequences yet, copy them over and |
| 2774 | process them. */ | 2774 | process them. */ |
| 2775 | || (!remapped && (sequences = remapped_sequences, | 2775 | || (!remapped && (sequences = remapped_sequences, |
| 2776 | remapped = 1), | 2776 | remapped = 1, |
| 2777 | CONSP (sequences))) | 2777 | CONSP (sequences)))) |
| 2778 | { | 2778 | { |
| 2779 | Lisp_Object sequence, function; | 2779 | Lisp_Object sequence, function; |
| 2780 | 2780 | ||
| @@ -2814,9 +2814,9 @@ remapped command in the returned list. */) | |||
| 2814 | seems to be only one menu item to report. */ | 2814 | seems to be only one menu item to report. */ |
| 2815 | if (! NILP (sequence)) | 2815 | if (! NILP (sequence)) |
| 2816 | { | 2816 | { |
| 2817 | Lisp_Object tem; | 2817 | Lisp_Object tem1; |
| 2818 | tem = Faref (sequence, make_number (ASIZE (sequence) - 1)); | 2818 | tem1 = Faref (sequence, make_number (ASIZE (sequence) - 1)); |
| 2819 | if (STRINGP (tem)) | 2819 | if (STRINGP (tem1)) |
| 2820 | Faset (sequence, make_number (ASIZE (sequence) - 1), | 2820 | Faset (sequence, make_number (ASIZE (sequence) - 1), |
| 2821 | build_string ("(any string)")); | 2821 | build_string ("(any string)")); |
| 2822 | } | 2822 | } |
| @@ -2940,11 +2940,11 @@ You type Translation\n\ | |||
| 2940 | outbuf = Fcurrent_buffer (); | 2940 | outbuf = Fcurrent_buffer (); |
| 2941 | 2941 | ||
| 2942 | /* Report on alternates for keys. */ | 2942 | /* Report on alternates for keys. */ |
| 2943 | if (STRINGP (current_kboard->Vkeyboard_translate_table) && !NILP (prefix)) | 2943 | if (STRINGP (KVAR (current_kboard, Vkeyboard_translate_table)) && !NILP (prefix)) |
| 2944 | { | 2944 | { |
| 2945 | int c; | 2945 | int c; |
| 2946 | const unsigned char *translate = SDATA (current_kboard->Vkeyboard_translate_table); | 2946 | const unsigned char *translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table)); |
| 2947 | int translate_len = SCHARS (current_kboard->Vkeyboard_translate_table); | 2947 | int translate_len = SCHARS (KVAR (current_kboard, Vkeyboard_translate_table)); |
| 2948 | 2948 | ||
| 2949 | for (c = 0; c < translate_len; c++) | 2949 | for (c = 0; c < translate_len; c++) |
| 2950 | if (translate[c] != c) | 2950 | if (translate[c] != c) |
| @@ -2967,7 +2967,7 @@ You type Translation\n\ | |||
| 2967 | insert ("\n", 1); | 2967 | insert ("\n", 1); |
| 2968 | 2968 | ||
| 2969 | /* Insert calls signal_after_change which may GC. */ | 2969 | /* Insert calls signal_after_change which may GC. */ |
| 2970 | translate = SDATA (current_kboard->Vkeyboard_translate_table); | 2970 | translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table)); |
| 2971 | } | 2971 | } |
| 2972 | 2972 | ||
| 2973 | insert ("\n", 1); | 2973 | insert ("\n", 1); |
| @@ -2980,8 +2980,8 @@ You type Translation\n\ | |||
| 2980 | 2980 | ||
| 2981 | /* Print the (major mode) local map. */ | 2981 | /* Print the (major mode) local map. */ |
| 2982 | start1 = Qnil; | 2982 | start1 = Qnil; |
| 2983 | if (!NILP (current_kboard->Voverriding_terminal_local_map)) | 2983 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) |
| 2984 | start1 = current_kboard->Voverriding_terminal_local_map; | 2984 | start1 = KVAR (current_kboard, Voverriding_terminal_local_map); |
| 2985 | else if (!NILP (Voverriding_local_map)) | 2985 | else if (!NILP (Voverriding_local_map)) |
| 2986 | start1 = Voverriding_local_map; | 2986 | start1 = Voverriding_local_map; |
| 2987 | 2987 | ||
| @@ -3047,7 +3047,7 @@ You type Translation\n\ | |||
| 3047 | XBUFFER (buffer), Qlocal_map); | 3047 | XBUFFER (buffer), Qlocal_map); |
| 3048 | if (!NILP (start1)) | 3048 | if (!NILP (start1)) |
| 3049 | { | 3049 | { |
| 3050 | if (EQ (start1, XBUFFER (buffer)->keymap)) | 3050 | if (EQ (start1, BVAR (XBUFFER (buffer), keymap))) |
| 3051 | describe_map_tree (start1, 1, shadow, prefix, | 3051 | describe_map_tree (start1, 1, shadow, prefix, |
| 3052 | "\f\nMajor Mode Bindings", nomenu, 0, 0, 0); | 3052 | "\f\nMajor Mode Bindings", nomenu, 0, 0, 0); |
| 3053 | else | 3053 | else |
| @@ -3063,13 +3063,13 @@ You type Translation\n\ | |||
| 3063 | "\f\nGlobal Bindings", nomenu, 0, 1, 0); | 3063 | "\f\nGlobal Bindings", nomenu, 0, 1, 0); |
| 3064 | 3064 | ||
| 3065 | /* Print the function-key-map translations under this prefix. */ | 3065 | /* Print the function-key-map translations under this prefix. */ |
| 3066 | if (!NILP (current_kboard->Vlocal_function_key_map)) | 3066 | if (!NILP (KVAR (current_kboard, Vlocal_function_key_map))) |
| 3067 | describe_map_tree (current_kboard->Vlocal_function_key_map, 0, Qnil, prefix, | 3067 | describe_map_tree (KVAR (current_kboard, Vlocal_function_key_map), 0, Qnil, prefix, |
| 3068 | "\f\nFunction key map translations", nomenu, 1, 0, 0); | 3068 | "\f\nFunction key map translations", nomenu, 1, 0, 0); |
| 3069 | 3069 | ||
| 3070 | /* Print the input-decode-map translations under this prefix. */ | 3070 | /* Print the input-decode-map translations under this prefix. */ |
| 3071 | if (!NILP (current_kboard->Vinput_decode_map)) | 3071 | if (!NILP (KVAR (current_kboard, Vinput_decode_map))) |
| 3072 | describe_map_tree (current_kboard->Vinput_decode_map, 0, Qnil, prefix, | 3072 | describe_map_tree (KVAR (current_kboard, Vinput_decode_map), 0, Qnil, prefix, |
| 3073 | "\f\nInput decoding map translations", nomenu, 1, 0, 0); | 3073 | "\f\nInput decoding map translations", nomenu, 1, 0, 0); |
| 3074 | 3074 | ||
| 3075 | UNGCPRO; | 3075 | UNGCPRO; |
| @@ -3121,13 +3121,13 @@ key binding\n\ | |||
| 3121 | /* Delete from MAPS each element that is for the menu bar. */ | 3121 | /* Delete from MAPS each element that is for the menu bar. */ |
| 3122 | for (list = maps; CONSP (list); list = XCDR (list)) | 3122 | for (list = maps; CONSP (list); list = XCDR (list)) |
| 3123 | { | 3123 | { |
| 3124 | Lisp_Object elt, prefix, tem; | 3124 | Lisp_Object elt, elt_prefix, tem; |
| 3125 | 3125 | ||
| 3126 | elt = XCAR (list); | 3126 | elt = XCAR (list); |
| 3127 | prefix = Fcar (elt); | 3127 | elt_prefix = Fcar (elt); |
| 3128 | if (XVECTOR (prefix)->size >= 1) | 3128 | if (ASIZE (elt_prefix) >= 1) |
| 3129 | { | 3129 | { |
| 3130 | tem = Faref (prefix, make_number (0)); | 3130 | tem = Faref (elt_prefix, make_number (0)); |
| 3131 | if (EQ (tem, Qmenu_bar)) | 3131 | if (EQ (tem, Qmenu_bar)) |
| 3132 | maps = Fdelq (elt, maps); | 3132 | maps = Fdelq (elt, maps); |
| 3133 | } | 3133 | } |
| @@ -3152,10 +3152,10 @@ key binding\n\ | |||
| 3152 | 3152 | ||
| 3153 | for (; CONSP (maps); maps = XCDR (maps)) | 3153 | for (; CONSP (maps); maps = XCDR (maps)) |
| 3154 | { | 3154 | { |
| 3155 | register Lisp_Object elt, prefix, tail; | 3155 | register Lisp_Object elt, elt_prefix, tail; |
| 3156 | 3156 | ||
| 3157 | elt = XCAR (maps); | 3157 | elt = XCAR (maps); |
| 3158 | prefix = Fcar (elt); | 3158 | elt_prefix = Fcar (elt); |
| 3159 | 3159 | ||
| 3160 | sub_shadows = Qnil; | 3160 | sub_shadows = Qnil; |
| 3161 | 3161 | ||
| @@ -3167,8 +3167,8 @@ key binding\n\ | |||
| 3167 | 3167 | ||
| 3168 | /* If the sequence by which we reach this keymap is zero-length, | 3168 | /* If the sequence by which we reach this keymap is zero-length, |
| 3169 | then the shadow map for this keymap is just SHADOW. */ | 3169 | then the shadow map for this keymap is just SHADOW. */ |
| 3170 | if ((STRINGP (prefix) && SCHARS (prefix) == 0) | 3170 | if ((STRINGP (elt_prefix) && SCHARS (elt_prefix) == 0) |
| 3171 | || (VECTORP (prefix) && XVECTOR (prefix)->size == 0)) | 3171 | || (VECTORP (elt_prefix) && ASIZE (elt_prefix) == 0)) |
| 3172 | ; | 3172 | ; |
| 3173 | /* If the sequence by which we reach this keymap actually has | 3173 | /* If the sequence by which we reach this keymap actually has |
| 3174 | some elements, then the sequence's definition in SHADOW is | 3174 | some elements, then the sequence's definition in SHADOW is |
| @@ -3194,12 +3194,12 @@ key binding\n\ | |||
| 3194 | for (tail = orig_maps; !EQ (tail, maps); tail = XCDR (tail)) | 3194 | for (tail = orig_maps; !EQ (tail, maps); tail = XCDR (tail)) |
| 3195 | { | 3195 | { |
| 3196 | Lisp_Object tem; | 3196 | Lisp_Object tem; |
| 3197 | tem = Fequal (Fcar (XCAR (tail)), prefix); | 3197 | tem = Fequal (Fcar (XCAR (tail)), elt_prefix); |
| 3198 | if (!NILP (tem)) | 3198 | if (!NILP (tem)) |
| 3199 | sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows); | 3199 | sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows); |
| 3200 | } | 3200 | } |
| 3201 | 3201 | ||
| 3202 | describe_map (Fcdr (elt), prefix, | 3202 | describe_map (Fcdr (elt), elt_prefix, |
| 3203 | transl ? describe_translation : describe_command, | 3203 | transl ? describe_translation : describe_command, |
| 3204 | partial, sub_shadows, &seen, nomenu, mention_shadow); | 3204 | partial, sub_shadows, &seen, nomenu, mention_shadow); |
| 3205 | 3205 | ||
| @@ -3218,7 +3218,7 @@ static void | |||
| 3218 | describe_command (Lisp_Object definition, Lisp_Object args) | 3218 | describe_command (Lisp_Object definition, Lisp_Object args) |
| 3219 | { | 3219 | { |
| 3220 | register Lisp_Object tem1; | 3220 | register Lisp_Object tem1; |
| 3221 | int column = (int) current_column (); /* iftc */ | 3221 | EMACS_INT column = current_column (); |
| 3222 | int description_column; | 3222 | int description_column; |
| 3223 | 3223 | ||
| 3224 | /* If column 16 is no good, go to col 32; | 3224 | /* If column 16 is no good, go to col 32; |
| @@ -3354,7 +3354,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix, | |||
| 3354 | || CHAR_TABLE_P (XCAR (tail))) | 3354 | || CHAR_TABLE_P (XCAR (tail))) |
| 3355 | describe_vector (XCAR (tail), | 3355 | describe_vector (XCAR (tail), |
| 3356 | prefix, Qnil, elt_describer, partial, shadow, map, | 3356 | prefix, Qnil, elt_describer, partial, shadow, map, |
| 3357 | (int *)0, 0, 1, mention_shadow); | 3357 | 1, mention_shadow); |
| 3358 | else if (CONSP (XCAR (tail))) | 3358 | else if (CONSP (XCAR (tail))) |
| 3359 | { | 3359 | { |
| 3360 | int this_shadowed = 0; | 3360 | int this_shadowed = 0; |
| @@ -3507,7 +3507,7 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3507 | specbind (Qstandard_output, Fcurrent_buffer ()); | 3507 | specbind (Qstandard_output, Fcurrent_buffer ()); |
| 3508 | CHECK_VECTOR_OR_CHAR_TABLE (vector); | 3508 | CHECK_VECTOR_OR_CHAR_TABLE (vector); |
| 3509 | describe_vector (vector, Qnil, describer, describe_vector_princ, 0, | 3509 | describe_vector (vector, Qnil, describer, describe_vector_princ, 0, |
| 3510 | Qnil, Qnil, (int *)0, 0, 0, 0); | 3510 | Qnil, Qnil, 0, 0); |
| 3511 | 3511 | ||
| 3512 | return unbind_to (count, Qnil); | 3512 | return unbind_to (count, Qnil); |
| 3513 | } | 3513 | } |
| @@ -3540,9 +3540,6 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3540 | 3540 | ||
| 3541 | ARGS is simply passed as the second argument to ELT_DESCRIBER. | 3541 | ARGS is simply passed as the second argument to ELT_DESCRIBER. |
| 3542 | 3542 | ||
| 3543 | INDICES and CHAR_TABLE_DEPTH are ignored. They will be removed in | ||
| 3544 | the near future. | ||
| 3545 | |||
| 3546 | KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-. | 3543 | KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-. |
| 3547 | 3544 | ||
| 3548 | ARGS is simply passed as the second argument to ELT_DESCRIBER. */ | 3545 | ARGS is simply passed as the second argument to ELT_DESCRIBER. */ |
| @@ -3551,8 +3548,7 @@ static void | |||
| 3551 | describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | 3548 | describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, |
| 3552 | void (*elt_describer) (Lisp_Object, Lisp_Object), | 3549 | void (*elt_describer) (Lisp_Object, Lisp_Object), |
| 3553 | int partial, Lisp_Object shadow, Lisp_Object entire_map, | 3550 | int partial, Lisp_Object shadow, Lisp_Object entire_map, |
| 3554 | int *indices, int char_table_depth, int keymap_p, | 3551 | int keymap_p, int mention_shadow) |
| 3555 | int mention_shadow) | ||
| 3556 | { | 3552 | { |
| 3557 | Lisp_Object definition; | 3553 | Lisp_Object definition; |
| 3558 | Lisp_Object tem2; | 3554 | Lisp_Object tem2; |
| @@ -3596,7 +3592,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | |||
| 3596 | if (CHAR_TABLE_P (vector)) | 3592 | if (CHAR_TABLE_P (vector)) |
| 3597 | stop = MAX_5_BYTE_CHAR + 1, to = MAX_CHAR + 1; | 3593 | stop = MAX_5_BYTE_CHAR + 1, to = MAX_CHAR + 1; |
| 3598 | else | 3594 | else |
| 3599 | stop = to = XVECTOR (vector)->size; | 3595 | stop = to = ASIZE (vector); |
| 3600 | 3596 | ||
| 3601 | for (i = from; ; i++) | 3597 | for (i = from; ; i++) |
| 3602 | { | 3598 | { |
| @@ -3975,4 +3971,3 @@ keys_of_keymap (void) | |||
| 3975 | initial_define_key (global_map, 033, "ESC-prefix"); | 3971 | initial_define_key (global_map, 033, "ESC-prefix"); |
| 3976 | initial_define_key (global_map, Ctl ('X'), "Control-X-prefix"); | 3972 | initial_define_key (global_map, Ctl ('X'), "Control-X-prefix"); |
| 3977 | } | 3973 | } |
| 3978 | |||