aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c358
1 files changed, 180 insertions, 178 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 2f5558c171f..7a18cd5d983 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1,5 +1,6 @@
1/* Manipulation of keymaps 1/* Manipulation of keymaps
2 Copyright (C) 1985-1988, 1993-1995, 1998-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1993-1995, 1998-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -40,11 +41,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40 41
41#include <config.h> 42#include <config.h>
42#include <stdio.h> 43#include <stdio.h>
43#include <setjmp.h> 44
44#include "lisp.h" 45#include "lisp.h"
45#include "commands.h" 46#include "commands.h"
46#include "buffer.h"
47#include "character.h" 47#include "character.h"
48#include "buffer.h"
48#include "charset.h" 49#include "charset.h"
49#include "keyboard.h" 50#include "keyboard.h"
50#include "frame.h" 51#include "frame.h"
@@ -55,28 +56,28 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
55#include "keymap.h" 56#include "keymap.h"
56#include "window.h" 57#include "window.h"
57 58
58/* Actually allocate storage for these variables */ 59/* Actually allocate storage for these variables. */
59 60
60Lisp_Object current_global_map; /* Current global keymap */ 61Lisp_Object current_global_map; /* Current global keymap. */
61 62
62Lisp_Object global_map; /* default global key bindings */ 63Lisp_Object global_map; /* Default global key bindings. */
63 64
64Lisp_Object meta_map; /* The keymap used for globally bound 65Lisp_Object meta_map; /* The keymap used for globally bound
65 ESC-prefixed default commands */ 66 ESC-prefixed default commands. */
66 67
67Lisp_Object control_x_map; /* The keymap used for globally bound 68Lisp_Object control_x_map; /* The keymap used for globally bound
68 C-x-prefixed default commands */ 69 C-x-prefixed default commands. */
69 70
70 /* The keymap used by the minibuf for local 71 /* The keymap used by the minibuf for local
71 bindings when spaces are allowed in the 72 bindings when spaces are allowed in the
72 minibuf */ 73 minibuf. */
73 74
74 /* The keymap used by the minibuf for local 75 /* The keymap used by the minibuf for local
75 bindings when spaces are not encouraged 76 bindings when spaces are not encouraged
76 in the minibuf */ 77 in the minibuf. */
77 78
78/* keymap used for minibuffers when doing completion */ 79/* Keymap used for minibuffers when doing completion. */
79/* keymap used for minibuffers when doing completion and require a match */ 80/* Keymap used for minibuffers when doing completion and require a match. */
80static Lisp_Object Qkeymapp, Qnon_ascii; 81static Lisp_Object Qkeymapp, Qnon_ascii;
81Lisp_Object Qkeymap, Qmenu_item, Qremap; 82Lisp_Object Qkeymap, Qmenu_item, Qremap;
82static Lisp_Object QCadvertised_binding; 83static Lisp_Object QCadvertised_binding;
@@ -92,7 +93,6 @@ static Lisp_Object where_is_cache;
92/* Which keymaps are reverse-stored in the cache. */ 93/* Which keymaps are reverse-stored in the cache. */
93static Lisp_Object where_is_cache_keymaps; 94static Lisp_Object where_is_cache_keymaps;
94 95
95static Lisp_Object Flookup_key (Lisp_Object, Lisp_Object, Lisp_Object);
96static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); 96static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object);
97 97
98static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); 98static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object);
@@ -100,12 +100,18 @@ static void describe_command (Lisp_Object, Lisp_Object);
100static void describe_translation (Lisp_Object, Lisp_Object); 100static void describe_translation (Lisp_Object, Lisp_Object);
101static void describe_map (Lisp_Object, Lisp_Object, 101static void describe_map (Lisp_Object, Lisp_Object,
102 void (*) (Lisp_Object, Lisp_Object), 102 void (*) (Lisp_Object, Lisp_Object),
103 int, Lisp_Object, Lisp_Object*, int, int); 103 bool, Lisp_Object, Lisp_Object*, bool, bool);
104static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, 104static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object,
105 void (*) (Lisp_Object, Lisp_Object), int, 105 void (*) (Lisp_Object, Lisp_Object), bool,
106 Lisp_Object, Lisp_Object, int, int); 106 Lisp_Object, Lisp_Object, bool, bool);
107static void silly_event_symbol_error (Lisp_Object); 107static void silly_event_symbol_error (Lisp_Object);
108static Lisp_Object get_keyelt (Lisp_Object, int); 108static Lisp_Object get_keyelt (Lisp_Object, bool);
109
110static void
111CHECK_VECTOR_OR_CHAR_TABLE (Lisp_Object x)
112{
113 CHECK_TYPE (VECTORP (x) || CHAR_TABLE_P (x), Qvector_or_char_table_p, x);
114}
109 115
110/* Keymap object support - constructors and predicates. */ 116/* Keymap object support - constructors and predicates. */
111 117
@@ -123,7 +129,7 @@ in case you use it as a menu with `x-popup-menu'. */)
123{ 129{
124 Lisp_Object tail; 130 Lisp_Object tail;
125 if (!NILP (string)) 131 if (!NILP (string))
126 tail = Fcons (string, Qnil); 132 tail = list1 (string);
127 else 133 else
128 tail = Qnil; 134 tail = Qnil;
129 return Fcons (Qkeymap, 135 return Fcons (Qkeymap,
@@ -145,9 +151,9 @@ in case you use it as a menu with `x-popup-menu'. */)
145 { 151 {
146 if (!NILP (Vpurify_flag)) 152 if (!NILP (Vpurify_flag))
147 string = Fpurecopy (string); 153 string = Fpurecopy (string);
148 return Fcons (Qkeymap, Fcons (string, Qnil)); 154 return list2 (Qkeymap, string);
149 } 155 }
150 return Fcons (Qkeymap, Qnil); 156 return list1 (Qkeymap);
151} 157}
152 158
153/* This function is used for installing the standard key bindings 159/* This function is used for installing the standard key bindings
@@ -208,15 +214,12 @@ when reading a key-sequence to be looked-up in this keymap. */)
208/* Check that OBJECT is a keymap (after dereferencing through any 214/* Check that OBJECT is a keymap (after dereferencing through any
209 symbols). If it is, return it. 215 symbols). If it is, return it.
210 216
211 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value 217 If AUTOLOAD and if OBJECT is a symbol whose function value
212 is an autoload form, do the autoload and try again. 218 is an autoload form, do the autoload and try again.
213 If AUTOLOAD is nonzero, callers must assume GC is possible. 219 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 220
218 ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap. 221 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, 222 If ERROR_IF_NOT_KEYMAP, signal an error; otherwise,
220 just return Qnil. 223 just return Qnil.
221 224
222 Note that most of the time, we don't want to pursue autoloads. 225 Note that most of the time, we don't want to pursue autoloads.
@@ -225,11 +228,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 228 but it seems to me that only read_key_sequence, Flookup_key, and
226 Fdefine_key should cause keymaps to be autoloaded. 229 Fdefine_key should cause keymaps to be autoloaded.
227 230
228 This function can GC when AUTOLOAD is non-zero, because it calls 231 This function can GC when AUTOLOAD is true, because it calls
229 do_autoload which can GC. */ 232 Fautoload_do_load which can GC. */
230 233
231Lisp_Object 234Lisp_Object
232get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) 235get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload)
233{ 236{
234 Lisp_Object tem; 237 Lisp_Object tem;
235 238
@@ -260,7 +263,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload)
260 struct gcpro gcpro1, gcpro2; 263 struct gcpro gcpro1, gcpro2;
261 264
262 GCPRO2 (tem, object); 265 GCPRO2 (tem, object);
263 do_autoload (tem, object); 266 Fautoload_do_load (tem, object, Qnil);
264 UNGCPRO; 267 UNGCPRO;
265 268
266 goto autoload_retry; 269 goto autoload_retry;
@@ -281,7 +284,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload)
281 We assume that KEYMAP is a valid keymap. */ 284 We assume that KEYMAP is a valid keymap. */
282 285
283static Lisp_Object 286static Lisp_Object
284keymap_parent (Lisp_Object keymap, int autoload) 287keymap_parent (Lisp_Object keymap, bool autoload)
285{ 288{
286 Lisp_Object list; 289 Lisp_Object list;
287 290
@@ -308,7 +311,7 @@ If KEYMAP has no parent, return nil. */)
308} 311}
309 312
310/* Check whether MAP is one of MAPS parents. */ 313/* Check whether MAP is one of MAPS parents. */
311static int 314static bool
312keymap_memberp (Lisp_Object map, Lisp_Object maps) 315keymap_memberp (Lisp_Object map, Lisp_Object maps)
313{ 316{
314 if (NILP (map)) return 0; 317 if (NILP (map)) return 0;
@@ -366,19 +369,20 @@ Return PARENT. PARENT should be nil or another keymap. */)
366 369
367 MAP must be a keymap or a list of keymaps. 370 MAP must be a keymap or a list of keymaps.
368 371
369 If T_OK is non-zero, bindings for Qt are treated as default 372 If T_OK, bindings for Qt are treated as default
370 bindings; any key left unmentioned by other tables and bindings is 373 bindings; any key left unmentioned by other tables and bindings is
371 given the binding of Qt. 374 given the binding of Qt.
372 375
373 If T_OK is zero, bindings for Qt are not treated specially. 376 If not T_OK, bindings for Qt are not treated specially.
374 377
375 If NOINHERIT, don't accept a subkeymap found in an inherited keymap. 378 If NOINHERIT, don't accept a subkeymap found in an inherited keymap.
376 379
377 Returns Qunbound if no binding was found (and returns Qnil if a nil 380 Return Qunbound if no binding was found (and return Qnil if a nil
378 binding was found). */ 381 binding was found). */
379 382
380static Lisp_Object 383static Lisp_Object
381access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int autoload) 384access_keymap_1 (Lisp_Object map, Lisp_Object idx,
385 bool t_ok, bool noinherit, bool autoload)
382{ 386{
383 /* If idx is a list (some sort of mouse click, perhaps?), 387 /* 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 388 the index we want to use is the car of the list, which
@@ -530,12 +534,12 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int
530 retval = val; 534 retval = val;
531 else if (CONSP (retval_tail)) 535 else if (CONSP (retval_tail))
532 { 536 {
533 XSETCDR (retval_tail, Fcons (val, Qnil)); 537 XSETCDR (retval_tail, list1 (val));
534 retval_tail = XCDR (retval_tail); 538 retval_tail = XCDR (retval_tail);
535 } 539 }
536 else 540 else
537 { 541 {
538 retval_tail = Fcons (val, Qnil); 542 retval_tail = list1 (val);
539 retval = Fcons (Qkeymap, Fcons (retval, retval_tail)); 543 retval = Fcons (Qkeymap, Fcons (retval, retval_tail));
540 } 544 }
541 } 545 }
@@ -548,7 +552,7 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int
548 552
549Lisp_Object 553Lisp_Object
550access_keymap (Lisp_Object map, Lisp_Object idx, 554access_keymap (Lisp_Object map, Lisp_Object idx,
551 int t_ok, int noinherit, int autoload) 555 bool t_ok, bool noinherit, bool autoload)
552{ 556{
553 Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload); 557 Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload);
554 return EQ (val, Qunbound) ? Qnil : val; 558 return EQ (val, Qunbound) ? Qnil : val;
@@ -568,14 +572,13 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val)
568 if (!NILP (val)) 572 if (!NILP (val))
569 { 573 {
570 map_keymap_function_t fun 574 map_keymap_function_t fun
571 = (map_keymap_function_t) XSAVE_VALUE (XCAR (args))->pointer; 575 = (map_keymap_function_t) XSAVE_FUNCPOINTER (args, 0);
572 args = XCDR (args);
573 /* If the key is a range, make a copy since map_char_table modifies 576 /* If the key is a range, make a copy since map_char_table modifies
574 it in place. */ 577 it in place. */
575 if (CONSP (key)) 578 if (CONSP (key))
576 key = Fcons (XCAR (key), XCDR (key)); 579 key = Fcons (XCAR (key), XCDR (key));
577 map_keymap_item (fun, XCDR (args), key, val, 580 map_keymap_item (fun, XSAVE_OBJECT (args, 2), key,
578 XSAVE_VALUE (XCAR (args))->pointer); 581 val, XSAVE_POINTER (args, 1));
579 } 582 }
580} 583}
581 584
@@ -613,12 +616,9 @@ map_keymap_internal (Lisp_Object map,
613 } 616 }
614 } 617 }
615 else if (CHAR_TABLE_P (binding)) 618 else if (CHAR_TABLE_P (binding))
616 { 619 map_char_table (map_keymap_char_table_item, Qnil, binding,
617 map_char_table (map_keymap_char_table_item, Qnil, binding, 620 make_save_funcptr_ptr_obj ((voidfuncptr) fun, data,
618 Fcons (make_save_value ((void *) fun, 0), 621 args));
619 Fcons (make_save_value (data, 0),
620 args)));
621 }
622 } 622 }
623 UNGCPRO; 623 UNGCPRO;
624 return tail; 624 return tail;
@@ -631,9 +631,10 @@ map_keymap_call (Lisp_Object key, Lisp_Object val, Lisp_Object fun, void *dummy)
631} 631}
632 632
633/* Same as map_keymap_internal, but traverses parent keymaps as well. 633/* Same as map_keymap_internal, but traverses parent keymaps as well.
634 A non-zero AUTOLOAD indicates that autoloaded keymaps should be loaded. */ 634 AUTOLOAD indicates that autoloaded keymaps should be loaded. */
635void 635void
636map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data, int autoload) 636map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args,
637 void *data, bool autoload)
637{ 638{
638 struct gcpro gcpro1; 639 struct gcpro gcpro1;
639 GCPRO1 (args); 640 GCPRO1 (args);
@@ -712,13 +713,13 @@ usage: (map-keymap FUNCTION KEYMAP) */)
712 Also if OBJECT has a menu string as the first element, 713 Also if OBJECT has a menu string as the first element,
713 remove that. Also remove a menu help string as second element. 714 remove that. Also remove a menu help string as second element.
714 715
715 If AUTOLOAD is nonzero, load autoloadable keymaps 716 If AUTOLOAD, load autoloadable keymaps
716 that are referred to with indirection. 717 that are referred to with indirection.
717 718
718 This can GC because menu_item_eval_property calls Feval. */ 719 This can GC because menu_item_eval_property calls Feval. */
719 720
720static Lisp_Object 721static Lisp_Object
721get_keyelt (Lisp_Object object, int autoload) 722get_keyelt (Lisp_Object object, bool autoload)
722{ 723{
723 while (1) 724 while (1)
724 { 725 {
@@ -956,8 +957,6 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def)
956 return def; 957 return def;
957} 958}
958 959
959static Lisp_Object Fcopy_keymap (Lisp_Object);
960
961static Lisp_Object 960static Lisp_Object
962copy_keymap_item (Lisp_Object elt) 961copy_keymap_item (Lisp_Object elt)
963{ 962{
@@ -1046,9 +1045,9 @@ However, a key definition which is a symbol whose definition is a keymap
1046is not copied. */) 1045is not copied. */)
1047 (Lisp_Object keymap) 1046 (Lisp_Object keymap)
1048{ 1047{
1049 register Lisp_Object copy, tail; 1048 Lisp_Object copy, tail;
1050 keymap = get_keymap (keymap, 1, 0); 1049 keymap = get_keymap (keymap, 1, 0);
1051 copy = tail = Fcons (Qkeymap, Qnil); 1050 copy = tail = list1 (Qkeymap);
1052 keymap = XCDR (keymap); /* Skip the `keymap' symbol. */ 1051 keymap = XCDR (keymap); /* Skip the `keymap' symbol. */
1053 1052
1054 while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap)) 1053 while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap))
@@ -1074,7 +1073,7 @@ is not copied. */)
1074 else 1073 else
1075 elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt))); 1074 elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt)));
1076 } 1075 }
1077 XSETCDR (tail, Fcons (elt, Qnil)); 1076 XSETCDR (tail, list1 (elt));
1078 tail = XCDR (tail); 1077 tail = XCDR (tail);
1079 keymap = XCDR (keymap); 1078 keymap = XCDR (keymap);
1080 } 1079 }
@@ -1117,10 +1116,10 @@ binding is altered. If there is no binding for KEY, the new pair
1117binding KEY to DEF is added at the front of KEYMAP. */) 1116binding KEY to DEF is added at the front of KEYMAP. */)
1118 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) 1117 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def)
1119{ 1118{
1120 register ptrdiff_t idx; 1119 ptrdiff_t idx;
1121 register Lisp_Object c; 1120 Lisp_Object c;
1122 register Lisp_Object cmd; 1121 Lisp_Object cmd;
1123 int metized = 0; 1122 bool metized = 0;
1124 int meta_bit; 1123 int meta_bit;
1125 ptrdiff_t length; 1124 ptrdiff_t length;
1126 struct gcpro gcpro1, gcpro2, gcpro3; 1125 struct gcpro gcpro1, gcpro2, gcpro3;
@@ -1253,7 +1252,7 @@ remapping in all currently active keymaps. */)
1253 return INTEGERP (command) ? Qnil : command; 1252 return INTEGERP (command) ? Qnil : command;
1254} 1253}
1255 1254
1256/* Value is number if KEY is too long; nil if valid but has no definition. */ 1255/* Value is number if KEY is too long; nil if valid but has no definition. */
1257/* GC is possible in this function. */ 1256/* GC is possible in this function. */
1258 1257
1259DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, 1258DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0,
@@ -1274,11 +1273,11 @@ third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will
1274recognize the default bindings, just as `read-key-sequence' does. */) 1273recognize the default bindings, just as `read-key-sequence' does. */)
1275 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) 1274 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default)
1276{ 1275{
1277 register ptrdiff_t idx; 1276 ptrdiff_t idx;
1278 register Lisp_Object cmd; 1277 Lisp_Object cmd;
1279 register Lisp_Object c; 1278 Lisp_Object c;
1280 ptrdiff_t length; 1279 ptrdiff_t length;
1281 int t_ok = !NILP (accept_default); 1280 bool t_ok = !NILP (accept_default);
1282 struct gcpro gcpro1, gcpro2; 1281 struct gcpro gcpro1, gcpro2;
1283 1282
1284 GCPRO2 (keymap, key); 1283 GCPRO2 (keymap, key);
@@ -1342,8 +1341,7 @@ append_key (Lisp_Object key_sequence, Lisp_Object key)
1342 Lisp_Object args[2]; 1341 Lisp_Object args[2];
1343 1342
1344 args[0] = key_sequence; 1343 args[0] = key_sequence;
1345 1344 args[1] = list1 (key);
1346 args[1] = Fcons (key, Qnil);
1347 return Fvconcat (2, args); 1345 return Fvconcat (2, args);
1348} 1346}
1349 1347
@@ -1480,8 +1478,8 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1480 1478
1481 /* Use malloc here. See the comment above this function. 1479 /* Use malloc here. See the comment above this function.
1482 Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ 1480 Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */
1483 BLOCK_INPUT; 1481 block_input ();
1484 newmodes = (Lisp_Object *) malloc (allocsize); 1482 newmodes = malloc (allocsize);
1485 if (newmodes) 1483 if (newmodes)
1486 { 1484 {
1487 if (cmm_modes) 1485 if (cmm_modes)
@@ -1493,7 +1491,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1493 cmm_modes = newmodes; 1491 cmm_modes = newmodes;
1494 } 1492 }
1495 1493
1496 newmaps = (Lisp_Object *) malloc (allocsize); 1494 newmaps = malloc (allocsize);
1497 if (newmaps) 1495 if (newmaps)
1498 { 1496 {
1499 if (cmm_maps) 1497 if (cmm_maps)
@@ -1504,7 +1502,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1504 } 1502 }
1505 cmm_maps = newmaps; 1503 cmm_maps = newmaps;
1506 } 1504 }
1507 UNBLOCK_INPUT; 1505 unblock_input ();
1508 1506
1509 if (newmodes == NULL || newmaps == NULL) 1507 if (newmodes == NULL || newmaps == NULL)
1510 break; 1508 break;
@@ -1545,16 +1543,16 @@ DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps,
1545 doc: /* Return a list of the currently active keymaps. 1543 doc: /* Return a list of the currently active keymaps.
1546OLP if non-nil indicates that we should obey `overriding-local-map' and 1544OLP if non-nil indicates that we should obey `overriding-local-map' and
1547`overriding-terminal-local-map'. POSITION can specify a click position 1545`overriding-terminal-local-map'. POSITION can specify a click position
1548like in the respective argument of `key-binding'. */) 1546like in the respective argument of `key-binding'. */)
1549 (Lisp_Object olp, Lisp_Object position) 1547 (Lisp_Object olp, Lisp_Object position)
1550{ 1548{
1551 ptrdiff_t count = SPECPDL_INDEX (); 1549 ptrdiff_t count = SPECPDL_INDEX ();
1552 1550
1553 Lisp_Object keymaps = Fcons (current_global_map, Qnil); 1551 Lisp_Object keymaps = list1 (current_global_map);
1554 1552
1555 /* If a mouse click position is given, our variables are based on 1553 /* If a mouse click position is given, our variables are based on
1556 the buffer clicked on, not the current buffer. So we may have to 1554 the buffer clicked on, not the current buffer. So we may have to
1557 switch the buffer here. */ 1555 switch the buffer here. */
1558 1556
1559 if (CONSP (position)) 1557 if (CONSP (position))
1560 { 1558 {
@@ -1563,8 +1561,8 @@ like in the respective argument of `key-binding'. */)
1563 window = POSN_WINDOW (position); 1561 window = POSN_WINDOW (position);
1564 1562
1565 if (WINDOWP (window) 1563 if (WINDOWP (window)
1566 && BUFFERP (XWINDOW (window)->buffer) 1564 && BUFFERP (XWINDOW (window)->contents)
1567 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) 1565 && XBUFFER (XWINDOW (window)->contents) != current_buffer)
1568 { 1566 {
1569 /* Arrange to go back to the original buffer once we're done 1567 /* Arrange to go back to the original buffer once we're done
1570 processing the key sequence. We don't use 1568 processing the key sequence. We don't use
@@ -1573,24 +1571,19 @@ like in the respective argument of `key-binding'. */)
1573 would not be a problem here, but it is easier to keep 1571 would not be a problem here, but it is easier to keep
1574 things the same. 1572 things the same.
1575 */ 1573 */
1576 1574 record_unwind_current_buffer ();
1577 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 1575 set_buffer_internal (XBUFFER (XWINDOW (window)->contents));
1578
1579 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
1580 } 1576 }
1581 } 1577 }
1582 1578
1583 if (!NILP (olp)) 1579 if (!NILP (olp)
1584 {
1585 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
1586 keymaps = Fcons (KVAR (current_kboard, Voverriding_terminal_local_map),
1587 keymaps);
1588 /* The doc said that overriding-terminal-local-map should 1580 /* The doc said that overriding-terminal-local-map should
1589 override overriding-local-map. The code used them both, 1581 override overriding-local-map. The code used them both,
1590 but it seems clearer to use just one. rms, jan 2005. */ 1582 but it seems clearer to use just one. rms, jan 2005. */
1591 else if (!NILP (Voverriding_local_map)) 1583 && NILP (KVAR (current_kboard, Voverriding_terminal_local_map))
1592 keymaps = Fcons (Voverriding_local_map, keymaps); 1584 && !NILP (Voverriding_local_map))
1593 } 1585 keymaps = Fcons (Voverriding_local_map, keymaps);
1586
1594 if (NILP (XCDR (keymaps))) 1587 if (NILP (XCDR (keymaps)))
1595 { 1588 {
1596 Lisp_Object *maps; 1589 Lisp_Object *maps;
@@ -1601,6 +1594,7 @@ like in the respective argument of `key-binding'. */)
1601 Lisp_Object local_map = get_local_map (pt, current_buffer, Qlocal_map); 1594 Lisp_Object local_map = get_local_map (pt, current_buffer, Qlocal_map);
1602 /* This returns nil unless there is a `keymap' property. */ 1595 /* This returns nil unless there is a `keymap' property. */
1603 Lisp_Object keymap = get_local_map (pt, current_buffer, Qkeymap); 1596 Lisp_Object keymap = get_local_map (pt, current_buffer, Qkeymap);
1597 Lisp_Object otlp = KVAR (current_kboard, Voverriding_terminal_local_map);
1604 1598
1605 if (CONSP (position)) 1599 if (CONSP (position))
1606 { 1600 {
@@ -1665,6 +1659,9 @@ like in the respective argument of `key-binding'. */)
1665 1659
1666 if (!NILP (keymap)) 1660 if (!NILP (keymap))
1667 keymaps = Fcons (keymap, keymaps); 1661 keymaps = Fcons (keymap, keymaps);
1662
1663 if (!NILP (olp) && !NILP (otlp))
1664 keymaps = Fcons (otlp, keymaps);
1668 } 1665 }
1669 1666
1670 unbind_to (count, Qnil); 1667 unbind_to (count, Qnil);
@@ -1811,7 +1808,7 @@ bindings; see the description of `lookup-key' for more details about this. */)
1811 if (KEYMAPP (binding)) 1808 if (KEYMAPP (binding))
1812 maps[j++] = Fcons (modes[i], binding); 1809 maps[j++] = Fcons (modes[i], binding);
1813 else if (j == 0) 1810 else if (j == 0)
1814 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil)); 1811 RETURN_UNGCPRO (list1 (Fcons (modes[i], binding)));
1815 } 1812 }
1816 1813
1817 UNGCPRO; 1814 UNGCPRO;
@@ -1857,7 +1854,7 @@ If KEYMAP is nil, that means no local keymap. */)
1857 if (!NILP (keymap)) 1854 if (!NILP (keymap))
1858 keymap = get_keymap (keymap, 1, 1); 1855 keymap = get_keymap (keymap, 1, 1);
1859 1856
1860 BVAR (current_buffer, keymap) = keymap; 1857 bset_keymap (current_buffer, keymap);
1861 1858
1862 return Qnil; 1859 return Qnil;
1863} 1860}
@@ -1892,7 +1889,7 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_
1892struct accessible_keymaps_data { 1889struct accessible_keymaps_data {
1893 Lisp_Object maps, tail, thisseq; 1890 Lisp_Object maps, tail, thisseq;
1894 /* Does the current sequence end in the meta-prefix-char? */ 1891 /* Does the current sequence end in the meta-prefix-char? */
1895 int is_metized; 1892 bool is_metized;
1896}; 1893};
1897 1894
1898static void 1895static void
@@ -1903,7 +1900,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
1903 Lisp_Object maps = d->maps; 1900 Lisp_Object maps = d->maps;
1904 Lisp_Object tail = d->tail; 1901 Lisp_Object tail = d->tail;
1905 Lisp_Object thisseq = d->thisseq; 1902 Lisp_Object thisseq = d->thisseq;
1906 int is_metized = d->is_metized && INTEGERP (key); 1903 bool is_metized = d->is_metized && INTEGERP (key);
1907 Lisp_Object tem; 1904 Lisp_Object tem;
1908 1905
1909 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0); 1906 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0);
@@ -1953,7 +1950,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
1953 else 1950 else
1954 { 1951 {
1955 tem = append_key (thisseq, key); 1952 tem = append_key (thisseq, key);
1956 nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); 1953 nconc2 (tail, list1 (Fcons (tem, cmd)));
1957 } 1954 }
1958} 1955}
1959 1956
@@ -2007,15 +2004,13 @@ then the value includes only maps for prefixes that start with PREFIX. */)
2007 } 2004 }
2008 prefix = copy; 2005 prefix = copy;
2009 } 2006 }
2010 maps = Fcons (Fcons (prefix, tem), Qnil); 2007 maps = list1 (Fcons (prefix, tem));
2011 } 2008 }
2012 else 2009 else
2013 return Qnil; 2010 return Qnil;
2014 } 2011 }
2015 else 2012 else
2016 maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), 2013 maps = list1 (Fcons (zero_vector, get_keymap (keymap, 1, 0)));
2017 get_keymap (keymap, 1, 0)),
2018 Qnil);
2019 2014
2020 /* For each map in the list maps, 2015 /* For each map in the list maps,
2021 look at any other maps it points to, 2016 look at any other maps it points to,
@@ -2055,7 +2050,7 @@ DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0,
2055Optional arg PREFIX is the sequence of keys leading up to KEYS. 2050Optional arg PREFIX is the sequence of keys leading up to KEYS.
2056For example, [?\C-x ?l] is converted into the string \"C-x l\". 2051For example, [?\C-x ?l] is converted into the string \"C-x l\".
2057 2052
2058The `kbd' macro is an approximate inverse of this. */) 2053For an approximate inverse of this, see `kbd'. */)
2059 (Lisp_Object keys, Lisp_Object prefix) 2054 (Lisp_Object keys, Lisp_Object prefix)
2060{ 2055{
2061 ptrdiff_t len = 0; 2056 ptrdiff_t len = 0;
@@ -2067,14 +2062,14 @@ The `kbd' macro is an approximate inverse of this. */)
2067 Lisp_Object sep = build_string (" "); 2062 Lisp_Object sep = build_string (" ");
2068 Lisp_Object key; 2063 Lisp_Object key;
2069 Lisp_Object result; 2064 Lisp_Object result;
2070 int add_meta = 0; 2065 bool add_meta = 0;
2071 USE_SAFE_ALLOCA; 2066 USE_SAFE_ALLOCA;
2072 2067
2073 if (!NILP (prefix)) 2068 if (!NILP (prefix))
2074 size += XINT (Flength (prefix)); 2069 size += XINT (Flength (prefix));
2075 2070
2076 /* This has one extra element at the end that we don't pass to Fconcat. */ 2071 /* This has one extra element at the end that we don't pass to Fconcat. */
2077 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) / 4 < size) 2072 if (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size)
2078 memory_full (SIZE_MAX); 2073 memory_full (SIZE_MAX);
2079 SAFE_ALLOCA_LISP (args, size * 4); 2074 SAFE_ALLOCA_LISP (args, size * 4);
2080 2075
@@ -2146,7 +2141,7 @@ The `kbd' macro is an approximate inverse of this. */)
2146 continue; 2141 continue;
2147 } 2142 }
2148 else 2143 else
2149 XSETINT (key, (XINT (key) | meta_modifier) & ~0x80); 2144 XSETINT (key, XINT (key) | meta_modifier);
2150 add_meta = 0; 2145 add_meta = 0;
2151 } 2146 }
2152 else if (EQ (key, meta_prefix_char)) 2147 else if (EQ (key, meta_prefix_char))
@@ -2162,9 +2157,10 @@ The `kbd' macro is an approximate inverse of this. */)
2162 2157
2163 2158
2164char * 2159char *
2165push_key_description (EMACS_INT ch, char *p, int force_multibyte) 2160push_key_description (EMACS_INT ch, char *p)
2166{ 2161{
2167 int c, c2; 2162 int c, c2;
2163 bool tab_as_ci;
2168 2164
2169 /* Clear all the meaningless bits above the meta bit. */ 2165 /* Clear all the meaningless bits above the meta bit. */
2170 c = ch & (meta_modifier | ~ - meta_modifier); 2166 c = ch & (meta_modifier | ~ - meta_modifier);
@@ -2178,6 +2174,8 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2178 return p; 2174 return p;
2179 } 2175 }
2180 2176
2177 tab_as_ci = (c2 == '\t' && (c & meta_modifier));
2178
2181 if (c & alt_modifier) 2179 if (c & alt_modifier)
2182 { 2180 {
2183 *p++ = 'A'; 2181 *p++ = 'A';
@@ -2185,7 +2183,8 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2185 c -= alt_modifier; 2183 c -= alt_modifier;
2186 } 2184 }
2187 if ((c & ctrl_modifier) != 0 2185 if ((c & ctrl_modifier) != 0
2188 || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))) 2186 || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))
2187 || tab_as_ci)
2189 { 2188 {
2190 *p++ = 'C'; 2189 *p++ = 'C';
2191 *p++ = '-'; 2190 *p++ = '-';
@@ -2223,6 +2222,10 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2223 *p++ = 'S'; 2222 *p++ = 'S';
2224 *p++ = 'C'; 2223 *p++ = 'C';
2225 } 2224 }
2225 else if (tab_as_ci)
2226 {
2227 *p++ = 'i';
2228 }
2226 else if (c == '\t') 2229 else if (c == '\t')
2227 { 2230 {
2228 *p++ = 'T'; 2231 *p++ = 'T';
@@ -2256,21 +2259,12 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2256 *p++ = 'P'; 2259 *p++ = 'P';
2257 *p++ = 'C'; 2260 *p++ = 'C';
2258 } 2261 }
2259 else if (c < 128 2262 else if (c < 128)
2260 || (NILP (BVAR (current_buffer, enable_multibyte_characters)) 2263 *p++ = c;
2261 && SINGLE_BYTE_CHAR_P (c)
2262 && !force_multibyte))
2263 {
2264 *p++ = c;
2265 }
2266 else 2264 else
2267 { 2265 {
2268 /* Now we are sure that C is a valid character code. */ 2266 /* Now we are sure that C is a valid character code. */
2269 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) 2267 p += CHAR_STRING (c, (unsigned char *) p);
2270 && ! force_multibyte)
2271 *p++ = multibyte_char_to_unibyte (c);
2272 else
2273 p += CHAR_STRING (c, (unsigned char *) p);
2274 } 2268 }
2275 2269
2276 return p; 2270 return p;
@@ -2299,9 +2293,8 @@ around function keys and event symbols. */)
2299 2293
2300 if (INTEGERP (key)) /* Normal character. */ 2294 if (INTEGERP (key)) /* Normal character. */
2301 { 2295 {
2302 char tem[KEY_DESCRIPTION_SIZE], *p; 2296 char tem[KEY_DESCRIPTION_SIZE];
2303 2297 char *p = push_key_description (XINT (key), tem);
2304 p = push_key_description (XINT (key), tem, 1);
2305 *p = 0; 2298 *p = 0;
2306 return make_specified_string (tem, -1, p - tem, 1); 2299 return make_specified_string (tem, -1, p - tem, 1);
2307 } 2300 }
@@ -2309,11 +2302,10 @@ around function keys and event symbols. */)
2309 { 2302 {
2310 if (NILP (no_angles)) 2303 if (NILP (no_angles))
2311 { 2304 {
2312 char *buffer;
2313 Lisp_Object result; 2305 Lisp_Object result;
2314 USE_SAFE_ALLOCA; 2306 USE_SAFE_ALLOCA;
2315 SAFE_ALLOCA (buffer, char *, 2307 char *buffer = SAFE_ALLOCA (sizeof "<>"
2316 sizeof "<>" + SBYTES (SYMBOL_NAME (key))); 2308 + SBYTES (SYMBOL_NAME (key)));
2317 esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); 2309 esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key)));
2318 result = build_string (buffer); 2310 result = build_string (buffer);
2319 SAFE_FREE (); 2311 SAFE_FREE ();
@@ -2326,7 +2318,6 @@ around function keys and event symbols. */)
2326 return Fcopy_sequence (key); 2318 return Fcopy_sequence (key);
2327 else 2319 else
2328 error ("KEY must be an integer, cons, symbol, or string"); 2320 error ("KEY must be an integer, cons, symbol, or string");
2329 return Qnil;
2330} 2321}
2331 2322
2332static char * 2323static char *
@@ -2430,7 +2421,7 @@ static void where_is_internal_1 (Lisp_Object key, Lisp_Object binding,
2430 2421
2431static Lisp_Object 2422static Lisp_Object
2432shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag, 2423shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag,
2433 int remap) 2424 bool remap)
2434{ 2425{
2435 Lisp_Object tail, value; 2426 Lisp_Object tail, value;
2436 2427
@@ -2462,7 +2453,7 @@ static Lisp_Object Vmouse_events;
2462 2453
2463struct where_is_internal_data { 2454struct where_is_internal_data {
2464 Lisp_Object definition, this, last; 2455 Lisp_Object definition, this, last;
2465 int last_is_meta, noindirect; 2456 bool last_is_meta, noindirect;
2466 Lisp_Object sequences; 2457 Lisp_Object sequences;
2467}; 2458};
2468 2459
@@ -2475,7 +2466,7 @@ struct where_is_internal_data {
2475 2466
2476static Lisp_Object 2467static Lisp_Object
2477where_is_internal (Lisp_Object definition, Lisp_Object keymaps, 2468where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2478 int noindirect, int nomenus) 2469 bool noindirect, bool nomenus)
2479{ 2470{
2480 Lisp_Object maps = Qnil; 2471 Lisp_Object maps = Qnil;
2481 Lisp_Object found; 2472 Lisp_Object found;
@@ -2524,7 +2515,7 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2524 [M-CHAR] sequences, check if last character of the sequence 2515 [M-CHAR] sequences, check if last character of the sequence
2525 is the meta-prefix char. */ 2516 is the meta-prefix char. */
2526 Lisp_Object last; 2517 Lisp_Object last;
2527 int last_is_meta; 2518 bool last_is_meta;
2528 2519
2529 this = Fcar (XCAR (maps)); 2520 this = Fcar (XCAR (maps));
2530 map = Fcdr (XCAR (maps)); 2521 map = Fcdr (XCAR (maps));
@@ -2607,7 +2598,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2607 /* Actually relevant bindings. */ 2598 /* Actually relevant bindings. */
2608 Lisp_Object found = Qnil; 2599 Lisp_Object found = Qnil;
2609 /* 1 means ignore all menu bindings entirely. */ 2600 /* 1 means ignore all menu bindings entirely. */
2610 int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); 2601 bool nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii);
2611 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 2602 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
2612 /* List of sequences found via remapping. Keep them in a separate 2603 /* List of sequences found via remapping. Keep them in a separate
2613 variable, so as to push them later, since we prefer 2604 variable, so as to push them later, since we prefer
@@ -2616,7 +2607,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2616 /* Whether or not we're handling remapped sequences. This is needed 2607 /* Whether or not we're handling remapped sequences. This is needed
2617 because remapping is not done recursively by Fcommand_remapping: you 2608 because remapping is not done recursively by Fcommand_remapping: you
2618 can't remap a remapped command. */ 2609 can't remap a remapped command. */
2619 int remapped = 0; 2610 bool remapped = 0;
2620 Lisp_Object tem = Qnil; 2611 Lisp_Object tem = Qnil;
2621 2612
2622 /* Refresh the C version of the modifier preference. */ 2613 /* Refresh the C version of the modifier preference. */
@@ -2627,7 +2618,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2627 if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) 2618 if (CONSP (keymap) && KEYMAPP (XCAR (keymap)))
2628 keymaps = keymap; 2619 keymaps = keymap;
2629 else if (!NILP (keymap)) 2620 else if (!NILP (keymap))
2630 keymaps = Fcons (keymap, Fcons (current_global_map, Qnil)); 2621 keymaps = list2 (keymap, current_global_map);
2631 else 2622 else
2632 keymaps = Fcurrent_active_maps (Qnil, Qnil); 2623 keymaps = Fcurrent_active_maps (Qnil, Qnil);
2633 2624
@@ -2768,10 +2759,10 @@ where_is_internal_1 (Lisp_Object key, Lisp_Object binding, Lisp_Object args, voi
2768{ 2759{
2769 struct where_is_internal_data *d = data; /* Cast! */ 2760 struct where_is_internal_data *d = data; /* Cast! */
2770 Lisp_Object definition = d->definition; 2761 Lisp_Object definition = d->definition;
2771 int noindirect = d->noindirect; 2762 bool noindirect = d->noindirect;
2772 Lisp_Object this = d->this; 2763 Lisp_Object this = d->this;
2773 Lisp_Object last = d->last; 2764 Lisp_Object last = d->last;
2774 int last_is_meta = d->last_is_meta; 2765 bool last_is_meta = d->last_is_meta;
2775 Lisp_Object sequence; 2766 Lisp_Object sequence;
2776 2767
2777 /* Search through indirections unless that's not wanted. */ 2768 /* Search through indirections unless that's not wanted. */
@@ -2822,8 +2813,8 @@ The optional argument MENUS, if non-nil, says to mention menu bindings.
2822 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) 2813 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus)
2823{ 2814{
2824 Lisp_Object outbuf, shadow; 2815 Lisp_Object outbuf, shadow;
2825 int nomenu = NILP (menus); 2816 bool nomenu = NILP (menus);
2826 register Lisp_Object start1; 2817 Lisp_Object start1;
2827 struct gcpro gcpro1; 2818 struct gcpro gcpro1;
2828 2819
2829 const char *alternate_heading 2820 const char *alternate_heading
@@ -2858,15 +2849,15 @@ You type Translation\n\
2858 alternate_heading = 0; 2849 alternate_heading = 0;
2859 } 2850 }
2860 2851
2861 bufend = push_key_description (translate[c], buf, 1); 2852 bufend = push_key_description (translate[c], buf);
2862 insert (buf, bufend - buf); 2853 insert (buf, bufend - buf);
2863 Findent_to (make_number (16), make_number (1)); 2854 Findent_to (make_number (16), make_number (1));
2864 bufend = push_key_description (c, buf, 1); 2855 bufend = push_key_description (c, buf);
2865 insert (buf, bufend - buf); 2856 insert (buf, bufend - buf);
2866 2857
2867 insert ("\n", 1); 2858 insert ("\n", 1);
2868 2859
2869 /* Insert calls signal_after_change which may GC. */ 2860 /* Insert calls signal_after_change which may GC. */
2870 translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table)); 2861 translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table));
2871 } 2862 }
2872 2863
@@ -2882,6 +2873,14 @@ You type Translation\n\
2882 start1 = Qnil; 2873 start1 = Qnil;
2883 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) 2874 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
2884 start1 = KVAR (current_kboard, Voverriding_terminal_local_map); 2875 start1 = KVAR (current_kboard, Voverriding_terminal_local_map);
2876
2877 if (!NILP (start1))
2878 {
2879 describe_map_tree (start1, 1, shadow, prefix,
2880 "\f\nOverriding Bindings", nomenu, 0, 0, 0);
2881 shadow = Fcons (start1, shadow);
2882 start1 = Qnil;
2883 }
2885 else if (!NILP (Voverriding_local_map)) 2884 else if (!NILP (Voverriding_local_map))
2886 start1 = Voverriding_local_map; 2885 start1 = Voverriding_local_map;
2887 2886
@@ -2924,9 +2923,9 @@ You type Translation\n\
2924 char *title, *p; 2923 char *title, *p;
2925 2924
2926 if (!SYMBOLP (modes[i])) 2925 if (!SYMBOLP (modes[i]))
2927 abort (); 2926 emacs_abort ();
2928 2927
2929 p = title = (char *) alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); 2928 p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i])));
2930 *p++ = '\f'; 2929 *p++ = '\f';
2931 *p++ = '\n'; 2930 *p++ = '\n';
2932 *p++ = '`'; 2931 *p++ = '`';
@@ -2978,34 +2977,34 @@ You type Translation\n\
2978 2977
2979/* Insert a description of the key bindings in STARTMAP, 2978/* Insert a description of the key bindings in STARTMAP,
2980 followed by those of all maps reachable through STARTMAP. 2979 followed by those of all maps reachable through STARTMAP.
2981 If PARTIAL is nonzero, omit certain "uninteresting" commands 2980 If PARTIAL, omit certain "uninteresting" commands
2982 (such as `undefined'). 2981 (such as `undefined').
2983 If SHADOW is non-nil, it is a list of maps; 2982 If SHADOW is non-nil, it is a list of maps;
2984 don't mention keys which would be shadowed by any of them. 2983 don't mention keys which would be shadowed by any of them.
2985 PREFIX, if non-nil, says mention only keys that start with PREFIX. 2984 PREFIX, if non-nil, says mention only keys that start with PREFIX.
2986 TITLE, if not 0, is a string to insert at the beginning. 2985 TITLE, if not 0, is a string to insert at the beginning.
2987 TITLE should not end with a colon or a newline; we supply that. 2986 TITLE should not end with a colon or a newline; we supply that.
2988 If NOMENU is not 0, then omit menu-bar commands. 2987 If NOMENU, then omit menu-bar commands.
2989 2988
2990 If TRANSL is nonzero, the definitions are actually key translations 2989 If TRANSL, the definitions are actually key translations
2991 so print strings and vectors differently. 2990 so print strings and vectors differently.
2992 2991
2993 If ALWAYS_TITLE is nonzero, print the title even if there are no maps 2992 If ALWAYS_TITLE, print the title even if there are no maps
2994 to look through. 2993 to look through.
2995 2994
2996 If MENTION_SHADOW is nonzero, then when something is shadowed by SHADOW, 2995 If MENTION_SHADOW, then when something is shadowed by SHADOW,
2997 don't omit it; instead, mention it but say it is shadowed. 2996 don't omit it; instead, mention it but say it is shadowed.
2998 2997
2999 Any inserted text ends in two newlines (used by `help-make-xrefs'). */ 2998 Any inserted text ends in two newlines (used by `help-make-xrefs'). */
3000 2999
3001void 3000void
3002describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, 3001describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow,
3003 Lisp_Object prefix, const char *title, int nomenu, int transl, 3002 Lisp_Object prefix, const char *title, bool nomenu,
3004 int always_title, int mention_shadow) 3003 bool transl, bool always_title, bool mention_shadow)
3005{ 3004{
3006 Lisp_Object maps, orig_maps, seen, sub_shadows; 3005 Lisp_Object maps, orig_maps, seen, sub_shadows;
3007 struct gcpro gcpro1, gcpro2, gcpro3; 3006 struct gcpro gcpro1, gcpro2, gcpro3;
3008 int something = 0; 3007 bool something = 0;
3009 const char *key_heading 3008 const char *key_heading
3010 = "\ 3009 = "\
3011key binding\n\ 3010key binding\n\
@@ -3180,7 +3179,12 @@ describe_translation (Lisp_Object definition, Lisp_Object args)
3180 into an array of `struct describe_map_elt', 3179 into an array of `struct describe_map_elt',
3181 then sorts them by the events. */ 3180 then sorts them by the events. */
3182 3181
3183struct describe_map_elt { Lisp_Object event; Lisp_Object definition; int shadowed; }; 3182struct describe_map_elt
3183{
3184 Lisp_Object event;
3185 Lisp_Object definition;
3186 bool shadowed;
3187};
3184 3188
3185/* qsort comparison function for sorting `struct describe_map_elt' by 3189/* qsort comparison function for sorting `struct describe_map_elt' by
3186 the event field. */ 3190 the event field. */
@@ -3210,14 +3214,14 @@ describe_map_compare (const void *aa, const void *bb)
3210static void 3214static void
3211describe_map (Lisp_Object map, Lisp_Object prefix, 3215describe_map (Lisp_Object map, Lisp_Object prefix,
3212 void (*elt_describer) (Lisp_Object, Lisp_Object), 3216 void (*elt_describer) (Lisp_Object, Lisp_Object),
3213 int partial, Lisp_Object shadow, 3217 bool partial, Lisp_Object shadow,
3214 Lisp_Object *seen, int nomenu, int mention_shadow) 3218 Lisp_Object *seen, bool nomenu, bool mention_shadow)
3215{ 3219{
3216 Lisp_Object tail, definition, event; 3220 Lisp_Object tail, definition, event;
3217 Lisp_Object tem; 3221 Lisp_Object tem;
3218 Lisp_Object suppress; 3222 Lisp_Object suppress;
3219 Lisp_Object kludge; 3223 Lisp_Object kludge;
3220 int first = 1; 3224 bool first = 1;
3221 struct gcpro gcpro1, gcpro2, gcpro3; 3225 struct gcpro gcpro1, gcpro2, gcpro3;
3222 3226
3223 /* These accumulate the values from sparse keymap bindings, 3227 /* These accumulate the values from sparse keymap bindings,
@@ -3245,8 +3249,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3245 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3249 for (tail = map; CONSP (tail); tail = XCDR (tail))
3246 length_needed++; 3250 length_needed++;
3247 3251
3248 vect = ((struct describe_map_elt *) 3252 vect = alloca (length_needed * sizeof *vect);
3249 alloca (sizeof (struct describe_map_elt) * length_needed));
3250 3253
3251 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3254 for (tail = map; CONSP (tail); tail = XCDR (tail))
3252 { 3255 {
@@ -3259,7 +3262,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3259 1, mention_shadow); 3262 1, mention_shadow);
3260 else if (CONSP (XCAR (tail))) 3263 else if (CONSP (XCAR (tail)))
3261 { 3264 {
3262 int this_shadowed = 0; 3265 bool this_shadowed = 0;
3263 3266
3264 event = XCAR (XCAR (tail)); 3267 event = XCAR (XCAR (tail));
3265 3268
@@ -3429,7 +3432,7 @@ DESCRIBER is the output function used; nil means use `princ'. */)
3429 of bytes that lead to the character set or portion of a character 3432 of bytes that lead to the character set or portion of a character
3430 set described by this chartable. 3433 set described by this chartable.
3431 3434
3432 If PARTIAL is nonzero, it means do not mention suppressed commands 3435 If PARTIAL, it means do not mention suppressed commands
3433 (that assumes the vector is in a keymap). 3436 (that assumes the vector is in a keymap).
3434 3437
3435 SHADOW is a list of keymaps that shadow this map. 3438 SHADOW is a list of keymaps that shadow this map.
@@ -3449,8 +3452,8 @@ DESCRIBER is the output function used; nil means use `princ'. */)
3449static void 3452static void
3450describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, 3453describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3451 void (*elt_describer) (Lisp_Object, Lisp_Object), 3454 void (*elt_describer) (Lisp_Object, Lisp_Object),
3452 int partial, Lisp_Object shadow, Lisp_Object entire_map, 3455 bool partial, Lisp_Object shadow, Lisp_Object entire_map,
3453 int keymap_p, int mention_shadow) 3456 bool keymap_p, bool mention_shadow)
3454{ 3457{
3455 Lisp_Object definition; 3458 Lisp_Object definition;
3456 Lisp_Object tem2; 3459 Lisp_Object tem2;
@@ -3458,7 +3461,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3458 int i; 3461 int i;
3459 Lisp_Object suppress; 3462 Lisp_Object suppress;
3460 Lisp_Object kludge; 3463 Lisp_Object kludge;
3461 int first = 1; 3464 bool first = 1;
3462 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 3465 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3463 /* Range of elements to be handled. */ 3466 /* Range of elements to be handled. */
3464 int from, to, stop; 3467 int from, to, stop;
@@ -3498,7 +3501,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3498 3501
3499 for (i = from; ; i++) 3502 for (i = from; ; i++)
3500 { 3503 {
3501 int this_shadowed = 0; 3504 bool this_shadowed = 0;
3502 int range_beg, range_end; 3505 int range_beg, range_end;
3503 Lisp_Object val; 3506 Lisp_Object val;
3504 3507
@@ -3707,13 +3710,12 @@ syms_of_keymap (void)
3707 Fset (intern_c_string ("ctl-x-map"), control_x_map); 3710 Fset (intern_c_string ("ctl-x-map"), control_x_map);
3708 Ffset (intern_c_string ("Control-X-prefix"), control_x_map); 3711 Ffset (intern_c_string ("Control-X-prefix"), control_x_map);
3709 3712
3710 exclude_keys 3713 exclude_keys = listn (CONSTYPE_PURE, 5,
3711 = pure_cons (pure_cons (make_pure_c_string ("DEL"), make_pure_c_string ("\\d")), 3714 pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")),
3712 pure_cons (pure_cons (make_pure_c_string ("TAB"), make_pure_c_string ("\\t")), 3715 pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")),
3713 pure_cons (pure_cons (make_pure_c_string ("RET"), make_pure_c_string ("\\r")), 3716 pure_cons (build_pure_c_string ("RET"), build_pure_c_string ("\\r")),
3714 pure_cons (pure_cons (make_pure_c_string ("ESC"), make_pure_c_string ("\\e")), 3717 pure_cons (build_pure_c_string ("ESC"), build_pure_c_string ("\\e")),
3715 pure_cons (pure_cons (make_pure_c_string ("SPC"), make_pure_c_string (" ")), 3718 pure_cons (build_pure_c_string ("SPC"), build_pure_c_string (" ")));
3716 Qnil)))));
3717 staticpro (&exclude_keys); 3719 staticpro (&exclude_keys);
3718 3720
3719 DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands, 3721 DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands,
@@ -3766,16 +3768,16 @@ be preferred. */);
3766 where_is_preferred_modifier = 0; 3768 where_is_preferred_modifier = 0;
3767 3769
3768 staticpro (&Vmouse_events); 3770 staticpro (&Vmouse_events);
3769 Vmouse_events = pure_cons (intern_c_string ("menu-bar"), 3771 Vmouse_events = listn (CONSTYPE_PURE, 9,
3770 pure_cons (intern_c_string ("tool-bar"), 3772 intern_c_string ("menu-bar"),
3771 pure_cons (intern_c_string ("header-line"), 3773 intern_c_string ("tool-bar"),
3772 pure_cons (intern_c_string ("mode-line"), 3774 intern_c_string ("header-line"),
3773 pure_cons (intern_c_string ("mouse-1"), 3775 intern_c_string ("mode-line"),
3774 pure_cons (intern_c_string ("mouse-2"), 3776 intern_c_string ("mouse-1"),
3775 pure_cons (intern_c_string ("mouse-3"), 3777 intern_c_string ("mouse-2"),
3776 pure_cons (intern_c_string ("mouse-4"), 3778 intern_c_string ("mouse-3"),
3777 pure_cons (intern_c_string ("mouse-5"), 3779 intern_c_string ("mouse-4"),
3778 Qnil))))))))); 3780 intern_c_string ("mouse-5"));
3779 3781
3780 DEFSYM (Qsingle_key_description, "single-key-description"); 3782 DEFSYM (Qsingle_key_description, "single-key-description");
3781 DEFSYM (Qkey_description, "key-description"); 3783 DEFSYM (Qkey_description, "key-description");