comparison src/keymap.c @ 6774:a29237d1fdca

(get_keymap): Pass 1 as ERROR to get_keymap_1. (get_keyelt): New arg AUTOLOAD means load keymaps indirected thru. All callers changed; most pass 0. (Fdefine_key, Flookup_key): Load all the keymaps we look in.
author Richard M. Stallman <rms@gnu.org>
date Sat, 09 Apr 1994 21:09:34 +0000
parents c66bed2f25af
children 6a77fcbb5d44
comparison
equal deleted inserted replaced
6773:ed16e189b9a5 6774:a29237d1fdca
244 If OBJECT doesn't denote a keymap at all, signal an error. */ 244 If OBJECT doesn't denote a keymap at all, signal an error. */
245 Lisp_Object 245 Lisp_Object
246 get_keymap (object) 246 get_keymap (object)
247 Lisp_Object object; 247 Lisp_Object object;
248 { 248 {
249 return get_keymap_1 (object, 0, 0); 249 return get_keymap_1 (object, 1, 0);
250 } 250 }
251 251
252 252
253 /* Look up IDX in MAP. IDX may be any sort of event. 253 /* Look up IDX in MAP. IDX may be any sort of event.
254 Note that this does only one level of lookup; IDX must be a single 254 Note that this does only one level of lookup; IDX must be a single
342 An indirect definition is a list of the form 342 An indirect definition is a list of the form
343 (KEYMAP . INDEX), where KEYMAP is a keymap or a symbol defined as one 343 (KEYMAP . INDEX), where KEYMAP is a keymap or a symbol defined as one
344 and INDEX is the object to look up in KEYMAP to yield the definition. 344 and INDEX is the object to look up in KEYMAP to yield the definition.
345 345
346 Also if OBJECT has a menu string as the first element, 346 Also if OBJECT has a menu string as the first element,
347 remove that. Also remove a menu help string as second element. */ 347 remove that. Also remove a menu help string as second element.
348
349 If AUTOLOAD is nonzero, load autoloadable keymaps
350 that are referred to with indirection. */
348 351
349 Lisp_Object 352 Lisp_Object
350 get_keyelt (object) 353 get_keyelt (object, autoload)
351 register Lisp_Object object; 354 register Lisp_Object object;
355 int autoload;
352 { 356 {
353 while (1) 357 while (1)
354 { 358 {
355 register Lisp_Object map, tem; 359 register Lisp_Object map, tem;
356 360
357 /* If the contents are (KEYMAP . ELEMENT), go indirect. */ 361 /* If the contents are (KEYMAP . ELEMENT), go indirect. */
358 map = get_keymap_1 (Fcar_safe (object), 0, 0); 362 map = get_keymap_1 (Fcar_safe (object), 0, autoload);
359 tem = Fkeymapp (map); 363 tem = Fkeymapp (map);
360 if (!NILP (tem)) 364 if (!NILP (tem))
361 object = access_keymap (map, Fcdr (object), 0, 0); 365 object = access_keymap (map, Fcdr (object), 0, 0);
362 366
363 /* If the keymap contents looks like (STRING . DEFN), 367 /* If the keymap contents looks like (STRING . DEFN),
581 int metized = 0; 585 int metized = 0;
582 int meta_bit; 586 int meta_bit;
583 int length; 587 int length;
584 struct gcpro gcpro1, gcpro2, gcpro3; 588 struct gcpro gcpro1, gcpro2, gcpro3;
585 589
586 keymap = get_keymap (keymap); 590 keymap = get_keymap_1 (keymap, 1, 1);
587 591
588 if (XTYPE (key) != Lisp_Vector 592 if (XTYPE (key) != Lisp_Vector
589 && XTYPE (key) != Lisp_String) 593 && XTYPE (key) != Lisp_String)
590 key = wrong_type_argument (Qarrayp, key); 594 key = wrong_type_argument (Qarrayp, key);
591 595
625 error ("Key sequence contains illegal events"); 629 error ("Key sequence contains illegal events");
626 630
627 if (idx == length) 631 if (idx == length)
628 RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); 632 RETURN_UNGCPRO (store_in_keymap (keymap, c, def));
629 633
630 cmd = get_keyelt (access_keymap (keymap, c, 0, 1)); 634 cmd = get_keyelt (access_keymap (keymap, c, 0, 1), 1);
631 635
632 /* If this key is undefined, make it a prefix. */ 636 /* If this key is undefined, make it a prefix. */
633 if (NILP (cmd)) 637 if (NILP (cmd))
634 cmd = define_as_prefix (keymap, c); 638 cmd = define_as_prefix (keymap, c);
635 639
671 int metized = 0; 675 int metized = 0;
672 int length; 676 int length;
673 int t_ok = ! NILP (accept_default); 677 int t_ok = ! NILP (accept_default);
674 int meta_bit; 678 int meta_bit;
675 679
676 keymap = get_keymap (keymap); 680 keymap = get_keymap_1 (keymap, 1, 1);
677 681
678 if (XTYPE (key) != Lisp_Vector 682 if (XTYPE (key) != Lisp_Vector
679 && XTYPE (key) != Lisp_String) 683 && XTYPE (key) != Lisp_String)
680 key = wrong_type_argument (Qarrayp, key); 684 key = wrong_type_argument (Qarrayp, key);
681 685
707 711
708 metized = 0; 712 metized = 0;
709 idx++; 713 idx++;
710 } 714 }
711 715
712 cmd = get_keyelt (access_keymap (keymap, c, t_ok, 0)); 716 cmd = get_keyelt (access_keymap (keymap, c, t_ok, 0), 1);
713 if (idx == length) 717 if (idx == length)
714 return cmd; 718 return cmd;
715 719
716 keymap = get_keymap_1 (cmd, 0, 0); 720 keymap = get_keymap_1 (cmd, 0, 1);
717 if (NILP (keymap)) 721 if (NILP (keymap))
718 return make_number (idx); 722 return make_number (idx);
719 723
720 QUIT; 724 QUIT;
721 } 725 }
1168 for (i = 0; i < XVECTOR (elt)->size; i++) 1172 for (i = 0; i < XVECTOR (elt)->size; i++)
1169 { 1173 {
1170 register Lisp_Object tem; 1174 register Lisp_Object tem;
1171 register Lisp_Object cmd; 1175 register Lisp_Object cmd;
1172 1176
1173 cmd = get_keyelt (XVECTOR (elt)->contents[i]); 1177 cmd = get_keyelt (XVECTOR (elt)->contents[i], 0);
1174 if (NILP (cmd)) continue; 1178 if (NILP (cmd)) continue;
1175 tem = Fkeymapp (cmd); 1179 tem = Fkeymapp (cmd);
1176 if (!NILP (tem)) 1180 if (!NILP (tem))
1177 { 1181 {
1178 cmd = get_keymap (cmd); 1182 cmd = get_keymap (cmd);
1209 } 1213 }
1210 else if (CONSP (elt)) 1214 else if (CONSP (elt))
1211 { 1215 {
1212 register Lisp_Object cmd, tem, filter; 1216 register Lisp_Object cmd, tem, filter;
1213 1217
1214 cmd = get_keyelt (XCONS (elt)->cdr); 1218 cmd = get_keyelt (XCONS (elt)->cdr, 0);
1215 /* Ignore definitions that aren't keymaps themselves. */ 1219 /* Ignore definitions that aren't keymaps themselves. */
1216 tem = Fkeymapp (cmd); 1220 tem = Fkeymapp (cmd);
1217 if (!NILP (tem)) 1221 if (!NILP (tem))
1218 { 1222 {
1219 /* Ignore keymaps that have been seen already. */ 1223 /* Ignore keymaps that have been seen already. */
1633 continue; 1637 continue;
1634 } 1638 }
1635 1639
1636 /* Search through indirections unless that's not wanted. */ 1640 /* Search through indirections unless that's not wanted. */
1637 if (NILP (noindirect)) 1641 if (NILP (noindirect))
1638 binding = get_keyelt (binding); 1642 binding = get_keyelt (binding, 0);
1639 1643
1640 /* End this iteration if this element does not match 1644 /* End this iteration if this element does not match
1641 the target. */ 1645 the target. */
1642 1646
1643 if (XTYPE (definition) == Lisp_Cons) 1647 if (XTYPE (definition) == Lisp_Cons)
2080 describe_vector (XCONS (tail)->car, 2084 describe_vector (XCONS (tail)->car,
2081 elt_prefix, elt_describer, partial, shadow); 2085 elt_prefix, elt_describer, partial, shadow);
2082 else 2086 else
2083 { 2087 {
2084 event = Fcar_safe (Fcar (tail)); 2088 event = Fcar_safe (Fcar (tail));
2085 definition = get_keyelt (Fcdr_safe (Fcar (tail))); 2089 definition = get_keyelt (Fcdr_safe (Fcar (tail)), 0);
2086 2090
2087 /* Don't show undefined commands or suppressed commands. */ 2091 /* Don't show undefined commands or suppressed commands. */
2088 if (NILP (definition)) continue; 2092 if (NILP (definition)) continue;
2089 if (XTYPE (definition) == Lisp_Symbol && partial) 2093 if (XTYPE (definition) == Lisp_Symbol && partial)
2090 { 2094 {
2180 suppress = intern ("suppress-keymap"); 2184 suppress = intern ("suppress-keymap");
2181 2185
2182 for (i = 0; i < XVECTOR (vector)->size; i++) 2186 for (i = 0; i < XVECTOR (vector)->size; i++)
2183 { 2187 {
2184 QUIT; 2188 QUIT;
2185 tem1 = get_keyelt (XVECTOR (vector)->contents[i]); 2189 tem1 = get_keyelt (XVECTOR (vector)->contents[i], 0);
2186 2190
2187 if (NILP (tem1)) continue; 2191 if (NILP (tem1)) continue;
2188 2192
2189 /* Don't mention suppressed commands. */ 2193 /* Don't mention suppressed commands. */
2190 if (XTYPE (tem1) == Lisp_Symbol && partial) 2194 if (XTYPE (tem1) == Lisp_Symbol && partial)
2223 this = Fsingle_key_description (dummy); 2227 this = Fsingle_key_description (dummy);
2224 insert1 (this); 2228 insert1 (this);
2225 2229
2226 /* Find all consecutive characters that have the same definition. */ 2230 /* Find all consecutive characters that have the same definition. */
2227 while (i + 1 < XVECTOR (vector)->size 2231 while (i + 1 < XVECTOR (vector)->size
2228 && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1]), 2232 && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1], 0),
2229 EQ (tem2, tem1))) 2233 EQ (tem2, tem1)))
2230 i++; 2234 i++;
2231 2235
2232 /* If we have a range of more than one character, 2236 /* If we have a range of more than one character,
2233 print where the range reaches to. */ 2237 print where the range reaches to. */