diff options
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 345 |
1 files changed, 187 insertions, 158 deletions
diff --git a/src/keymap.c b/src/keymap.c index b429ca968d7..fbdd31e0de3 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Manipulation of keymaps | 1 | /* Manipulation of keymaps |
| 2 | Copyright (C) 1985-1988, 1993-1995, 1998-2011 Free Software Foundation, Inc. | 2 | Copyright (C) 1985-1988, 1993-1995, 1998-2012 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -40,11 +40,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 40 | 40 | ||
| 41 | #include <config.h> | 41 | #include <config.h> |
| 42 | #include <stdio.h> | 42 | #include <stdio.h> |
| 43 | #include <setjmp.h> | 43 | |
| 44 | #include "lisp.h" | 44 | #include "lisp.h" |
| 45 | #include "commands.h" | 45 | #include "commands.h" |
| 46 | #include "buffer.h" | ||
| 47 | #include "character.h" | 46 | #include "character.h" |
| 47 | #include "buffer.h" | ||
| 48 | #include "charset.h" | 48 | #include "charset.h" |
| 49 | #include "keyboard.h" | 49 | #include "keyboard.h" |
| 50 | #include "frame.h" | 50 | #include "frame.h" |
| @@ -92,7 +92,6 @@ static Lisp_Object where_is_cache; | |||
| 92 | /* Which keymaps are reverse-stored in the cache. */ | 92 | /* Which keymaps are reverse-stored in the cache. */ |
| 93 | static Lisp_Object where_is_cache_keymaps; | 93 | static Lisp_Object where_is_cache_keymaps; |
| 94 | 94 | ||
| 95 | static Lisp_Object Flookup_key (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 96 | static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); | 95 | static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); |
| 97 | 96 | ||
| 98 | static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); | 97 | static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); |
| @@ -100,12 +99,12 @@ static void describe_command (Lisp_Object, Lisp_Object); | |||
| 100 | static void describe_translation (Lisp_Object, Lisp_Object); | 99 | static void describe_translation (Lisp_Object, Lisp_Object); |
| 101 | static void describe_map (Lisp_Object, Lisp_Object, | 100 | static void describe_map (Lisp_Object, Lisp_Object, |
| 102 | void (*) (Lisp_Object, Lisp_Object), | 101 | void (*) (Lisp_Object, Lisp_Object), |
| 103 | int, Lisp_Object, Lisp_Object*, int, int); | 102 | bool, Lisp_Object, Lisp_Object*, bool, bool); |
| 104 | static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, | 103 | static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, |
| 105 | void (*) (Lisp_Object, Lisp_Object), int, | 104 | void (*) (Lisp_Object, Lisp_Object), bool, |
| 106 | Lisp_Object, Lisp_Object, int, int); | 105 | Lisp_Object, Lisp_Object, bool, bool); |
| 107 | static void silly_event_symbol_error (Lisp_Object); | 106 | static void silly_event_symbol_error (Lisp_Object); |
| 108 | static Lisp_Object get_keyelt (Lisp_Object, int); | 107 | static Lisp_Object get_keyelt (Lisp_Object, bool); |
| 109 | 108 | ||
| 110 | /* Keymap object support - constructors and predicates. */ | 109 | /* Keymap object support - constructors and predicates. */ |
| 111 | 110 | ||
| @@ -208,15 +207,12 @@ when reading a key-sequence to be looked-up in this keymap. */) | |||
| 208 | /* Check that OBJECT is a keymap (after dereferencing through any | 207 | /* Check that OBJECT is a keymap (after dereferencing through any |
| 209 | symbols). If it is, return it. | 208 | symbols). If it is, return it. |
| 210 | 209 | ||
| 211 | If AUTOLOAD is non-zero and OBJECT is a symbol whose function value | 210 | If AUTOLOAD and if OBJECT is a symbol whose function value |
| 212 | is an autoload form, do the autoload and try again. | 211 | is an autoload form, do the autoload and try again. |
| 213 | If AUTOLOAD is nonzero, callers must assume GC is possible. | 212 | If AUTOLOAD, callers must assume GC is possible. |
| 214 | |||
| 215 | If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR | ||
| 216 | is zero as well), return Qt. | ||
| 217 | 213 | ||
| 218 | ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap. | 214 | ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap. |
| 219 | If ERROR_IF_NOT_KEYMAP is non-zero, signal an error; otherwise, | 215 | If ERROR_IF_NOT_KEYMAP, signal an error; otherwise, |
| 220 | just return Qnil. | 216 | just return Qnil. |
| 221 | 217 | ||
| 222 | Note that most of the time, we don't want to pursue autoloads. | 218 | Note that most of the time, we don't want to pursue autoloads. |
| @@ -225,11 +221,11 @@ when reading a key-sequence to be looked-up in this keymap. */) | |||
| 225 | but it seems to me that only read_key_sequence, Flookup_key, and | 221 | but it seems to me that only read_key_sequence, Flookup_key, and |
| 226 | Fdefine_key should cause keymaps to be autoloaded. | 222 | Fdefine_key should cause keymaps to be autoloaded. |
| 227 | 223 | ||
| 228 | This function can GC when AUTOLOAD is non-zero, because it calls | 224 | This function can GC when AUTOLOAD is true, because it calls |
| 229 | do_autoload which can GC. */ | 225 | Fautoload_do_load which can GC. */ |
| 230 | 226 | ||
| 231 | Lisp_Object | 227 | Lisp_Object |
| 232 | get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) | 228 | get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload) |
| 233 | { | 229 | { |
| 234 | Lisp_Object tem; | 230 | Lisp_Object tem; |
| 235 | 231 | ||
| @@ -260,7 +256,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) | |||
| 260 | struct gcpro gcpro1, gcpro2; | 256 | struct gcpro gcpro1, gcpro2; |
| 261 | 257 | ||
| 262 | GCPRO2 (tem, object); | 258 | GCPRO2 (tem, object); |
| 263 | do_autoload (tem, object); | 259 | Fautoload_do_load (tem, object, Qnil); |
| 264 | UNGCPRO; | 260 | UNGCPRO; |
| 265 | 261 | ||
| 266 | goto autoload_retry; | 262 | goto autoload_retry; |
| @@ -281,7 +277,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) | |||
| 281 | We assume that KEYMAP is a valid keymap. */ | 277 | We assume that KEYMAP is a valid keymap. */ |
| 282 | 278 | ||
| 283 | static Lisp_Object | 279 | static Lisp_Object |
| 284 | keymap_parent (Lisp_Object keymap, int autoload) | 280 | keymap_parent (Lisp_Object keymap, bool autoload) |
| 285 | { | 281 | { |
| 286 | Lisp_Object list; | 282 | Lisp_Object list; |
| 287 | 283 | ||
| @@ -308,7 +304,7 @@ If KEYMAP has no parent, return nil. */) | |||
| 308 | } | 304 | } |
| 309 | 305 | ||
| 310 | /* Check whether MAP is one of MAPS parents. */ | 306 | /* Check whether MAP is one of MAPS parents. */ |
| 311 | static int | 307 | static bool |
| 312 | keymap_memberp (Lisp_Object map, Lisp_Object maps) | 308 | keymap_memberp (Lisp_Object map, Lisp_Object maps) |
| 313 | { | 309 | { |
| 314 | if (NILP (map)) return 0; | 310 | if (NILP (map)) return 0; |
| @@ -366,19 +362,20 @@ Return PARENT. PARENT should be nil or another keymap. */) | |||
| 366 | 362 | ||
| 367 | MAP must be a keymap or a list of keymaps. | 363 | MAP must be a keymap or a list of keymaps. |
| 368 | 364 | ||
| 369 | If T_OK is non-zero, bindings for Qt are treated as default | 365 | If T_OK, bindings for Qt are treated as default |
| 370 | bindings; any key left unmentioned by other tables and bindings is | 366 | bindings; any key left unmentioned by other tables and bindings is |
| 371 | given the binding of Qt. | 367 | given the binding of Qt. |
| 372 | 368 | ||
| 373 | If T_OK is zero, bindings for Qt are not treated specially. | 369 | If not T_OK, bindings for Qt are not treated specially. |
| 374 | 370 | ||
| 375 | If NOINHERIT, don't accept a subkeymap found in an inherited keymap. | 371 | If NOINHERIT, don't accept a subkeymap found in an inherited keymap. |
| 376 | 372 | ||
| 377 | Returns Qunbound if no binding was found (and returns Qnil if a nil | 373 | Return Qunbound if no binding was found (and return Qnil if a nil |
| 378 | binding was found). */ | 374 | binding was found). */ |
| 379 | 375 | ||
| 380 | static Lisp_Object | 376 | static Lisp_Object |
| 381 | access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int autoload) | 377 | access_keymap_1 (Lisp_Object map, Lisp_Object idx, |
| 378 | bool t_ok, bool noinherit, bool autoload) | ||
| 382 | { | 379 | { |
| 383 | /* If idx is a list (some sort of mouse click, perhaps?), | 380 | /* If idx is a list (some sort of mouse click, perhaps?), |
| 384 | the index we want to use is the car of the list, which | 381 | the index we want to use is the car of the list, which |
| @@ -548,7 +545,7 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int | |||
| 548 | 545 | ||
| 549 | Lisp_Object | 546 | Lisp_Object |
| 550 | access_keymap (Lisp_Object map, Lisp_Object idx, | 547 | access_keymap (Lisp_Object map, Lisp_Object idx, |
| 551 | int t_ok, int noinherit, int autoload) | 548 | bool t_ok, bool noinherit, bool autoload) |
| 552 | { | 549 | { |
| 553 | Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload); | 550 | Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload); |
| 554 | return EQ (val, Qunbound) ? Qnil : val; | 551 | return EQ (val, Qunbound) ? Qnil : val; |
| @@ -631,9 +628,10 @@ map_keymap_call (Lisp_Object key, Lisp_Object val, Lisp_Object fun, void *dummy) | |||
| 631 | } | 628 | } |
| 632 | 629 | ||
| 633 | /* Same as map_keymap_internal, but traverses parent keymaps as well. | 630 | /* Same as map_keymap_internal, but traverses parent keymaps as well. |
| 634 | A non-zero AUTOLOAD indicates that autoloaded keymaps should be loaded. */ | 631 | AUTOLOAD indicates that autoloaded keymaps should be loaded. */ |
| 635 | void | 632 | void |
| 636 | map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data, int autoload) | 633 | map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, |
| 634 | void *data, bool autoload) | ||
| 637 | { | 635 | { |
| 638 | struct gcpro gcpro1; | 636 | struct gcpro gcpro1; |
| 639 | GCPRO1 (args); | 637 | GCPRO1 (args); |
| @@ -712,13 +710,13 @@ usage: (map-keymap FUNCTION KEYMAP) */) | |||
| 712 | Also if OBJECT has a menu string as the first element, | 710 | Also if OBJECT has a menu string as the first element, |
| 713 | remove that. Also remove a menu help string as second element. | 711 | remove that. Also remove a menu help string as second element. |
| 714 | 712 | ||
| 715 | If AUTOLOAD is nonzero, load autoloadable keymaps | 713 | If AUTOLOAD, load autoloadable keymaps |
| 716 | that are referred to with indirection. | 714 | that are referred to with indirection. |
| 717 | 715 | ||
| 718 | This can GC because menu_item_eval_property calls Feval. */ | 716 | This can GC because menu_item_eval_property calls Feval. */ |
| 719 | 717 | ||
| 720 | static Lisp_Object | 718 | static Lisp_Object |
| 721 | get_keyelt (Lisp_Object object, int autoload) | 719 | get_keyelt (Lisp_Object object, bool autoload) |
| 722 | { | 720 | { |
| 723 | while (1) | 721 | while (1) |
| 724 | { | 722 | { |
| @@ -956,8 +954,6 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def) | |||
| 956 | return def; | 954 | return def; |
| 957 | } | 955 | } |
| 958 | 956 | ||
| 959 | static Lisp_Object Fcopy_keymap (Lisp_Object); | ||
| 960 | |||
| 961 | static Lisp_Object | 957 | static Lisp_Object |
| 962 | copy_keymap_item (Lisp_Object elt) | 958 | copy_keymap_item (Lisp_Object elt) |
| 963 | { | 959 | { |
| @@ -1117,12 +1113,12 @@ binding is altered. If there is no binding for KEY, the new pair | |||
| 1117 | binding KEY to DEF is added at the front of KEYMAP. */) | 1113 | binding KEY to DEF is added at the front of KEYMAP. */) |
| 1118 | (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) | 1114 | (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) |
| 1119 | { | 1115 | { |
| 1120 | register int idx; | 1116 | ptrdiff_t idx; |
| 1121 | register Lisp_Object c; | 1117 | Lisp_Object c; |
| 1122 | register Lisp_Object cmd; | 1118 | Lisp_Object cmd; |
| 1123 | int metized = 0; | 1119 | bool metized = 0; |
| 1124 | int meta_bit; | 1120 | int meta_bit; |
| 1125 | int length; | 1121 | ptrdiff_t length; |
| 1126 | struct gcpro gcpro1, gcpro2, gcpro3; | 1122 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 1127 | 1123 | ||
| 1128 | GCPRO3 (keymap, key, def); | 1124 | GCPRO3 (keymap, key, def); |
| @@ -1143,7 +1139,7 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1143 | if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0))) | 1139 | if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0))) |
| 1144 | { /* DEF is apparently an XEmacs-style keyboard macro. */ | 1140 | { /* DEF is apparently an XEmacs-style keyboard macro. */ |
| 1145 | Lisp_Object tmp = Fmake_vector (make_number (ASIZE (def)), Qnil); | 1141 | Lisp_Object tmp = Fmake_vector (make_number (ASIZE (def)), Qnil); |
| 1146 | int i = ASIZE (def); | 1142 | ptrdiff_t i = ASIZE (def); |
| 1147 | while (--i >= 0) | 1143 | while (--i >= 0) |
| 1148 | { | 1144 | { |
| 1149 | Lisp_Object defi = AREF (def, i); | 1145 | Lisp_Object defi = AREF (def, i); |
| @@ -1274,11 +1270,11 @@ third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will | |||
| 1274 | recognize the default bindings, just as `read-key-sequence' does. */) | 1270 | recognize the default bindings, just as `read-key-sequence' does. */) |
| 1275 | (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) | 1271 | (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) |
| 1276 | { | 1272 | { |
| 1277 | register int idx; | 1273 | ptrdiff_t idx; |
| 1278 | register Lisp_Object cmd; | 1274 | Lisp_Object cmd; |
| 1279 | register Lisp_Object c; | 1275 | Lisp_Object c; |
| 1280 | int length; | 1276 | ptrdiff_t length; |
| 1281 | int t_ok = !NILP (accept_default); | 1277 | bool t_ok = !NILP (accept_default); |
| 1282 | struct gcpro gcpro1, gcpro2; | 1278 | struct gcpro gcpro1, gcpro2; |
| 1283 | 1279 | ||
| 1284 | GCPRO2 (keymap, key); | 1280 | GCPRO2 (keymap, key); |
| @@ -1480,8 +1476,8 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1480 | 1476 | ||
| 1481 | /* Use malloc here. See the comment above this function. | 1477 | /* Use malloc here. See the comment above this function. |
| 1482 | Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ | 1478 | Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ |
| 1483 | BLOCK_INPUT; | 1479 | block_input (); |
| 1484 | newmodes = (Lisp_Object *) malloc (allocsize); | 1480 | newmodes = malloc (allocsize); |
| 1485 | if (newmodes) | 1481 | if (newmodes) |
| 1486 | { | 1482 | { |
| 1487 | if (cmm_modes) | 1483 | if (cmm_modes) |
| @@ -1493,7 +1489,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1493 | cmm_modes = newmodes; | 1489 | cmm_modes = newmodes; |
| 1494 | } | 1490 | } |
| 1495 | 1491 | ||
| 1496 | newmaps = (Lisp_Object *) malloc (allocsize); | 1492 | newmaps = malloc (allocsize); |
| 1497 | if (newmaps) | 1493 | if (newmaps) |
| 1498 | { | 1494 | { |
| 1499 | if (cmm_maps) | 1495 | if (cmm_maps) |
| @@ -1504,7 +1500,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1504 | } | 1500 | } |
| 1505 | cmm_maps = newmaps; | 1501 | cmm_maps = newmaps; |
| 1506 | } | 1502 | } |
| 1507 | UNBLOCK_INPUT; | 1503 | unblock_input (); |
| 1508 | 1504 | ||
| 1509 | if (newmodes == NULL || newmaps == NULL) | 1505 | if (newmodes == NULL || newmaps == NULL) |
| 1510 | break; | 1506 | break; |
| @@ -1527,6 +1523,19 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1527 | return i; | 1523 | return i; |
| 1528 | } | 1524 | } |
| 1529 | 1525 | ||
| 1526 | /* Return the offset of POSITION, a click position, in the style of | ||
| 1527 | the respective argument of Fkey_binding. */ | ||
| 1528 | static ptrdiff_t | ||
| 1529 | click_position (Lisp_Object position) | ||
| 1530 | { | ||
| 1531 | EMACS_INT pos = (INTEGERP (position) ? XINT (position) | ||
| 1532 | : MARKERP (position) ? marker_position (position) | ||
| 1533 | : PT); | ||
| 1534 | if (! (BEGV <= pos && pos <= ZV)) | ||
| 1535 | args_out_of_range (Fcurrent_buffer (), position); | ||
| 1536 | return pos; | ||
| 1537 | } | ||
| 1538 | |||
| 1530 | DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps, | 1539 | DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps, |
| 1531 | 0, 2, 0, | 1540 | 0, 2, 0, |
| 1532 | doc: /* Return a list of the currently active keymaps. | 1541 | doc: /* Return a list of the currently active keymaps. |
| @@ -1535,7 +1544,7 @@ OLP if non-nil indicates that we should obey `overriding-local-map' and | |||
| 1535 | like in the respective argument of `key-binding'. */) | 1544 | like in the respective argument of `key-binding'. */) |
| 1536 | (Lisp_Object olp, Lisp_Object position) | 1545 | (Lisp_Object olp, Lisp_Object position) |
| 1537 | { | 1546 | { |
| 1538 | int count = SPECPDL_INDEX (); | 1547 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1539 | 1548 | ||
| 1540 | Lisp_Object keymaps = Fcons (current_global_map, Qnil); | 1549 | Lisp_Object keymaps = Fcons (current_global_map, Qnil); |
| 1541 | 1550 | ||
| @@ -1560,9 +1569,7 @@ like in the respective argument of `key-binding'. */) | |||
| 1560 | would not be a problem here, but it is easier to keep | 1569 | would not be a problem here, but it is easier to keep |
| 1561 | things the same. | 1570 | things the same. |
| 1562 | */ | 1571 | */ |
| 1563 | 1572 | record_unwind_current_buffer (); | |
| 1564 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | ||
| 1565 | |||
| 1566 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 1573 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); |
| 1567 | } | 1574 | } |
| 1568 | } | 1575 | } |
| @@ -1582,10 +1589,7 @@ like in the respective argument of `key-binding'. */) | |||
| 1582 | { | 1589 | { |
| 1583 | Lisp_Object *maps; | 1590 | Lisp_Object *maps; |
| 1584 | int nmaps, i; | 1591 | int nmaps, i; |
| 1585 | EMACS_INT pt | 1592 | ptrdiff_t pt = click_position (position); |
| 1586 | = INTEGERP (position) ? XINT (position) | ||
| 1587 | : MARKERP (position) ? marker_position (position) | ||
| 1588 | : PT; | ||
| 1589 | /* This usually returns the buffer's local map, | 1593 | /* This usually returns the buffer's local map, |
| 1590 | but that can be overridden by a `local-map' property. */ | 1594 | but that can be overridden by a `local-map' property. */ |
| 1591 | Lisp_Object local_map = get_local_map (pt, current_buffer, Qlocal_map); | 1595 | Lisp_Object local_map = get_local_map (pt, current_buffer, Qlocal_map); |
| @@ -1847,7 +1851,7 @@ If KEYMAP is nil, that means no local keymap. */) | |||
| 1847 | if (!NILP (keymap)) | 1851 | if (!NILP (keymap)) |
| 1848 | keymap = get_keymap (keymap, 1, 1); | 1852 | keymap = get_keymap (keymap, 1, 1); |
| 1849 | 1853 | ||
| 1850 | BVAR (current_buffer, keymap) = keymap; | 1854 | bset_keymap (current_buffer, keymap); |
| 1851 | 1855 | ||
| 1852 | return Qnil; | 1856 | return Qnil; |
| 1853 | } | 1857 | } |
| @@ -1882,7 +1886,7 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_ | |||
| 1882 | struct accessible_keymaps_data { | 1886 | struct accessible_keymaps_data { |
| 1883 | Lisp_Object maps, tail, thisseq; | 1887 | Lisp_Object maps, tail, thisseq; |
| 1884 | /* Does the current sequence end in the meta-prefix-char? */ | 1888 | /* Does the current sequence end in the meta-prefix-char? */ |
| 1885 | int is_metized; | 1889 | bool is_metized; |
| 1886 | }; | 1890 | }; |
| 1887 | 1891 | ||
| 1888 | static void | 1892 | static void |
| @@ -1893,7 +1897,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void * | |||
| 1893 | Lisp_Object maps = d->maps; | 1897 | Lisp_Object maps = d->maps; |
| 1894 | Lisp_Object tail = d->tail; | 1898 | Lisp_Object tail = d->tail; |
| 1895 | Lisp_Object thisseq = d->thisseq; | 1899 | Lisp_Object thisseq = d->thisseq; |
| 1896 | int is_metized = d->is_metized && INTEGERP (key); | 1900 | bool is_metized = d->is_metized && INTEGERP (key); |
| 1897 | Lisp_Object tem; | 1901 | Lisp_Object tem; |
| 1898 | 1902 | ||
| 1899 | cmd = get_keymap (get_keyelt (cmd, 0), 0, 0); | 1903 | cmd = get_keymap (get_keyelt (cmd, 0), 0, 0); |
| @@ -1904,10 +1908,10 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void * | |||
| 1904 | while (!NILP (tem = Frassq (cmd, maps))) | 1908 | while (!NILP (tem = Frassq (cmd, maps))) |
| 1905 | { | 1909 | { |
| 1906 | Lisp_Object prefix = XCAR (tem); | 1910 | Lisp_Object prefix = XCAR (tem); |
| 1907 | int lim = XINT (Flength (XCAR (tem))); | 1911 | ptrdiff_t lim = XINT (Flength (XCAR (tem))); |
| 1908 | if (lim <= XINT (Flength (thisseq))) | 1912 | if (lim <= XINT (Flength (thisseq))) |
| 1909 | { /* This keymap was already seen with a smaller prefix. */ | 1913 | { /* This keymap was already seen with a smaller prefix. */ |
| 1910 | int i = 0; | 1914 | ptrdiff_t i = 0; |
| 1911 | while (i < lim && EQ (Faref (prefix, make_number (i)), | 1915 | while (i < lim && EQ (Faref (prefix, make_number (i)), |
| 1912 | Faref (thisseq, make_number (i)))) | 1916 | Faref (thisseq, make_number (i)))) |
| 1913 | i++; | 1917 | i++; |
| @@ -1960,7 +1964,7 @@ then the value includes only maps for prefixes that start with PREFIX. */) | |||
| 1960 | (Lisp_Object keymap, Lisp_Object prefix) | 1964 | (Lisp_Object keymap, Lisp_Object prefix) |
| 1961 | { | 1965 | { |
| 1962 | Lisp_Object maps, tail; | 1966 | Lisp_Object maps, tail; |
| 1963 | int prefixlen = XINT (Flength (prefix)); | 1967 | EMACS_INT prefixlen = XFASTINT (Flength (prefix)); |
| 1964 | 1968 | ||
| 1965 | /* no need for gcpro because we don't autoload any keymaps. */ | 1969 | /* no need for gcpro because we don't autoload any keymaps. */ |
| 1966 | 1970 | ||
| @@ -2003,9 +2007,7 @@ then the value includes only maps for prefixes that start with PREFIX. */) | |||
| 2003 | return Qnil; | 2007 | return Qnil; |
| 2004 | } | 2008 | } |
| 2005 | else | 2009 | else |
| 2006 | maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), | 2010 | maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil); |
| 2007 | get_keymap (keymap, 1, 0)), | ||
| 2008 | Qnil); | ||
| 2009 | 2011 | ||
| 2010 | /* For each map in the list maps, | 2012 | /* For each map in the list maps, |
| 2011 | look at any other maps it points to, | 2013 | look at any other maps it points to, |
| @@ -2043,24 +2045,30 @@ static Lisp_Object Qsingle_key_description, Qkey_description; | |||
| 2043 | DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0, | 2045 | DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0, |
| 2044 | doc: /* Return a pretty description of key-sequence KEYS. | 2046 | doc: /* Return a pretty description of key-sequence KEYS. |
| 2045 | Optional arg PREFIX is the sequence of keys leading up to KEYS. | 2047 | Optional arg PREFIX is the sequence of keys leading up to KEYS. |
| 2046 | Control characters turn into "C-foo" sequences, meta into "M-foo", | 2048 | For example, [?\C-x ?l] is converted into the string \"C-x l\". |
| 2047 | spaces are put between sequence elements, etc. */) | 2049 | |
| 2050 | The `kbd' macro is an approximate inverse of this. */) | ||
| 2048 | (Lisp_Object keys, Lisp_Object prefix) | 2051 | (Lisp_Object keys, Lisp_Object prefix) |
| 2049 | { | 2052 | { |
| 2050 | int len = 0; | 2053 | ptrdiff_t len = 0; |
| 2051 | int i, i_byte; | 2054 | EMACS_INT i; |
| 2055 | ptrdiff_t i_byte; | ||
| 2052 | Lisp_Object *args; | 2056 | Lisp_Object *args; |
| 2053 | int size = XINT (Flength (keys)); | 2057 | EMACS_INT size = XINT (Flength (keys)); |
| 2054 | Lisp_Object list; | 2058 | Lisp_Object list; |
| 2055 | Lisp_Object sep = build_string (" "); | 2059 | Lisp_Object sep = build_string (" "); |
| 2056 | Lisp_Object key; | 2060 | Lisp_Object key; |
| 2057 | int add_meta = 0; | 2061 | Lisp_Object result; |
| 2062 | bool add_meta = 0; | ||
| 2063 | USE_SAFE_ALLOCA; | ||
| 2058 | 2064 | ||
| 2059 | if (!NILP (prefix)) | 2065 | if (!NILP (prefix)) |
| 2060 | size += XINT (Flength (prefix)); | 2066 | size += XINT (Flength (prefix)); |
| 2061 | 2067 | ||
| 2062 | /* This has one extra element at the end that we don't pass to Fconcat. */ | 2068 | /* This has one extra element at the end that we don't pass to Fconcat. */ |
| 2063 | args = (Lisp_Object *) alloca (size * 4 * sizeof (Lisp_Object)); | 2069 | if (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size) |
| 2070 | memory_full (SIZE_MAX); | ||
| 2071 | SAFE_ALLOCA_LISP (args, size * 4); | ||
| 2064 | 2072 | ||
| 2065 | /* In effect, this computes | 2073 | /* In effect, this computes |
| 2066 | (mapconcat 'single-key-description keys " ") | 2074 | (mapconcat 'single-key-description keys " ") |
| @@ -2076,11 +2084,14 @@ spaces are put between sequence elements, etc. */) | |||
| 2076 | if (add_meta) | 2084 | if (add_meta) |
| 2077 | { | 2085 | { |
| 2078 | args[len] = Fsingle_key_description (meta_prefix_char, Qnil); | 2086 | args[len] = Fsingle_key_description (meta_prefix_char, Qnil); |
| 2079 | len += 2; | 2087 | result = Fconcat (len + 1, args); |
| 2080 | } | 2088 | } |
| 2081 | else if (len == 0) | 2089 | else if (len == 0) |
| 2082 | return empty_unibyte_string; | 2090 | result = empty_unibyte_string; |
| 2083 | return Fconcat (len - 1, args); | 2091 | else |
| 2092 | result = Fconcat (len - 1, args); | ||
| 2093 | SAFE_FREE (); | ||
| 2094 | return result; | ||
| 2084 | } | 2095 | } |
| 2085 | 2096 | ||
| 2086 | if (STRINGP (list)) | 2097 | if (STRINGP (list)) |
| @@ -2127,7 +2138,7 @@ spaces are put between sequence elements, etc. */) | |||
| 2127 | continue; | 2138 | continue; |
| 2128 | } | 2139 | } |
| 2129 | else | 2140 | else |
| 2130 | XSETINT (key, (XINT (key) | meta_modifier) & ~0x80); | 2141 | XSETINT (key, XINT (key) | meta_modifier); |
| 2131 | add_meta = 0; | 2142 | add_meta = 0; |
| 2132 | } | 2143 | } |
| 2133 | else if (EQ (key, meta_prefix_char)) | 2144 | else if (EQ (key, meta_prefix_char)) |
| @@ -2143,9 +2154,10 @@ spaces are put between sequence elements, etc. */) | |||
| 2143 | 2154 | ||
| 2144 | 2155 | ||
| 2145 | char * | 2156 | char * |
| 2146 | push_key_description (EMACS_INT ch, char *p, int force_multibyte) | 2157 | push_key_description (EMACS_INT ch, char *p) |
| 2147 | { | 2158 | { |
| 2148 | int c, c2; | 2159 | int c, c2; |
| 2160 | bool tab_as_ci; | ||
| 2149 | 2161 | ||
| 2150 | /* Clear all the meaningless bits above the meta bit. */ | 2162 | /* Clear all the meaningless bits above the meta bit. */ |
| 2151 | c = ch & (meta_modifier | ~ - meta_modifier); | 2163 | c = ch & (meta_modifier | ~ - meta_modifier); |
| @@ -2159,6 +2171,8 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte) | |||
| 2159 | return p; | 2171 | return p; |
| 2160 | } | 2172 | } |
| 2161 | 2173 | ||
| 2174 | tab_as_ci = (c2 == '\t' && (c & meta_modifier)); | ||
| 2175 | |||
| 2162 | if (c & alt_modifier) | 2176 | if (c & alt_modifier) |
| 2163 | { | 2177 | { |
| 2164 | *p++ = 'A'; | 2178 | *p++ = 'A'; |
| @@ -2166,7 +2180,8 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte) | |||
| 2166 | c -= alt_modifier; | 2180 | c -= alt_modifier; |
| 2167 | } | 2181 | } |
| 2168 | if ((c & ctrl_modifier) != 0 | 2182 | if ((c & ctrl_modifier) != 0 |
| 2169 | || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))) | 2183 | || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M')) |
| 2184 | || tab_as_ci) | ||
| 2170 | { | 2185 | { |
| 2171 | *p++ = 'C'; | 2186 | *p++ = 'C'; |
| 2172 | *p++ = '-'; | 2187 | *p++ = '-'; |
| @@ -2204,6 +2219,10 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte) | |||
| 2204 | *p++ = 'S'; | 2219 | *p++ = 'S'; |
| 2205 | *p++ = 'C'; | 2220 | *p++ = 'C'; |
| 2206 | } | 2221 | } |
| 2222 | else if (tab_as_ci) | ||
| 2223 | { | ||
| 2224 | *p++ = 'i'; | ||
| 2225 | } | ||
| 2207 | else if (c == '\t') | 2226 | else if (c == '\t') |
| 2208 | { | 2227 | { |
| 2209 | *p++ = 'T'; | 2228 | *p++ = 'T'; |
| @@ -2237,21 +2256,12 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte) | |||
| 2237 | *p++ = 'P'; | 2256 | *p++ = 'P'; |
| 2238 | *p++ = 'C'; | 2257 | *p++ = 'C'; |
| 2239 | } | 2258 | } |
| 2240 | else if (c < 128 | 2259 | else if (c < 128) |
| 2241 | || (NILP (BVAR (current_buffer, enable_multibyte_characters)) | 2260 | *p++ = c; |
| 2242 | && SINGLE_BYTE_CHAR_P (c) | ||
| 2243 | && !force_multibyte)) | ||
| 2244 | { | ||
| 2245 | *p++ = c; | ||
| 2246 | } | ||
| 2247 | else | 2261 | else |
| 2248 | { | 2262 | { |
| 2249 | /* Now we are sure that C is a valid character code. */ | 2263 | /* Now we are sure that C is a valid character code. */ |
| 2250 | if (NILP (BVAR (current_buffer, enable_multibyte_characters)) | 2264 | p += CHAR_STRING (c, (unsigned char *) p); |
| 2251 | && ! force_multibyte) | ||
| 2252 | *p++ = multibyte_char_to_unibyte (c); | ||
| 2253 | else | ||
| 2254 | p += CHAR_STRING (c, (unsigned char *) p); | ||
| 2255 | } | 2265 | } |
| 2256 | 2266 | ||
| 2257 | return p; | 2267 | return p; |
| @@ -2270,25 +2280,29 @@ around function keys and event symbols. */) | |||
| 2270 | if (CONSP (key) && lucid_event_type_list_p (key)) | 2280 | if (CONSP (key) && lucid_event_type_list_p (key)) |
| 2271 | key = Fevent_convert_list (key); | 2281 | key = Fevent_convert_list (key); |
| 2272 | 2282 | ||
| 2283 | if (CONSP (key) && INTEGERP (XCAR (key)) && INTEGERP (XCDR (key))) | ||
| 2284 | /* An interval from a map-char-table. */ | ||
| 2285 | return concat3 (Fsingle_key_description (XCAR (key), no_angles), | ||
| 2286 | build_string (".."), | ||
| 2287 | Fsingle_key_description (XCDR (key), no_angles)); | ||
| 2288 | |||
| 2273 | key = EVENT_HEAD (key); | 2289 | key = EVENT_HEAD (key); |
| 2274 | 2290 | ||
| 2275 | if (INTEGERP (key)) /* Normal character */ | 2291 | if (INTEGERP (key)) /* Normal character. */ |
| 2276 | { | 2292 | { |
| 2277 | char tem[KEY_DESCRIPTION_SIZE], *p; | 2293 | char tem[KEY_DESCRIPTION_SIZE]; |
| 2278 | 2294 | char *p = push_key_description (XINT (key), tem); | |
| 2279 | p = push_key_description (XINT (key), tem, 1); | ||
| 2280 | *p = 0; | 2295 | *p = 0; |
| 2281 | return make_specified_string (tem, -1, p - tem, 1); | 2296 | return make_specified_string (tem, -1, p - tem, 1); |
| 2282 | } | 2297 | } |
| 2283 | else if (SYMBOLP (key)) /* Function key or event-symbol */ | 2298 | else if (SYMBOLP (key)) /* Function key or event-symbol. */ |
| 2284 | { | 2299 | { |
| 2285 | if (NILP (no_angles)) | 2300 | if (NILP (no_angles)) |
| 2286 | { | 2301 | { |
| 2287 | char *buffer; | ||
| 2288 | Lisp_Object result; | 2302 | Lisp_Object result; |
| 2289 | USE_SAFE_ALLOCA; | 2303 | USE_SAFE_ALLOCA; |
| 2290 | SAFE_ALLOCA (buffer, char *, | 2304 | char *buffer = SAFE_ALLOCA (sizeof "<>" |
| 2291 | sizeof "<>" + SBYTES (SYMBOL_NAME (key))); | 2305 | + SBYTES (SYMBOL_NAME (key))); |
| 2292 | esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); | 2306 | esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); |
| 2293 | result = build_string (buffer); | 2307 | result = build_string (buffer); |
| 2294 | SAFE_FREE (); | 2308 | SAFE_FREE (); |
| @@ -2343,7 +2357,7 @@ See Info node `(elisp)Describing Characters' for examples. */) | |||
| 2343 | char str[6]; | 2357 | char str[6]; |
| 2344 | int c; | 2358 | int c; |
| 2345 | 2359 | ||
| 2346 | CHECK_NUMBER (character); | 2360 | CHECK_CHARACTER (character); |
| 2347 | 2361 | ||
| 2348 | c = XINT (character); | 2362 | c = XINT (character); |
| 2349 | if (!ASCII_CHAR_P (c)) | 2363 | if (!ASCII_CHAR_P (c)) |
| @@ -2366,8 +2380,8 @@ static int where_is_preferred_modifier; | |||
| 2366 | static int | 2380 | static int |
| 2367 | preferred_sequence_p (Lisp_Object seq) | 2381 | preferred_sequence_p (Lisp_Object seq) |
| 2368 | { | 2382 | { |
| 2369 | int i; | 2383 | EMACS_INT i; |
| 2370 | int len = XINT (Flength (seq)); | 2384 | EMACS_INT len = XFASTINT (Flength (seq)); |
| 2371 | int result = 1; | 2385 | int result = 1; |
| 2372 | 2386 | ||
| 2373 | for (i = 0; i < len; i++) | 2387 | for (i = 0; i < len; i++) |
| @@ -2405,7 +2419,7 @@ static void where_is_internal_1 (Lisp_Object key, Lisp_Object binding, | |||
| 2405 | 2419 | ||
| 2406 | static Lisp_Object | 2420 | static Lisp_Object |
| 2407 | shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag, | 2421 | shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag, |
| 2408 | int remap) | 2422 | bool remap) |
| 2409 | { | 2423 | { |
| 2410 | Lisp_Object tail, value; | 2424 | Lisp_Object tail, value; |
| 2411 | 2425 | ||
| @@ -2437,7 +2451,7 @@ static Lisp_Object Vmouse_events; | |||
| 2437 | 2451 | ||
| 2438 | struct where_is_internal_data { | 2452 | struct where_is_internal_data { |
| 2439 | Lisp_Object definition, this, last; | 2453 | Lisp_Object definition, this, last; |
| 2440 | int last_is_meta, noindirect; | 2454 | bool last_is_meta, noindirect; |
| 2441 | Lisp_Object sequences; | 2455 | Lisp_Object sequences; |
| 2442 | }; | 2456 | }; |
| 2443 | 2457 | ||
| @@ -2450,7 +2464,7 @@ struct where_is_internal_data { | |||
| 2450 | 2464 | ||
| 2451 | static Lisp_Object | 2465 | static Lisp_Object |
| 2452 | where_is_internal (Lisp_Object definition, Lisp_Object keymaps, | 2466 | where_is_internal (Lisp_Object definition, Lisp_Object keymaps, |
| 2453 | int noindirect, int nomenus) | 2467 | bool noindirect, bool nomenus) |
| 2454 | { | 2468 | { |
| 2455 | Lisp_Object maps = Qnil; | 2469 | Lisp_Object maps = Qnil; |
| 2456 | Lisp_Object found; | 2470 | Lisp_Object found; |
| @@ -2499,7 +2513,7 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps, | |||
| 2499 | [M-CHAR] sequences, check if last character of the sequence | 2513 | [M-CHAR] sequences, check if last character of the sequence |
| 2500 | is the meta-prefix char. */ | 2514 | is the meta-prefix char. */ |
| 2501 | Lisp_Object last; | 2515 | Lisp_Object last; |
| 2502 | int last_is_meta; | 2516 | bool last_is_meta; |
| 2503 | 2517 | ||
| 2504 | this = Fcar (XCAR (maps)); | 2518 | this = Fcar (XCAR (maps)); |
| 2505 | map = Fcdr (XCAR (maps)); | 2519 | map = Fcdr (XCAR (maps)); |
| @@ -2546,7 +2560,8 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps, | |||
| 2546 | DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, | 2560 | DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, |
| 2547 | doc: /* Return list of keys that invoke DEFINITION. | 2561 | doc: /* Return list of keys that invoke DEFINITION. |
| 2548 | If KEYMAP is a keymap, search only KEYMAP and the global keymap. | 2562 | If KEYMAP is a keymap, search only KEYMAP and the global keymap. |
| 2549 | If KEYMAP is nil, search all the currently active keymaps. | 2563 | If KEYMAP is nil, search all the currently active keymaps, except |
| 2564 | for `overriding-local-map' (which is ignored). | ||
| 2550 | If KEYMAP is a list of keymaps, search only those keymaps. | 2565 | If KEYMAP is a list of keymaps, search only those keymaps. |
| 2551 | 2566 | ||
| 2552 | If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found, | 2567 | If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found, |
| @@ -2561,9 +2576,17 @@ If optional 4th arg NOINDIRECT is non-nil, don't follow indirections | |||
| 2561 | to other keymaps or slots. This makes it possible to search for an | 2576 | to other keymaps or slots. This makes it possible to search for an |
| 2562 | indirect definition itself. | 2577 | indirect definition itself. |
| 2563 | 2578 | ||
| 2564 | If optional 5th arg NO-REMAP is non-nil, don't search for key sequences | 2579 | The optional 5th arg NO-REMAP alters how command remapping is handled: |
| 2565 | that invoke a command which is remapped to DEFINITION, but include the | 2580 | |
| 2566 | remapped command in the returned list. */) | 2581 | - If another command OTHER-COMMAND is remapped to DEFINITION, normally |
| 2582 | search for the bindings of OTHER-COMMAND and include them in the | ||
| 2583 | returned list. But if NO-REMAP is non-nil, include the vector | ||
| 2584 | [remap OTHER-COMMAND] in the returned list instead, without | ||
| 2585 | searching for those other bindings. | ||
| 2586 | |||
| 2587 | - If DEFINITION is remapped to OTHER-COMMAND, normally return the | ||
| 2588 | bindings for OTHER-COMMAND. But if NO-REMAP is non-nil, return the | ||
| 2589 | bindings for DEFINITION instead, ignoring its remapping. */) | ||
| 2567 | (Lisp_Object definition, Lisp_Object keymap, Lisp_Object firstonly, Lisp_Object noindirect, Lisp_Object no_remap) | 2590 | (Lisp_Object definition, Lisp_Object keymap, Lisp_Object firstonly, Lisp_Object noindirect, Lisp_Object no_remap) |
| 2568 | { | 2591 | { |
| 2569 | /* The keymaps in which to search. */ | 2592 | /* The keymaps in which to search. */ |
| @@ -2573,7 +2596,7 @@ remapped command in the returned list. */) | |||
| 2573 | /* Actually relevant bindings. */ | 2596 | /* Actually relevant bindings. */ |
| 2574 | Lisp_Object found = Qnil; | 2597 | Lisp_Object found = Qnil; |
| 2575 | /* 1 means ignore all menu bindings entirely. */ | 2598 | /* 1 means ignore all menu bindings entirely. */ |
| 2576 | int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); | 2599 | bool nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); |
| 2577 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 2600 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 2578 | /* List of sequences found via remapping. Keep them in a separate | 2601 | /* List of sequences found via remapping. Keep them in a separate |
| 2579 | variable, so as to push them later, since we prefer | 2602 | variable, so as to push them later, since we prefer |
| @@ -2582,7 +2605,7 @@ remapped command in the returned list. */) | |||
| 2582 | /* Whether or not we're handling remapped sequences. This is needed | 2605 | /* Whether or not we're handling remapped sequences. This is needed |
| 2583 | because remapping is not done recursively by Fcommand_remapping: you | 2606 | because remapping is not done recursively by Fcommand_remapping: you |
| 2584 | can't remap a remapped command. */ | 2607 | can't remap a remapped command. */ |
| 2585 | int remapped = 0; | 2608 | bool remapped = 0; |
| 2586 | Lisp_Object tem = Qnil; | 2609 | Lisp_Object tem = Qnil; |
| 2587 | 2610 | ||
| 2588 | /* Refresh the C version of the modifier preference. */ | 2611 | /* Refresh the C version of the modifier preference. */ |
| @@ -2734,10 +2757,10 @@ where_is_internal_1 (Lisp_Object key, Lisp_Object binding, Lisp_Object args, voi | |||
| 2734 | { | 2757 | { |
| 2735 | struct where_is_internal_data *d = data; /* Cast! */ | 2758 | struct where_is_internal_data *d = data; /* Cast! */ |
| 2736 | Lisp_Object definition = d->definition; | 2759 | Lisp_Object definition = d->definition; |
| 2737 | int noindirect = d->noindirect; | 2760 | bool noindirect = d->noindirect; |
| 2738 | Lisp_Object this = d->this; | 2761 | Lisp_Object this = d->this; |
| 2739 | Lisp_Object last = d->last; | 2762 | Lisp_Object last = d->last; |
| 2740 | int last_is_meta = d->last_is_meta; | 2763 | bool last_is_meta = d->last_is_meta; |
| 2741 | Lisp_Object sequence; | 2764 | Lisp_Object sequence; |
| 2742 | 2765 | ||
| 2743 | /* Search through indirections unless that's not wanted. */ | 2766 | /* Search through indirections unless that's not wanted. */ |
| @@ -2788,8 +2811,8 @@ The optional argument MENUS, if non-nil, says to mention menu bindings. | |||
| 2788 | (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) | 2811 | (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) |
| 2789 | { | 2812 | { |
| 2790 | Lisp_Object outbuf, shadow; | 2813 | Lisp_Object outbuf, shadow; |
| 2791 | int nomenu = NILP (menus); | 2814 | bool nomenu = NILP (menus); |
| 2792 | register Lisp_Object start1; | 2815 | Lisp_Object start1; |
| 2793 | struct gcpro gcpro1; | 2816 | struct gcpro gcpro1; |
| 2794 | 2817 | ||
| 2795 | const char *alternate_heading | 2818 | const char *alternate_heading |
| @@ -2824,10 +2847,10 @@ You type Translation\n\ | |||
| 2824 | alternate_heading = 0; | 2847 | alternate_heading = 0; |
| 2825 | } | 2848 | } |
| 2826 | 2849 | ||
| 2827 | bufend = push_key_description (translate[c], buf, 1); | 2850 | bufend = push_key_description (translate[c], buf); |
| 2828 | insert (buf, bufend - buf); | 2851 | insert (buf, bufend - buf); |
| 2829 | Findent_to (make_number (16), make_number (1)); | 2852 | Findent_to (make_number (16), make_number (1)); |
| 2830 | bufend = push_key_description (c, buf, 1); | 2853 | bufend = push_key_description (c, buf); |
| 2831 | insert (buf, bufend - buf); | 2854 | insert (buf, bufend - buf); |
| 2832 | 2855 | ||
| 2833 | insert ("\n", 1); | 2856 | insert ("\n", 1); |
| @@ -2890,9 +2913,9 @@ You type Translation\n\ | |||
| 2890 | char *title, *p; | 2913 | char *title, *p; |
| 2891 | 2914 | ||
| 2892 | if (!SYMBOLP (modes[i])) | 2915 | if (!SYMBOLP (modes[i])) |
| 2893 | abort (); | 2916 | emacs_abort (); |
| 2894 | 2917 | ||
| 2895 | p = title = (char *) alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); | 2918 | p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); |
| 2896 | *p++ = '\f'; | 2919 | *p++ = '\f'; |
| 2897 | *p++ = '\n'; | 2920 | *p++ = '\n'; |
| 2898 | *p++ = '`'; | 2921 | *p++ = '`'; |
| @@ -2944,34 +2967,34 @@ You type Translation\n\ | |||
| 2944 | 2967 | ||
| 2945 | /* Insert a description of the key bindings in STARTMAP, | 2968 | /* Insert a description of the key bindings in STARTMAP, |
| 2946 | followed by those of all maps reachable through STARTMAP. | 2969 | followed by those of all maps reachable through STARTMAP. |
| 2947 | If PARTIAL is nonzero, omit certain "uninteresting" commands | 2970 | If PARTIAL, omit certain "uninteresting" commands |
| 2948 | (such as `undefined'). | 2971 | (such as `undefined'). |
| 2949 | If SHADOW is non-nil, it is a list of maps; | 2972 | If SHADOW is non-nil, it is a list of maps; |
| 2950 | don't mention keys which would be shadowed by any of them. | 2973 | don't mention keys which would be shadowed by any of them. |
| 2951 | PREFIX, if non-nil, says mention only keys that start with PREFIX. | 2974 | PREFIX, if non-nil, says mention only keys that start with PREFIX. |
| 2952 | TITLE, if not 0, is a string to insert at the beginning. | 2975 | TITLE, if not 0, is a string to insert at the beginning. |
| 2953 | TITLE should not end with a colon or a newline; we supply that. | 2976 | TITLE should not end with a colon or a newline; we supply that. |
| 2954 | If NOMENU is not 0, then omit menu-bar commands. | 2977 | If NOMENU, then omit menu-bar commands. |
| 2955 | 2978 | ||
| 2956 | If TRANSL is nonzero, the definitions are actually key translations | 2979 | If TRANSL, the definitions are actually key translations |
| 2957 | so print strings and vectors differently. | 2980 | so print strings and vectors differently. |
| 2958 | 2981 | ||
| 2959 | If ALWAYS_TITLE is nonzero, print the title even if there are no maps | 2982 | If ALWAYS_TITLE, print the title even if there are no maps |
| 2960 | to look through. | 2983 | to look through. |
| 2961 | 2984 | ||
| 2962 | If MENTION_SHADOW is nonzero, then when something is shadowed by SHADOW, | 2985 | If MENTION_SHADOW, then when something is shadowed by SHADOW, |
| 2963 | don't omit it; instead, mention it but say it is shadowed. | 2986 | don't omit it; instead, mention it but say it is shadowed. |
| 2964 | 2987 | ||
| 2965 | Return whether something was inserted or not. */ | 2988 | Any inserted text ends in two newlines (used by `help-make-xrefs'). */ |
| 2966 | 2989 | ||
| 2967 | int | 2990 | void |
| 2968 | describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, | 2991 | describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow, |
| 2969 | Lisp_Object prefix, const char *title, int nomenu, int transl, | 2992 | Lisp_Object prefix, const char *title, bool nomenu, |
| 2970 | int always_title, int mention_shadow) | 2993 | bool transl, bool always_title, bool mention_shadow) |
| 2971 | { | 2994 | { |
| 2972 | Lisp_Object maps, orig_maps, seen, sub_shadows; | 2995 | Lisp_Object maps, orig_maps, seen, sub_shadows; |
| 2973 | struct gcpro gcpro1, gcpro2, gcpro3; | 2996 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 2974 | int something = 0; | 2997 | bool something = 0; |
| 2975 | const char *key_heading | 2998 | const char *key_heading |
| 2976 | = "\ | 2999 | = "\ |
| 2977 | key binding\n\ | 3000 | key binding\n\ |
| @@ -3074,8 +3097,10 @@ key binding\n\ | |||
| 3074 | skip: ; | 3097 | skip: ; |
| 3075 | } | 3098 | } |
| 3076 | 3099 | ||
| 3100 | if (something) | ||
| 3101 | insert_string ("\n"); | ||
| 3102 | |||
| 3077 | UNGCPRO; | 3103 | UNGCPRO; |
| 3078 | return something; | ||
| 3079 | } | 3104 | } |
| 3080 | 3105 | ||
| 3081 | static int previous_description_column; | 3106 | static int previous_description_column; |
| @@ -3084,7 +3109,7 @@ static void | |||
| 3084 | describe_command (Lisp_Object definition, Lisp_Object args) | 3109 | describe_command (Lisp_Object definition, Lisp_Object args) |
| 3085 | { | 3110 | { |
| 3086 | register Lisp_Object tem1; | 3111 | register Lisp_Object tem1; |
| 3087 | EMACS_INT column = current_column (); | 3112 | ptrdiff_t column = current_column (); |
| 3088 | int description_column; | 3113 | int description_column; |
| 3089 | 3114 | ||
| 3090 | /* If column 16 is no good, go to col 32; | 3115 | /* If column 16 is no good, go to col 32; |
| @@ -3144,7 +3169,12 @@ describe_translation (Lisp_Object definition, Lisp_Object args) | |||
| 3144 | into an array of `struct describe_map_elt', | 3169 | into an array of `struct describe_map_elt', |
| 3145 | then sorts them by the events. */ | 3170 | then sorts them by the events. */ |
| 3146 | 3171 | ||
| 3147 | struct describe_map_elt { Lisp_Object event; Lisp_Object definition; int shadowed; }; | 3172 | struct describe_map_elt |
| 3173 | { | ||
| 3174 | Lisp_Object event; | ||
| 3175 | Lisp_Object definition; | ||
| 3176 | bool shadowed; | ||
| 3177 | }; | ||
| 3148 | 3178 | ||
| 3149 | /* qsort comparison function for sorting `struct describe_map_elt' by | 3179 | /* qsort comparison function for sorting `struct describe_map_elt' by |
| 3150 | the event field. */ | 3180 | the event field. */ |
| @@ -3174,14 +3204,14 @@ describe_map_compare (const void *aa, const void *bb) | |||
| 3174 | static void | 3204 | static void |
| 3175 | describe_map (Lisp_Object map, Lisp_Object prefix, | 3205 | describe_map (Lisp_Object map, Lisp_Object prefix, |
| 3176 | void (*elt_describer) (Lisp_Object, Lisp_Object), | 3206 | void (*elt_describer) (Lisp_Object, Lisp_Object), |
| 3177 | int partial, Lisp_Object shadow, | 3207 | bool partial, Lisp_Object shadow, |
| 3178 | Lisp_Object *seen, int nomenu, int mention_shadow) | 3208 | Lisp_Object *seen, bool nomenu, bool mention_shadow) |
| 3179 | { | 3209 | { |
| 3180 | Lisp_Object tail, definition, event; | 3210 | Lisp_Object tail, definition, event; |
| 3181 | Lisp_Object tem; | 3211 | Lisp_Object tem; |
| 3182 | Lisp_Object suppress; | 3212 | Lisp_Object suppress; |
| 3183 | Lisp_Object kludge; | 3213 | Lisp_Object kludge; |
| 3184 | int first = 1; | 3214 | bool first = 1; |
| 3185 | struct gcpro gcpro1, gcpro2, gcpro3; | 3215 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 3186 | 3216 | ||
| 3187 | /* These accumulate the values from sparse keymap bindings, | 3217 | /* These accumulate the values from sparse keymap bindings, |
| @@ -3223,7 +3253,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix, | |||
| 3223 | 1, mention_shadow); | 3253 | 1, mention_shadow); |
| 3224 | else if (CONSP (XCAR (tail))) | 3254 | else if (CONSP (XCAR (tail))) |
| 3225 | { | 3255 | { |
| 3226 | int this_shadowed = 0; | 3256 | bool this_shadowed = 0; |
| 3227 | 3257 | ||
| 3228 | event = XCAR (XCAR (tail)); | 3258 | event = XCAR (XCAR (tail)); |
| 3229 | 3259 | ||
| @@ -3367,7 +3397,7 @@ This is text showing the elements of vector matched against indices. | |||
| 3367 | DESCRIBER is the output function used; nil means use `princ'. */) | 3397 | DESCRIBER is the output function used; nil means use `princ'. */) |
| 3368 | (Lisp_Object vector, Lisp_Object describer) | 3398 | (Lisp_Object vector, Lisp_Object describer) |
| 3369 | { | 3399 | { |
| 3370 | int count = SPECPDL_INDEX (); | 3400 | ptrdiff_t count = SPECPDL_INDEX (); |
| 3371 | if (NILP (describer)) | 3401 | if (NILP (describer)) |
| 3372 | describer = intern ("princ"); | 3402 | describer = intern ("princ"); |
| 3373 | specbind (Qstandard_output, Fcurrent_buffer ()); | 3403 | specbind (Qstandard_output, Fcurrent_buffer ()); |
| @@ -3393,7 +3423,7 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3393 | of bytes that lead to the character set or portion of a character | 3423 | of bytes that lead to the character set or portion of a character |
| 3394 | set described by this chartable. | 3424 | set described by this chartable. |
| 3395 | 3425 | ||
| 3396 | If PARTIAL is nonzero, it means do not mention suppressed commands | 3426 | If PARTIAL, it means do not mention suppressed commands |
| 3397 | (that assumes the vector is in a keymap). | 3427 | (that assumes the vector is in a keymap). |
| 3398 | 3428 | ||
| 3399 | SHADOW is a list of keymaps that shadow this map. | 3429 | SHADOW is a list of keymaps that shadow this map. |
| @@ -3413,8 +3443,8 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3413 | static void | 3443 | static void |
| 3414 | describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | 3444 | describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, |
| 3415 | void (*elt_describer) (Lisp_Object, Lisp_Object), | 3445 | void (*elt_describer) (Lisp_Object, Lisp_Object), |
| 3416 | int partial, Lisp_Object shadow, Lisp_Object entire_map, | 3446 | bool partial, Lisp_Object shadow, Lisp_Object entire_map, |
| 3417 | int keymap_p, int mention_shadow) | 3447 | bool keymap_p, bool mention_shadow) |
| 3418 | { | 3448 | { |
| 3419 | Lisp_Object definition; | 3449 | Lisp_Object definition; |
| 3420 | Lisp_Object tem2; | 3450 | Lisp_Object tem2; |
| @@ -3422,7 +3452,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | |||
| 3422 | int i; | 3452 | int i; |
| 3423 | Lisp_Object suppress; | 3453 | Lisp_Object suppress; |
| 3424 | Lisp_Object kludge; | 3454 | Lisp_Object kludge; |
| 3425 | int first = 1; | 3455 | bool first = 1; |
| 3426 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 3456 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 3427 | /* Range of elements to be handled. */ | 3457 | /* Range of elements to be handled. */ |
| 3428 | int from, to, stop; | 3458 | int from, to, stop; |
| @@ -3462,7 +3492,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | |||
| 3462 | 3492 | ||
| 3463 | for (i = from; ; i++) | 3493 | for (i = from; ; i++) |
| 3464 | { | 3494 | { |
| 3465 | int this_shadowed = 0; | 3495 | bool this_shadowed = 0; |
| 3466 | int range_beg, range_end; | 3496 | int range_beg, range_end; |
| 3467 | Lisp_Object val; | 3497 | Lisp_Object val; |
| 3468 | 3498 | ||
| @@ -3671,13 +3701,12 @@ syms_of_keymap (void) | |||
| 3671 | Fset (intern_c_string ("ctl-x-map"), control_x_map); | 3701 | Fset (intern_c_string ("ctl-x-map"), control_x_map); |
| 3672 | Ffset (intern_c_string ("Control-X-prefix"), control_x_map); | 3702 | Ffset (intern_c_string ("Control-X-prefix"), control_x_map); |
| 3673 | 3703 | ||
| 3674 | exclude_keys | 3704 | exclude_keys = listn (CONSTYPE_PURE, 5, |
| 3675 | = pure_cons (pure_cons (make_pure_c_string ("DEL"), make_pure_c_string ("\\d")), | 3705 | pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), |
| 3676 | pure_cons (pure_cons (make_pure_c_string ("TAB"), make_pure_c_string ("\\t")), | 3706 | pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), |
| 3677 | pure_cons (pure_cons (make_pure_c_string ("RET"), make_pure_c_string ("\\r")), | 3707 | pure_cons (build_pure_c_string ("RET"), build_pure_c_string ("\\r")), |
| 3678 | pure_cons (pure_cons (make_pure_c_string ("ESC"), make_pure_c_string ("\\e")), | 3708 | pure_cons (build_pure_c_string ("ESC"), build_pure_c_string ("\\e")), |
| 3679 | pure_cons (pure_cons (make_pure_c_string ("SPC"), make_pure_c_string (" ")), | 3709 | pure_cons (build_pure_c_string ("SPC"), build_pure_c_string (" "))); |
| 3680 | Qnil))))); | ||
| 3681 | staticpro (&exclude_keys); | 3710 | staticpro (&exclude_keys); |
| 3682 | 3711 | ||
| 3683 | DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands, | 3712 | DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands, |
| @@ -3730,16 +3759,16 @@ be preferred. */); | |||
| 3730 | where_is_preferred_modifier = 0; | 3759 | where_is_preferred_modifier = 0; |
| 3731 | 3760 | ||
| 3732 | staticpro (&Vmouse_events); | 3761 | staticpro (&Vmouse_events); |
| 3733 | Vmouse_events = pure_cons (intern_c_string ("menu-bar"), | 3762 | Vmouse_events = listn (CONSTYPE_PURE, 9, |
| 3734 | pure_cons (intern_c_string ("tool-bar"), | 3763 | intern_c_string ("menu-bar"), |
| 3735 | pure_cons (intern_c_string ("header-line"), | 3764 | intern_c_string ("tool-bar"), |
| 3736 | pure_cons (intern_c_string ("mode-line"), | 3765 | intern_c_string ("header-line"), |
| 3737 | pure_cons (intern_c_string ("mouse-1"), | 3766 | intern_c_string ("mode-line"), |
| 3738 | pure_cons (intern_c_string ("mouse-2"), | 3767 | intern_c_string ("mouse-1"), |
| 3739 | pure_cons (intern_c_string ("mouse-3"), | 3768 | intern_c_string ("mouse-2"), |
| 3740 | pure_cons (intern_c_string ("mouse-4"), | 3769 | intern_c_string ("mouse-3"), |
| 3741 | pure_cons (intern_c_string ("mouse-5"), | 3770 | intern_c_string ("mouse-4"), |
| 3742 | Qnil))))))))); | 3771 | intern_c_string ("mouse-5")); |
| 3743 | 3772 | ||
| 3744 | DEFSYM (Qsingle_key_description, "single-key-description"); | 3773 | DEFSYM (Qsingle_key_description, "single-key-description"); |
| 3745 | DEFSYM (Qkey_description, "key-description"); | 3774 | DEFSYM (Qkey_description, "key-description"); |