Mercurial > emacs
comparison src/keymap.c @ 6502:18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Faccessible_keymaps, Fwhere_is_internal): Use assignment instead of
initialization.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 23 Mar 1994 22:50:23 +0000 |
parents | e7db7f9c1fb4 |
children | cedc6c52a812 |
comparison
equal
deleted
inserted
replaced
6501:d7ac9a417f87 | 6502:18dfda644bc0 |
---|---|
286 with more than 24 bits of integer. */ | 286 with more than 24 bits of integer. */ |
287 XFASTINT (idx) = XINT (idx) & (CHAR_META | (CHAR_META - 1)); | 287 XFASTINT (idx) = XINT (idx) & (CHAR_META | (CHAR_META - 1)); |
288 | 288 |
289 { | 289 { |
290 Lisp_Object tail; | 290 Lisp_Object tail; |
291 Lisp_Object t_binding = Qnil; | 291 Lisp_Object t_binding; |
292 | 292 |
293 t_binding = Qnil; | |
293 for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) | 294 for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) |
294 { | 295 { |
295 Lisp_Object binding = XCONS (tail)->car; | 296 Lisp_Object binding; |
296 | 297 |
298 binding = XCONS (tail)->car; | |
297 switch (XTYPE (binding)) | 299 switch (XTYPE (binding)) |
298 { | 300 { |
299 case Lisp_Symbol: | 301 case Lisp_Symbol: |
300 /* If NOINHERIT, stop finding prefix definitions | 302 /* If NOINHERIT, stop finding prefix definitions |
301 after we pass a second occurrence of the `keymap' symbol. */ | 303 after we pass a second occurrence of the `keymap' symbol. */ |
420 keymap has a table element, we record its position here, so new | 422 keymap has a table element, we record its position here, so new |
421 bindings will go after it; this way, the table will stay | 423 bindings will go after it; this way, the table will stay |
422 towards the front of the alist and character lookups in dense | 424 towards the front of the alist and character lookups in dense |
423 keymaps will remain fast. Otherwise, this just points at the | 425 keymaps will remain fast. Otherwise, this just points at the |
424 front of the keymap. */ | 426 front of the keymap. */ |
425 Lisp_Object insertion_point = keymap; | 427 Lisp_Object insertion_point; |
426 | 428 |
429 insertion_point = keymap; | |
427 for (tail = XCONS (keymap)->cdr; CONSP (tail); tail = XCONS (tail)->cdr) | 430 for (tail = XCONS (keymap)->cdr; CONSP (tail); tail = XCONS (tail)->cdr) |
428 { | 431 { |
429 Lisp_Object elt = XCONS (tail)->car; | 432 Lisp_Object elt; |
430 | 433 |
434 elt = XCONS (tail)->car; | |
431 switch (XTYPE (elt)) | 435 switch (XTYPE (elt)) |
432 { | 436 { |
433 case Lisp_Vector: | 437 case Lisp_Vector: |
434 if (XTYPE (idx) == Lisp_Int | 438 if (XTYPE (idx) == Lisp_Int |
435 && XINT (idx) >= 0 && XINT (idx) < XVECTOR (elt)->size) | 439 && XINT (idx) >= 0 && XINT (idx) < XVECTOR (elt)->size) |
486 | 490 |
487 copy = Fcopy_alist (get_keymap (keymap)); | 491 copy = Fcopy_alist (get_keymap (keymap)); |
488 | 492 |
489 for (tail = copy; CONSP (tail); tail = XCONS (tail)->cdr) | 493 for (tail = copy; CONSP (tail); tail = XCONS (tail)->cdr) |
490 { | 494 { |
491 Lisp_Object elt = XCONS (tail)->car; | 495 Lisp_Object elt; |
492 | 496 |
497 elt = XCONS (tail)->car; | |
493 if (XTYPE (elt) == Lisp_Vector) | 498 if (XTYPE (elt) == Lisp_Vector) |
494 { | 499 { |
495 int i; | 500 int i; |
496 | 501 |
497 elt = Fcopy_sequence (elt); | 502 elt = Fcopy_sequence (elt); |
628 if (NILP (cmd)) | 633 if (NILP (cmd)) |
629 cmd = define_as_prefix (keymap, c); | 634 cmd = define_as_prefix (keymap, c); |
630 | 635 |
631 keymap = get_keymap_1 (cmd, 0, 1); | 636 keymap = get_keymap_1 (cmd, 0, 1); |
632 if (NILP (keymap)) | 637 if (NILP (keymap)) |
633 { | 638 /* We must use Fkey_description rather than just passing key to |
634 /* We must use Fkey_description rather than just passing key to | 639 error; key might be a vector, not a string. */ |
635 error; key might be a vector, not a string. */ | 640 error ("Key sequence %s uses invalid prefix characters", |
636 Lisp_Object description = Fkey_description (key); | 641 XSTRING (Fkey_description (key))->data); |
637 | |
638 error ("Key sequence %s uses invalid prefix characters", | |
639 XSTRING (description)->data); | |
640 } | |
641 } | 642 } |
642 } | 643 } |
643 | 644 |
644 /* Value is number if KEY is too long; NIL if valid but has no definition. */ | 645 /* Value is number if KEY is too long; NIL if valid but has no definition. */ |
645 | 646 |
1138 This is a breadth-first traversal, where tail is the queue of | 1139 This is a breadth-first traversal, where tail is the queue of |
1139 nodes, and maps accumulates a list of all nodes visited. */ | 1140 nodes, and maps accumulates a list of all nodes visited. */ |
1140 | 1141 |
1141 for (tail = maps; CONSP (tail); tail = XCONS (tail)->cdr) | 1142 for (tail = maps; CONSP (tail); tail = XCONS (tail)->cdr) |
1142 { | 1143 { |
1143 register Lisp_Object thisseq = Fcar (Fcar (tail)); | 1144 register Lisp_Object thisseq, thismap; |
1144 register Lisp_Object thismap = Fcdr (Fcar (tail)); | 1145 Lisp_Object last; |
1145 Lisp_Object last = make_number (XINT (Flength (thisseq)) - 1); | |
1146 | |
1147 /* Does the current sequence end in the meta-prefix-char? */ | 1146 /* Does the current sequence end in the meta-prefix-char? */ |
1148 int is_metized = (XINT (last) >= 0 | 1147 int is_metized; |
1149 && EQ (Faref (thisseq, last), meta_prefix_char)); | 1148 |
1149 thisseq = Fcar (Fcar (tail)); | |
1150 thismap = Fcdr (Fcar (tail)); | |
1151 last = make_number (XINT (Flength (thisseq)) - 1); | |
1152 is_metized = (XINT (last) >= 0 | |
1153 && EQ (Faref (thisseq, last), meta_prefix_char)); | |
1150 | 1154 |
1151 for (; CONSP (thismap); thismap = XCONS (thismap)->cdr) | 1155 for (; CONSP (thismap); thismap = XCONS (thismap)->cdr) |
1152 { | 1156 { |
1153 Lisp_Object elt = XCONS (thismap)->car; | 1157 Lisp_Object elt; |
1158 | |
1159 elt = XCONS (thismap)->car; | |
1154 | 1160 |
1155 QUIT; | 1161 QUIT; |
1156 | 1162 |
1157 if (XTYPE (elt) == Lisp_Vector) | 1163 if (XTYPE (elt) == Lisp_Vector) |
1158 { | 1164 { |
1201 } | 1207 } |
1202 } | 1208 } |
1203 } | 1209 } |
1204 else if (CONSP (elt)) | 1210 else if (CONSP (elt)) |
1205 { | 1211 { |
1206 register Lisp_Object cmd = get_keyelt (XCONS (elt)->cdr); | 1212 register Lisp_Object cmd, tem, filter; |
1207 register Lisp_Object tem, filter; | 1213 |
1208 | 1214 cmd = get_keyelt (XCONS (elt)->cdr); |
1209 /* Ignore definitions that aren't keymaps themselves. */ | 1215 /* Ignore definitions that aren't keymaps themselves. */ |
1210 tem = Fkeymapp (cmd); | 1216 tem = Fkeymapp (cmd); |
1211 if (!NILP (tem)) | 1217 if (!NILP (tem)) |
1212 { | 1218 { |
1213 /* Ignore keymaps that have been seen already. */ | 1219 /* Ignore keymaps that have been seen already. */ |
1556 | 1562 |
1557 found = Qnil; | 1563 found = Qnil; |
1558 | 1564 |
1559 for (; !NILP (maps); maps = Fcdr (maps)) | 1565 for (; !NILP (maps); maps = Fcdr (maps)) |
1560 { | 1566 { |
1561 /* Key sequence to reach map */ | 1567 /* Key sequence to reach map, and the map that it reaches */ |
1562 register Lisp_Object this = Fcar (Fcar (maps)); | 1568 register Lisp_Object this, map; |
1563 | |
1564 /* The map that it reaches */ | |
1565 register Lisp_Object map = Fcdr (Fcar (maps)); | |
1566 | 1569 |
1567 /* If Fcar (map) is a VECTOR, the current element within that vector. */ | 1570 /* If Fcar (map) is a VECTOR, the current element within that vector. */ |
1568 int i = 0; | 1571 int i = 0; |
1569 | 1572 |
1570 /* In order to fold [META-PREFIX-CHAR CHAR] sequences into | 1573 /* In order to fold [META-PREFIX-CHAR CHAR] sequences into |
1571 [M-CHAR] sequences, check if last character of the sequence | 1574 [M-CHAR] sequences, check if last character of the sequence |
1572 is the meta-prefix char. */ | 1575 is the meta-prefix char. */ |
1573 Lisp_Object last = make_number (XINT (Flength (this)) - 1); | 1576 Lisp_Object last; |
1574 int last_is_meta = (XINT (last) >= 0 | 1577 int last_is_meta; |
1575 && EQ (Faref (this, last), meta_prefix_char)); | 1578 |
1579 this = Fcar (Fcar (maps)); | |
1580 map = Fcdr (Fcar (maps)); | |
1581 last = make_number (XINT (Flength (this)) - 1); | |
1582 last_is_meta = (XINT (last) >= 0 | |
1583 && EQ (Faref (this, last), meta_prefix_char)); | |
1576 | 1584 |
1577 QUIT; | 1585 QUIT; |
1578 | 1586 |
1579 while (CONSP (map)) | 1587 while (CONSP (map)) |
1580 { | 1588 { |
1585 | 1593 |
1586 For this reason, if Fcar (map) is a vector, we don't | 1594 For this reason, if Fcar (map) is a vector, we don't |
1587 advance map to the next element until i indicates that we | 1595 advance map to the next element until i indicates that we |
1588 have finished off the vector. */ | 1596 have finished off the vector. */ |
1589 | 1597 |
1590 Lisp_Object elt = XCONS (map)->car; | 1598 Lisp_Object elt, key, binding, sequence; |
1591 Lisp_Object key, binding, sequence; | 1599 elt = XCONS (map)->car; |
1592 | 1600 |
1593 QUIT; | 1601 QUIT; |
1594 | 1602 |
1595 /* Set key and binding to the current key and binding, and | 1603 /* Set key and binding to the current key and binding, and |
1596 advance map and i to the next binding. */ | 1604 advance map and i to the next binding. */ |