aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas2020-12-30 09:43:38 +0100
committerStefan Kangas2020-12-30 09:43:38 +0100
commitd22fa9eb67925ba341ef5b0da8a432a76cbb6af1 (patch)
tree8809acf90311cd7574f69844dca03979bd4ab473 /src
parentdc771b6c409c016dec6aea394d574de1cca3c583 (diff)
downloademacs-d22fa9eb67925ba341ef5b0da8a432a76cbb6af1.tar.gz
emacs-d22fa9eb67925ba341ef5b0da8a432a76cbb6af1.zip
Minor cleanup in keymap.c
* src/keymap.c (get_keymap, keymap_parent, Fset_keymap_parent) (store_in_keymap, Fdefine_key, Flookup_key, define_as_prefix) (silly_event_symbol_error, current_minor_maps) (Fcurrent_active_maps, Fkey_binding, Flocal_key_binding) (Fminor_mode_key_binding, Fdefine_prefix_command) (Faccessible_keymaps, Fdescribe_buffer_bindings) (describe_vector, Fwhere_is_internal): Minor cleanup.
Diffstat (limited to 'src')
-rw-r--r--src/keymap.c208
1 files changed, 72 insertions, 136 deletions
diff --git a/src/keymap.c b/src/keymap.c
index ca2d33dba47..86ec2388d11 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -218,15 +218,13 @@ when reading a key-sequence to be looked-up in this keymap. */)
218Lisp_Object 218Lisp_Object
219get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload) 219get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload)
220{ 220{
221 Lisp_Object tem;
222
223 autoload_retry: 221 autoload_retry:
224 if (NILP (object)) 222 if (NILP (object))
225 goto end; 223 goto end;
226 if (CONSP (object) && EQ (XCAR (object), Qkeymap)) 224 if (CONSP (object) && EQ (XCAR (object), Qkeymap))
227 return object; 225 return object;
228 226
229 tem = indirect_function (object); 227 Lisp_Object tem = indirect_function (object);
230 if (CONSP (tem)) 228 if (CONSP (tem))
231 { 229 {
232 if (EQ (XCAR (tem), Qkeymap)) 230 if (EQ (XCAR (tem), Qkeymap))
@@ -265,12 +263,10 @@ get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload)
265static Lisp_Object 263static Lisp_Object
266keymap_parent (Lisp_Object keymap, bool autoload) 264keymap_parent (Lisp_Object keymap, bool autoload)
267{ 265{
268 Lisp_Object list;
269
270 keymap = get_keymap (keymap, 1, autoload); 266 keymap = get_keymap (keymap, 1, autoload);
271 267
272 /* Skip past the initial element `keymap'. */ 268 /* Skip past the initial element `keymap'. */
273 list = XCDR (keymap); 269 Lisp_Object list = XCDR (keymap);
274 for (; CONSP (list); list = XCDR (list)) 270 for (; CONSP (list); list = XCDR (list))
275 { 271 {
276 /* See if there is another `keymap'. */ 272 /* See if there is another `keymap'. */
@@ -306,8 +302,6 @@ DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0,
306Return PARENT. PARENT should be nil or another keymap. */) 302Return PARENT. PARENT should be nil or another keymap. */)
307 (Lisp_Object keymap, Lisp_Object parent) 303 (Lisp_Object keymap, Lisp_Object parent)
308{ 304{
309 Lisp_Object list, prev;
310
311 /* Flush any reverse-map cache. */ 305 /* Flush any reverse-map cache. */
312 where_is_cache = Qnil; where_is_cache_keymaps = Qt; 306 where_is_cache = Qnil; where_is_cache_keymaps = Qt;
313 307
@@ -323,10 +317,10 @@ Return PARENT. PARENT should be nil or another keymap. */)
323 } 317 }
324 318
325 /* Skip past the initial element `keymap'. */ 319 /* Skip past the initial element `keymap'. */
326 prev = keymap; 320 Lisp_Object prev = keymap;
327 while (1) 321 while (1)
328 { 322 {
329 list = XCDR (prev); 323 Lisp_Object list = XCDR (prev);
330 /* If there is a parent keymap here, replace it. 324 /* If there is a parent keymap here, replace it.
331 If we came to the end, add the parent in PREV. */ 325 If we came to the end, add the parent in PREV. */
332 if (!CONSP (list) || KEYMAPP (list)) 326 if (!CONSP (list) || KEYMAPP (list))
@@ -805,14 +799,10 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def)
805 towards the front of the alist and character lookups in dense 799 towards the front of the alist and character lookups in dense
806 keymaps will remain fast. Otherwise, this just points at the 800 keymaps will remain fast. Otherwise, this just points at the
807 front of the keymap. */ 801 front of the keymap. */
808 Lisp_Object insertion_point; 802 Lisp_Object insertion_point = keymap;
809
810 insertion_point = keymap;
811 for (tail = XCDR (keymap); CONSP (tail); tail = XCDR (tail)) 803 for (tail = XCDR (keymap); CONSP (tail); tail = XCDR (tail))
812 { 804 {
813 Lisp_Object elt; 805 Lisp_Object elt = XCAR (tail);
814
815 elt = XCAR (tail);
816 if (VECTORP (elt)) 806 if (VECTORP (elt))
817 { 807 {
818 if (FIXNATP (idx) && XFIXNAT (idx) < ASIZE (elt)) 808 if (FIXNATP (idx) && XFIXNAT (idx) < ASIZE (elt))
@@ -1018,9 +1008,8 @@ copy_keymap_1 (Lisp_Object keymap, int depth)
1018 } 1008 }
1019 else if (VECTORP (elt)) 1009 else if (VECTORP (elt))
1020 { 1010 {
1021 int i;
1022 elt = Fcopy_sequence (elt); 1011 elt = Fcopy_sequence (elt);
1023 for (i = 0; i < ASIZE (elt); i++) 1012 for (int i = 0; i < ASIZE (elt); i++)
1024 ASET (elt, i, copy_keymap_item (AREF (elt, i), depth + 1)); 1013 ASET (elt, i, copy_keymap_item (AREF (elt, i), depth + 1));
1025 } 1014 }
1026 else if (CONSP (elt)) 1015 else if (CONSP (elt))
@@ -1097,24 +1086,19 @@ binding is altered. If there is no binding for KEY, the new pair
1097binding KEY to DEF is added at the front of KEYMAP. */) 1086binding KEY to DEF is added at the front of KEYMAP. */)
1098 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) 1087 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def)
1099{ 1088{
1100 ptrdiff_t idx; 1089 bool metized = false;
1101 Lisp_Object c;
1102 Lisp_Object cmd;
1103 bool metized = 0;
1104 int meta_bit;
1105 ptrdiff_t length;
1106 1090
1107 keymap = get_keymap (keymap, 1, 1); 1091 keymap = get_keymap (keymap, 1, 1);
1108 1092
1109 length = CHECK_VECTOR_OR_STRING (key); 1093 ptrdiff_t length = CHECK_VECTOR_OR_STRING (key);
1110 if (length == 0) 1094 if (length == 0)
1111 return Qnil; 1095 return Qnil;
1112 1096
1113 if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt)) 1097 if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt))
1114 Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands); 1098 Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands);
1115 1099
1116 meta_bit = (VECTORP (key) || (STRINGP (key) && STRING_MULTIBYTE (key)) 1100 int meta_bit = (VECTORP (key) || (STRINGP (key) && STRING_MULTIBYTE (key))
1117 ? meta_modifier : 0x80); 1101 ? meta_modifier : 0x80);
1118 1102
1119 if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0))) 1103 if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0)))
1120 { /* DEF is apparently an XEmacs-style keyboard macro. */ 1104 { /* DEF is apparently an XEmacs-style keyboard macro. */
@@ -1130,10 +1114,10 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1130 def = tmp; 1114 def = tmp;
1131 } 1115 }
1132 1116
1133 idx = 0; 1117 ptrdiff_t idx = 0;
1134 while (1) 1118 while (1)
1135 { 1119 {
1136 c = Faref (key, make_fixnum (idx)); 1120 Lisp_Object c = Faref (key, make_fixnum (idx));
1137 1121
1138 if (CONSP (c)) 1122 if (CONSP (c))
1139 { 1123 {
@@ -1153,14 +1137,14 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1153 && !metized) 1137 && !metized)
1154 { 1138 {
1155 c = meta_prefix_char; 1139 c = meta_prefix_char;
1156 metized = 1; 1140 metized = true;
1157 } 1141 }
1158 else 1142 else
1159 { 1143 {
1160 if (FIXNUMP (c)) 1144 if (FIXNUMP (c))
1161 XSETINT (c, XFIXNUM (c) & ~meta_bit); 1145 XSETINT (c, XFIXNUM (c) & ~meta_bit);
1162 1146
1163 metized = 0; 1147 metized = false;
1164 idx++; 1148 idx++;
1165 } 1149 }
1166 1150
@@ -1173,7 +1157,7 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1173 if (idx == length) 1157 if (idx == length)
1174 return store_in_keymap (keymap, c, def); 1158 return store_in_keymap (keymap, c, def);
1175 1159
1176 cmd = access_keymap (keymap, c, 0, 1, 1); 1160 Lisp_Object cmd = access_keymap (keymap, c, 0, 1, 1);
1177 1161
1178 /* If this key is undefined, make it a prefix. */ 1162 /* If this key is undefined, make it a prefix. */
1179 if (NILP (cmd)) 1163 if (NILP (cmd))
@@ -1250,23 +1234,19 @@ third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will
1250recognize the default bindings, just as `read-key-sequence' does. */) 1234recognize the default bindings, just as `read-key-sequence' does. */)
1251 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) 1235 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default)
1252{ 1236{
1253 ptrdiff_t idx;
1254 Lisp_Object cmd;
1255 Lisp_Object c;
1256 ptrdiff_t length;
1257 bool t_ok = !NILP (accept_default); 1237 bool t_ok = !NILP (accept_default);
1258 1238
1259 if (!CONSP (keymap) && !NILP (keymap)) 1239 if (!CONSP (keymap) && !NILP (keymap))
1260 keymap = get_keymap (keymap, true, true); 1240 keymap = get_keymap (keymap, true, true);
1261 1241
1262 length = CHECK_VECTOR_OR_STRING (key); 1242 ptrdiff_t length = CHECK_VECTOR_OR_STRING (key);
1263 if (length == 0) 1243 if (length == 0)
1264 return keymap; 1244 return keymap;
1265 1245
1266 idx = 0; 1246 ptrdiff_t idx = 0;
1267 while (1) 1247 while (1)
1268 { 1248 {
1269 c = Faref (key, make_fixnum (idx++)); 1249 Lisp_Object c = Faref (key, make_fixnum (idx++));
1270 1250
1271 if (CONSP (c) && lucid_event_type_list_p (c)) 1251 if (CONSP (c) && lucid_event_type_list_p (c))
1272 c = Fevent_convert_list (c); 1252 c = Fevent_convert_list (c);
@@ -1280,7 +1260,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1280 if (!FIXNUMP (c) && !SYMBOLP (c) && !CONSP (c) && !STRINGP (c)) 1260 if (!FIXNUMP (c) && !SYMBOLP (c) && !CONSP (c) && !STRINGP (c))
1281 message_with_string ("Key sequence contains invalid event %s", c, 1); 1261 message_with_string ("Key sequence contains invalid event %s", c, 1);
1282 1262
1283 cmd = access_keymap (keymap, c, t_ok, 0, 1); 1263 Lisp_Object cmd = access_keymap (keymap, c, t_ok, 0, 1);
1284 if (idx == length) 1264 if (idx == length)
1285 return cmd; 1265 return cmd;
1286 1266
@@ -1299,9 +1279,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1299static Lisp_Object 1279static Lisp_Object
1300define_as_prefix (Lisp_Object keymap, Lisp_Object c) 1280define_as_prefix (Lisp_Object keymap, Lisp_Object c)
1301{ 1281{
1302 Lisp_Object cmd; 1282 Lisp_Object cmd = Fmake_sparse_keymap (Qnil);
1303
1304 cmd = Fmake_sparse_keymap (Qnil);
1305 store_in_keymap (keymap, c, cmd); 1283 store_in_keymap (keymap, c, cmd);
1306 1284
1307 return cmd; 1285 return cmd;
@@ -1322,15 +1300,12 @@ append_key (Lisp_Object key_sequence, Lisp_Object key)
1322static void 1300static void
1323silly_event_symbol_error (Lisp_Object c) 1301silly_event_symbol_error (Lisp_Object c)
1324{ 1302{
1325 Lisp_Object parsed, base, name, assoc; 1303 Lisp_Object parsed = parse_modifiers (c);
1326 int modifiers; 1304 int modifiers = XFIXNAT (XCAR (XCDR (parsed)));
1327 1305 Lisp_Object base = XCAR (parsed);
1328 parsed = parse_modifiers (c); 1306 Lisp_Object name = Fsymbol_name (base);
1329 modifiers = XFIXNAT (XCAR (XCDR (parsed)));
1330 base = XCAR (parsed);
1331 name = Fsymbol_name (base);
1332 /* This alist includes elements such as ("RET" . "\\r"). */ 1307 /* This alist includes elements such as ("RET" . "\\r"). */
1333 assoc = Fassoc (name, exclude_keys, Qnil); 1308 Lisp_Object assoc = Fassoc (name, exclude_keys, Qnil);
1334 1309
1335 if (! NILP (assoc)) 1310 if (! NILP (assoc))
1336 { 1311 {
@@ -1391,16 +1366,14 @@ ptrdiff_t
1391current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) 1366current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1392{ 1367{
1393 ptrdiff_t i = 0; 1368 ptrdiff_t i = 0;
1394 int list_number = 0;
1395 Lisp_Object alist, assoc, var, val; 1369 Lisp_Object alist, assoc, var, val;
1396 Lisp_Object emulation_alists; 1370 Lisp_Object emulation_alists = Vemulation_mode_map_alists;
1397 Lisp_Object lists[2]; 1371 Lisp_Object lists[2];
1398 1372
1399 emulation_alists = Vemulation_mode_map_alists;
1400 lists[0] = Vminor_mode_overriding_map_alist; 1373 lists[0] = Vminor_mode_overriding_map_alist;
1401 lists[1] = Vminor_mode_map_alist; 1374 lists[1] = Vminor_mode_map_alist;
1402 1375
1403 for (list_number = 0; list_number < 2; list_number++) 1376 for (int list_number = 0; list_number < 2; list_number++)
1404 { 1377 {
1405 if (CONSP (emulation_alists)) 1378 if (CONSP (emulation_alists))
1406 { 1379 {
@@ -1526,9 +1499,7 @@ like in the respective argument of `key-binding'. */)
1526 1499
1527 if (CONSP (position)) 1500 if (CONSP (position))
1528 { 1501 {
1529 Lisp_Object window; 1502 Lisp_Object window = POSN_WINDOW (position);
1530
1531 window = POSN_WINDOW (position);
1532 1503
1533 if (WINDOWP (window) 1504 if (WINDOWP (window)
1534 && BUFFERP (XWINDOW (window)->contents) 1505 && BUFFERP (XWINDOW (window)->contents)
@@ -1557,7 +1528,7 @@ like in the respective argument of `key-binding'. */)
1557 if (NILP (XCDR (keymaps))) 1528 if (NILP (XCDR (keymaps)))
1558 { 1529 {
1559 Lisp_Object *maps; 1530 Lisp_Object *maps;
1560 int nmaps, i; 1531 int nmaps;
1561 ptrdiff_t pt = click_position (position); 1532 ptrdiff_t pt = click_position (position);
1562 /* This usually returns the buffer's local map, 1533 /* This usually returns the buffer's local map,
1563 but that can be overridden by a `local-map' property. */ 1534 but that can be overridden by a `local-map' property. */
@@ -1575,9 +1546,7 @@ like in the respective argument of `key-binding'. */)
1575 1546
1576 if (POSN_INBUFFER_P (position)) 1547 if (POSN_INBUFFER_P (position))
1577 { 1548 {
1578 Lisp_Object pos; 1549 Lisp_Object pos = POSN_BUFFER_POSN (position);
1579
1580 pos = POSN_BUFFER_POSN (position);
1581 if (FIXNUMP (pos) 1550 if (FIXNUMP (pos)
1582 && XFIXNUM (pos) >= BEG && XFIXNUM (pos) <= Z) 1551 && XFIXNUM (pos) >= BEG && XFIXNUM (pos) <= Z)
1583 { 1552 {
@@ -1597,15 +1566,13 @@ like in the respective argument of `key-binding'. */)
1597 1566
1598 if (CONSP (string) && STRINGP (XCAR (string))) 1567 if (CONSP (string) && STRINGP (XCAR (string)))
1599 { 1568 {
1600 Lisp_Object pos, map; 1569 Lisp_Object pos = XCDR (string);
1601
1602 pos = XCDR (string);
1603 string = XCAR (string); 1570 string = XCAR (string);
1604 if (FIXNUMP (pos) 1571 if (FIXNUMP (pos)
1605 && XFIXNUM (pos) >= 0 1572 && XFIXNUM (pos) >= 0
1606 && XFIXNUM (pos) < SCHARS (string)) 1573 && XFIXNUM (pos) < SCHARS (string))
1607 { 1574 {
1608 map = Fget_text_property (pos, Qlocal_map, string); 1575 Lisp_Object map = Fget_text_property (pos, Qlocal_map, string);
1609 if (!NILP (map)) 1576 if (!NILP (map))
1610 local_map = map; 1577 local_map = map;
1611 1578
@@ -1623,7 +1590,7 @@ like in the respective argument of `key-binding'. */)
1623 /* Now put all the minor mode keymaps on the list. */ 1590 /* Now put all the minor mode keymaps on the list. */
1624 nmaps = current_minor_maps (0, &maps); 1591 nmaps = current_minor_maps (0, &maps);
1625 1592
1626 for (i = --nmaps; i >= 0; i--) 1593 for (int i = --nmaps; i >= 0; i--)
1627 if (!NILP (maps[i])) 1594 if (!NILP (maps[i]))
1628 keymaps = Fcons (maps[i], keymaps); 1595 keymaps = Fcons (maps[i], keymaps);
1629 1596
@@ -1667,18 +1634,15 @@ specified buffer position instead of point are used.
1667 */) 1634 */)
1668 (Lisp_Object key, Lisp_Object accept_default, Lisp_Object no_remap, Lisp_Object position) 1635 (Lisp_Object key, Lisp_Object accept_default, Lisp_Object no_remap, Lisp_Object position)
1669{ 1636{
1670 Lisp_Object value;
1671
1672 if (NILP (position) && VECTORP (key)) 1637 if (NILP (position) && VECTORP (key))
1673 { 1638 {
1674 Lisp_Object event;
1675
1676 if (ASIZE (key) == 0) 1639 if (ASIZE (key) == 0)
1677 return Qnil; 1640 return Qnil;
1678 1641
1679 /* mouse events may have a symbolic prefix indicating the 1642 /* mouse events may have a symbolic prefix indicating the
1680 scrollbar or mode line */ 1643 scrollbar or mode line */
1681 event = AREF (key, SYMBOLP (AREF (key, 0)) && ASIZE (key) > 1 ? 1 : 0); 1644 Lisp_Object event
1645 = AREF (key, SYMBOLP (AREF (key, 0)) && ASIZE (key) > 1 ? 1 : 0);
1682 1646
1683 /* We are not interested in locations without event data */ 1647 /* We are not interested in locations without event data */
1684 1648
@@ -1690,8 +1654,8 @@ specified buffer position instead of point are used.
1690 } 1654 }
1691 } 1655 }
1692 1656
1693 value = Flookup_key (Fcurrent_active_maps (Qt, position), 1657 Lisp_Object value = Flookup_key (Fcurrent_active_maps (Qt, position),
1694 key, accept_default); 1658 key, accept_default);
1695 1659
1696 if (NILP (value) || FIXNUMP (value)) 1660 if (NILP (value) || FIXNUMP (value))
1697 return Qnil; 1661 return Qnil;
@@ -1720,8 +1684,7 @@ If optional argument ACCEPT-DEFAULT is non-nil, recognize default
1720bindings; see the description of `lookup-key' for more details about this. */) 1684bindings; see the description of `lookup-key' for more details about this. */)
1721 (Lisp_Object keys, Lisp_Object accept_default) 1685 (Lisp_Object keys, Lisp_Object accept_default)
1722{ 1686{
1723 register Lisp_Object map; 1687 register Lisp_Object map = BVAR (current_buffer, keymap);
1724 map = BVAR (current_buffer, keymap);
1725 if (NILP (map)) 1688 if (NILP (map))
1726 return Qnil; 1689 return Qnil;
1727 return Flookup_key (map, keys, accept_default); 1690 return Flookup_key (map, keys, accept_default);
@@ -1760,15 +1723,11 @@ bindings; see the description of `lookup-key' for more details about this. */)
1760 (Lisp_Object key, Lisp_Object accept_default) 1723 (Lisp_Object key, Lisp_Object accept_default)
1761{ 1724{
1762 Lisp_Object *modes, *maps; 1725 Lisp_Object *modes, *maps;
1763 int nmaps; 1726 int nmaps = current_minor_maps (&modes, &maps);
1764 Lisp_Object binding; 1727 Lisp_Object binding = Qnil;
1765 int i, j;
1766
1767 nmaps = current_minor_maps (&modes, &maps);
1768
1769 binding = Qnil;
1770 1728
1771 for (i = j = 0; i < nmaps; i++) 1729 int j;
1730 for (int i = j = 0; i < nmaps; i++)
1772 if (!NILP (maps[i]) 1731 if (!NILP (maps[i])
1773 && !NILP (binding = Flookup_key (maps[i], key, accept_default)) 1732 && !NILP (binding = Flookup_key (maps[i], key, accept_default))
1774 && !FIXNUMP (binding)) 1733 && !FIXNUMP (binding))
@@ -1795,8 +1754,7 @@ string for the map. This is required to use the keymap as a menu.
1795This function returns COMMAND. */) 1754This function returns COMMAND. */)
1796 (Lisp_Object command, Lisp_Object mapvar, Lisp_Object name) 1755 (Lisp_Object command, Lisp_Object mapvar, Lisp_Object name)
1797{ 1756{
1798 Lisp_Object map; 1757 Lisp_Object map = Fmake_sparse_keymap (name);
1799 map = Fmake_sparse_keymap (name);
1800 Ffset (command, map); 1758 Ffset (command, map);
1801 if (!NILP (mapvar)) 1759 if (!NILP (mapvar))
1802 Fset (mapvar, map); 1760 Fset (mapvar, map);
@@ -1942,8 +1900,7 @@ then the value includes only maps for prefixes that start with PREFIX. */)
1942 { 1900 {
1943 /* If a prefix was specified, start with the keymap (if any) for 1901 /* If a prefix was specified, start with the keymap (if any) for
1944 that prefix, so we don't waste time considering other prefixes. */ 1902 that prefix, so we don't waste time considering other prefixes. */
1945 Lisp_Object tem; 1903 Lisp_Object tem = Flookup_key (keymap, prefix, Qt);
1946 tem = Flookup_key (keymap, prefix, Qt);
1947 /* Flookup_key may give us nil, or a number, 1904 /* Flookup_key may give us nil, or a number,
1948 if the prefix is not defined in this particular map. 1905 if the prefix is not defined in this particular map.
1949 It might even give us a list that isn't a keymap. */ 1906 It might even give us a list that isn't a keymap. */
@@ -2406,7 +2363,6 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2406 bool noindirect, bool nomenus) 2363 bool noindirect, bool nomenus)
2407{ 2364{
2408 Lisp_Object maps = Qnil; 2365 Lisp_Object maps = Qnil;
2409 Lisp_Object found;
2410 struct where_is_internal_data data; 2366 struct where_is_internal_data data;
2411 2367
2412 /* Only important use of caching is for the menubar 2368 /* Only important use of caching is for the menubar
@@ -2432,7 +2388,7 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2432 we're filling it up. */ 2388 we're filling it up. */
2433 where_is_cache = Qnil; 2389 where_is_cache = Qnil;
2434 2390
2435 found = keymaps; 2391 Lisp_Object found = keymaps;
2436 while (CONSP (found)) 2392 while (CONSP (found))
2437 { 2393 {
2438 maps = 2394 maps =
@@ -2541,8 +2497,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2541 /* Whether or not we're handling remapped sequences. This is needed 2497 /* Whether or not we're handling remapped sequences. This is needed
2542 because remapping is not done recursively by Fcommand_remapping: you 2498 because remapping is not done recursively by Fcommand_remapping: you
2543 can't remap a remapped command. */ 2499 can't remap a remapped command. */
2544 bool remapped = 0; 2500 bool remapped = false;
2545 Lisp_Object tem = Qnil;
2546 2501
2547 /* Refresh the C version of the modifier preference. */ 2502 /* Refresh the C version of the modifier preference. */
2548 where_is_preferred_modifier 2503 where_is_preferred_modifier
@@ -2556,7 +2511,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2556 else 2511 else
2557 keymaps = Fcurrent_active_maps (Qnil, Qnil); 2512 keymaps = Fcurrent_active_maps (Qnil, Qnil);
2558 2513
2559 tem = Fcommand_remapping (definition, Qnil, keymaps); 2514 Lisp_Object tem = Fcommand_remapping (definition, Qnil, keymaps);
2560 /* If `definition' is remapped to `tem', then OT1H no key will run 2515 /* If `definition' is remapped to `tem', then OT1H no key will run
2561 that command (since they will run `tem' instead), so we should 2516 that command (since they will run `tem' instead), so we should
2562 return nil; but OTOH all keys bound to `definition' (or to `tem') 2517 return nil; but OTOH all keys bound to `definition' (or to `tem')
@@ -2598,7 +2553,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2598 considered remapped sequences yet, copy them over and 2553 considered remapped sequences yet, copy them over and
2599 process them. */ 2554 process them. */
2600 || (!remapped && (sequences = remapped_sequences, 2555 || (!remapped && (sequences = remapped_sequences,
2601 remapped = 1, 2556 remapped = true,
2602 CONSP (sequences)))) 2557 CONSP (sequences))))
2603 { 2558 {
2604 Lisp_Object sequence, function; 2559 Lisp_Object sequence, function;
@@ -2744,9 +2699,7 @@ The optional argument MENUS, if non-nil, says to mention menu bindings.
2744\(Ordinarily these are omitted from the output.) */) 2699\(Ordinarily these are omitted from the output.) */)
2745 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) 2700 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus)
2746{ 2701{
2747 Lisp_Object outbuf, shadow;
2748 Lisp_Object nomenu = NILP (menus) ? Qt : Qnil; 2702 Lisp_Object nomenu = NILP (menus) ? Qt : Qnil;
2749 Lisp_Object start1;
2750 2703
2751 const char *alternate_heading 2704 const char *alternate_heading
2752 = "\ 2705 = "\
@@ -2756,17 +2709,16 @@ You type Translation\n\
2756 2709
2757 CHECK_BUFFER (buffer); 2710 CHECK_BUFFER (buffer);
2758 2711
2759 shadow = Qnil; 2712 Lisp_Object shadow = Qnil;
2760 outbuf = Fcurrent_buffer (); 2713 Lisp_Object outbuf = Fcurrent_buffer ();
2761 2714
2762 /* Report on alternates for keys. */ 2715 /* Report on alternates for keys. */
2763 if (STRINGP (KVAR (current_kboard, Vkeyboard_translate_table)) && !NILP (prefix)) 2716 if (STRINGP (KVAR (current_kboard, Vkeyboard_translate_table)) && !NILP (prefix))
2764 { 2717 {
2765 int c;
2766 const unsigned char *translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table)); 2718 const unsigned char *translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table));
2767 int translate_len = SCHARS (KVAR (current_kboard, Vkeyboard_translate_table)); 2719 int translate_len = SCHARS (KVAR (current_kboard, Vkeyboard_translate_table));
2768 2720
2769 for (c = 0; c < translate_len; c++) 2721 for (int c = 0; c < translate_len; c++)
2770 if (translate[c] != c) 2722 if (translate[c] != c)
2771 { 2723 {
2772 char buf[KEY_DESCRIPTION_SIZE]; 2724 char buf[KEY_DESCRIPTION_SIZE];
@@ -2803,7 +2755,7 @@ You type Translation\n\
2803 } 2755 }
2804 2756
2805 /* Print the (major mode) local map. */ 2757 /* Print the (major mode) local map. */
2806 start1 = Qnil; 2758 Lisp_Object start1 = Qnil;
2807 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) 2759 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
2808 start1 = KVAR (current_kboard, Voverriding_terminal_local_map); 2760 start1 = KVAR (current_kboard, Voverriding_terminal_local_map);
2809 2761
@@ -2832,14 +2784,13 @@ You type Translation\n\
2832 else 2784 else
2833 { 2785 {
2834 /* Print the minor mode and major mode keymaps. */ 2786 /* Print the minor mode and major mode keymaps. */
2835 int i, nmaps;
2836 Lisp_Object *modes, *maps; 2787 Lisp_Object *modes, *maps;
2837 2788
2838 /* Temporarily switch to `buffer', so that we can get that buffer's 2789 /* Temporarily switch to `buffer', so that we can get that buffer's
2839 minor modes correctly. */ 2790 minor modes correctly. */
2840 Fset_buffer (buffer); 2791 Fset_buffer (buffer);
2841 2792
2842 nmaps = current_minor_maps (&modes, &maps); 2793 int nmaps = current_minor_maps (&modes, &maps);
2843 Fset_buffer (outbuf); 2794 Fset_buffer (outbuf);
2844 2795
2845 start1 = get_local_map (BUF_PT (XBUFFER (buffer)), 2796 start1 = get_local_map (BUF_PT (XBUFFER (buffer)),
@@ -2855,7 +2806,7 @@ You type Translation\n\
2855 } 2806 }
2856 2807
2857 /* Print the minor mode maps. */ 2808 /* Print the minor mode maps. */
2858 for (i = 0; i < nmaps; i++) 2809 for (int i = 0; i < nmaps; i++)
2859 { 2810 {
2860 /* The title for a minor mode keymap 2811 /* The title for a minor mode keymap
2861 is constructed at run time. 2812 is constructed at run time.
@@ -3042,21 +2993,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3042 bool partial, Lisp_Object shadow, Lisp_Object entire_map, 2993 bool partial, Lisp_Object shadow, Lisp_Object entire_map,
3043 bool keymap_p, bool mention_shadow) 2994 bool keymap_p, bool mention_shadow)
3044{ 2995{
3045 Lisp_Object definition;
3046 Lisp_Object tem2;
3047 Lisp_Object elt_prefix = Qnil; 2996 Lisp_Object elt_prefix = Qnil;
3048 int i; 2997 Lisp_Object suppress = Qnil;
3049 Lisp_Object suppress; 2998 bool first = true;
3050 Lisp_Object kludge;
3051 bool first = 1;
3052 /* Range of elements to be handled. */ 2999 /* Range of elements to be handled. */
3053 int from, to, stop; 3000 int from, to, stop;
3054 Lisp_Object character;
3055 int starting_i;
3056
3057 suppress = Qnil;
3058
3059 definition = Qnil;
3060 3001
3061 if (!keymap_p) 3002 if (!keymap_p)
3062 { 3003 {
@@ -3071,7 +3012,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3071 /* This vector gets used to present single keys to Flookup_key. Since 3012 /* This vector gets used to present single keys to Flookup_key. Since
3072 that is done once per vector element, we don't want to cons up a 3013 that is done once per vector element, we don't want to cons up a
3073 fresh vector every time. */ 3014 fresh vector every time. */
3074 kludge = make_nil_vector (1); 3015 Lisp_Object kludge = make_nil_vector (1);
3075 3016
3076 if (partial) 3017 if (partial)
3077 suppress = intern ("suppress-keymap"); 3018 suppress = intern ("suppress-keymap");
@@ -3082,12 +3023,12 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3082 else 3023 else
3083 stop = to = ASIZE (vector); 3024 stop = to = ASIZE (vector);
3084 3025
3085 for (i = from; ; i++) 3026 for (int i = from; ; i++)
3086 { 3027 {
3087 bool this_shadowed = 0; 3028 bool this_shadowed = false;
3088 Lisp_Object shadowed_by = Qnil; 3029 Lisp_Object shadowed_by = Qnil;
3089 int range_beg, range_end; 3030 int range_beg, range_end;
3090 Lisp_Object val; 3031 Lisp_Object val, tem2;
3091 3032
3092 maybe_quit (); 3033 maybe_quit ();
3093 3034
@@ -3098,7 +3039,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3098 stop = to; 3039 stop = to;
3099 } 3040 }
3100 3041
3101 starting_i = i; 3042 int starting_i = i;
3102 3043
3103 if (CHAR_TABLE_P (vector)) 3044 if (CHAR_TABLE_P (vector))
3104 { 3045 {
@@ -3108,21 +3049,19 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3108 } 3049 }
3109 else 3050 else
3110 val = AREF (vector, i); 3051 val = AREF (vector, i);
3111 definition = get_keyelt (val, 0); 3052 Lisp_Object definition = get_keyelt (val, 0);
3112 3053
3113 if (NILP (definition)) continue; 3054 if (NILP (definition)) continue;
3114 3055
3115 /* Don't mention suppressed commands. */ 3056 /* Don't mention suppressed commands. */
3116 if (SYMBOLP (definition) && partial) 3057 if (SYMBOLP (definition) && partial)
3117 { 3058 {
3118 Lisp_Object tem; 3059 Lisp_Object tem = Fget (definition, suppress);
3119
3120 tem = Fget (definition, suppress);
3121 3060
3122 if (!NILP (tem)) continue; 3061 if (!NILP (tem)) continue;
3123 } 3062 }
3124 3063
3125 character = make_fixnum (starting_i); 3064 Lisp_Object character = make_fixnum (starting_i);
3126 ASET (kludge, 0, character); 3065 ASET (kludge, 0, character);
3127 3066
3128 /* If this binding is shadowed by some other map, ignore it. */ 3067 /* If this binding is shadowed by some other map, ignore it. */
@@ -3133,7 +3072,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3133 if (!NILP (shadowed_by) && !EQ (shadowed_by, definition)) 3072 if (!NILP (shadowed_by) && !EQ (shadowed_by, definition))
3134 { 3073 {
3135 if (mention_shadow) 3074 if (mention_shadow)
3136 this_shadowed = 1; 3075 this_shadowed = true;
3137 else 3076 else
3138 continue; 3077 continue;
3139 } 3078 }
@@ -3143,9 +3082,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3143 one in the same keymap. */ 3082 one in the same keymap. */
3144 if (!NILP (entire_map)) 3083 if (!NILP (entire_map))
3145 { 3084 {
3146 Lisp_Object tem; 3085 Lisp_Object tem = Flookup_key (entire_map, kludge, Qt);
3147
3148 tem = Flookup_key (entire_map, kludge, Qt);
3149 3086
3150 if (!EQ (tem, definition)) 3087 if (!EQ (tem, definition))
3151 continue; 3088 continue;
@@ -3154,7 +3091,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3154 if (first) 3091 if (first)
3155 { 3092 {
3156 insert ("\n", 1); 3093 insert ("\n", 1);
3157 first = 0; 3094 first = false;
3158 } 3095 }
3159 3096
3160 /* Output the prefix that applies to every entry in this map. */ 3097 /* Output the prefix that applies to every entry in this map. */
@@ -3164,9 +3101,9 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3164 insert1 (Fkey_description (kludge, prefix)); 3101 insert1 (Fkey_description (kludge, prefix));
3165 3102
3166 /* Find all consecutive characters or rows that have the same 3103 /* Find all consecutive characters or rows that have the same
3167 definition. But, VECTOR is a char-table, we had better put a 3104 definition. But, if VECTOR is a char-table, we had better
3168 boundary between normal characters (-#x3FFF7F) and 8-bit 3105 put a boundary between normal characters (-#x3FFF7F) and
3169 characters (#x3FFF80-). */ 3106 8-bit characters (#x3FFF80-). */
3170 if (CHAR_TABLE_P (vector)) 3107 if (CHAR_TABLE_P (vector))
3171 { 3108 {
3172 while (i + 1 < stop 3109 while (i + 1 < stop
@@ -3189,12 +3126,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3189 if they are, that they are shadowed by the same command. */ 3126 if they are, that they are shadowed by the same command. */
3190 if (CHAR_TABLE_P (vector) && i != starting_i) 3127 if (CHAR_TABLE_P (vector) && i != starting_i)
3191 { 3128 {
3192 Lisp_Object tem;
3193 Lisp_Object key = make_nil_vector (1); 3129 Lisp_Object key = make_nil_vector (1);
3194 for (int j = starting_i + 1; j <= i; j++) 3130 for (int j = starting_i + 1; j <= i; j++)
3195 { 3131 {
3196 ASET (key, 0, make_fixnum (j)); 3132 ASET (key, 0, make_fixnum (j));
3197 tem = shadow_lookup (shadow, key, Qt, 0); 3133 Lisp_Object tem = shadow_lookup (shadow, key, Qt, 0);
3198 if (NILP (Fequal (tem, shadowed_by))) 3134 if (NILP (Fequal (tem, shadowed_by)))
3199 i = j - 1; 3135 i = j - 1;
3200 } 3136 }