aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorKarl Heuer1994-09-27 02:26:34 +0000
committerKarl Heuer1994-09-27 02:26:34 +0000
commit416349ecf28b2a8b883aad1d798f0118265bc40c (patch)
treeb62b83b0516809d60402edd353c68e352bcf6f98 /src/keymap.c
parent65346ae61f1df4e7b291e9fb12dd8599712e8a2d (diff)
downloademacs-416349ecf28b2a8b883aad1d798f0118265bc40c.tar.gz
emacs-416349ecf28b2a8b883aad1d798f0118265bc40c.zip
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
current_minor_maps, Fkey_binding, Fminor_mode_key_binding, Fglobal_set_key, Flocal_set_key, Faccessible_keymaps, ascii_sequence_p, Fwhere_is_internal, describe_buffer_bindings, describe_map_tree, describe_command, describe_map, describe_vector): Use type test macros.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c86
1 files changed, 39 insertions, 47 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 76f59c2fa55..13b8b262237 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -374,8 +374,7 @@ get_keyelt (object, autoload)
374 object = XCONS (object)->cdr; 374 object = XCONS (object)->cdr;
375 /* Also remove a menu help string, if any, 375 /* Also remove a menu help string, if any,
376 following the menu item name. */ 376 following the menu item name. */
377 if (XTYPE (object) == Lisp_Cons 377 if (CONSP (object) && STRINGP (XCONS (object)->car))
378 && STRINGP (XCONS (object)->car) == Lisp_String)
379 object = XCONS (object)->cdr; 378 object = XCONS (object)->cdr;
380 /* Also remove the sublist that caches key equivalences, if any. */ 379 /* Also remove the sublist that caches key equivalences, if any. */
381 if (CONSP (object) 380 if (CONSP (object)
@@ -400,8 +399,7 @@ store_in_keymap (keymap, idx, def)
400 register Lisp_Object idx; 399 register Lisp_Object idx;
401 register Lisp_Object def; 400 register Lisp_Object def;
402{ 401{
403 if (XTYPE (keymap) != Lisp_Cons 402 if (!CONSP (keymap) || ! EQ (XCONS (keymap)->car, Qkeymap))
404 || ! EQ (XCONS (keymap)->car, Qkeymap))
405 error ("attempt to define a key in a non-keymap"); 403 error ("attempt to define a key in a non-keymap");
406 404
407 /* If idx is a list (some sort of mouse click, perhaps?), 405 /* If idx is a list (some sort of mouse click, perhaps?),
@@ -411,7 +409,7 @@ store_in_keymap (keymap, idx, def)
411 409
412 /* If idx is a symbol, it might have modifiers, which need to 410 /* If idx is a symbol, it might have modifiers, which need to
413 be put in the canonical order. */ 411 be put in the canonical order. */
414 if (XTYPE (idx) == Lisp_Symbol) 412 if (SYMBOLP (idx))
415 idx = reorder_modifiers (idx); 413 idx = reorder_modifiers (idx);
416 else if (INTEGERP (idx)) 414 else if (INTEGERP (idx))
417 /* Clobber the high bits that can be present on a machine 415 /* Clobber the high bits that can be present on a machine
@@ -439,7 +437,7 @@ store_in_keymap (keymap, idx, def)
439 switch (XTYPE (elt)) 437 switch (XTYPE (elt))
440 { 438 {
441 case Lisp_Vector: 439 case Lisp_Vector:
442 if (XTYPE (idx) == Lisp_Int 440 if (INTEGERP (idx)
443 && XINT (idx) >= 0 && XINT (idx) < XVECTOR (elt)->size) 441 && XINT (idx) >= 0 && XINT (idx) < XVECTOR (elt)->size)
444 { 442 {
445 XVECTOR (elt)->contents[XFASTINT (idx)] = def; 443 XVECTOR (elt)->contents[XFASTINT (idx)] = def;
@@ -499,7 +497,7 @@ is not copied.")
499 Lisp_Object elt; 497 Lisp_Object elt;
500 498
501 elt = XCONS (tail)->car; 499 elt = XCONS (tail)->car;
502 if (XTYPE (elt) == Lisp_Vector) 500 if (VECTORP (elt))
503 { 501 {
504 int i; 502 int i;
505 503
@@ -507,7 +505,7 @@ is not copied.")
507 XCONS (tail)->car = elt; 505 XCONS (tail)->car = elt;
508 506
509 for (i = 0; i < XVECTOR (elt)->size; i++) 507 for (i = 0; i < XVECTOR (elt)->size; i++)
510 if (XTYPE (XVECTOR (elt)->contents[i]) != Lisp_Symbol 508 if (!SYMBOLP (XVECTOR (elt)->contents[i])
511 && ! NILP (Fkeymapp (XVECTOR (elt)->contents[i]))) 509 && ! NILP (Fkeymapp (XVECTOR (elt)->contents[i])))
512 XVECTOR (elt)->contents[i] = 510 XVECTOR (elt)->contents[i] =
513 Fcopy_keymap (XVECTOR (elt)->contents[i]); 511 Fcopy_keymap (XVECTOR (elt)->contents[i]);
@@ -591,8 +589,7 @@ the front of KEYMAP.")
591 589
592 keymap = get_keymap_1 (keymap, 1, 1); 590 keymap = get_keymap_1 (keymap, 1, 1);
593 591
594 if (XTYPE (key) != Lisp_Vector 592 if (!VECTORP (key) && !STRINGP (key))
595 && XTYPE (key) != Lisp_String)
596 key = wrong_type_argument (Qarrayp, key); 593 key = wrong_type_argument (Qarrayp, key);
597 594
598 length = XFASTINT (Flength (key)); 595 length = XFASTINT (Flength (key));
@@ -601,7 +598,7 @@ the front of KEYMAP.")
601 598
602 GCPRO3 (keymap, key, def); 599 GCPRO3 (keymap, key, def);
603 600
604 if (XTYPE (key) == Lisp_Vector) 601 if (VECTORP (key))
605 meta_bit = meta_modifier; 602 meta_bit = meta_modifier;
606 else 603 else
607 meta_bit = 0x80; 604 meta_bit = 0x80;
@@ -611,7 +608,7 @@ the front of KEYMAP.")
611 { 608 {
612 c = Faref (key, make_number (idx)); 609 c = Faref (key, make_number (idx));
613 610
614 if (XTYPE (c) == Lisp_Int 611 if (INTEGERP (c)
615 && (XINT (c) & meta_bit) 612 && (XINT (c) & meta_bit)
616 && !metized) 613 && !metized)
617 { 614 {
@@ -620,7 +617,7 @@ the front of KEYMAP.")
620 } 617 }
621 else 618 else
622 { 619 {
623 if (XTYPE (c) == Lisp_Int) 620 if (INTEGERP (c))
624 XSETINT (c, XINT (c) & ~meta_bit); 621 XSETINT (c, XINT (c) & ~meta_bit);
625 622
626 metized = 0; 623 metized = 0;
@@ -683,15 +680,14 @@ recognize the default bindings, just as `read-key-sequence' does.")
683 680
684 keymap = get_keymap_1 (keymap, 1, 1); 681 keymap = get_keymap_1 (keymap, 1, 1);
685 682
686 if (XTYPE (key) != Lisp_Vector 683 if (!VECTORP (key) && !STRINGP (key))
687 && XTYPE (key) != Lisp_String)
688 key = wrong_type_argument (Qarrayp, key); 684 key = wrong_type_argument (Qarrayp, key);
689 685
690 length = XFASTINT (Flength (key)); 686 length = XFASTINT (Flength (key));
691 if (length == 0) 687 if (length == 0)
692 return keymap; 688 return keymap;
693 689
694 if (XTYPE (key) == Lisp_Vector) 690 if (VECTORP (key))
695 meta_bit = meta_modifier; 691 meta_bit = meta_modifier;
696 else 692 else
697 meta_bit = 0x80; 693 meta_bit = 0x80;
@@ -703,7 +699,7 @@ recognize the default bindings, just as `read-key-sequence' does.")
703 { 699 {
704 c = Faref (key, make_number (idx)); 700 c = Faref (key, make_number (idx));
705 701
706 if (XTYPE (c) == Lisp_Int 702 if (INTEGERP (c)
707 && (XINT (c) & meta_bit) 703 && (XINT (c) & meta_bit)
708 && !metized) 704 && !metized)
709 { 705 {
@@ -712,7 +708,7 @@ recognize the default bindings, just as `read-key-sequence' does.")
712 } 708 }
713 else 709 else
714 { 710 {
715 if (XTYPE (c) == Lisp_Int) 711 if (INTEGERP (c))
716 XSETINT (c, XINT (c) & ~meta_bit); 712 XSETINT (c, XINT (c) & ~meta_bit);
717 713
718 metized = 0; 714 metized = 0;
@@ -817,7 +813,7 @@ current_minor_maps (modeptr, mapptr)
817 CONSP (alist); 813 CONSP (alist);
818 alist = XCONS (alist)->cdr) 814 alist = XCONS (alist)->cdr)
819 if (CONSP (assoc = XCONS (alist)->car) 815 if (CONSP (assoc = XCONS (alist)->car)
820 && XTYPE (var = XCONS (assoc)->car) == Lisp_Symbol 816 && SYMBOLP (var = XCONS (assoc)->car)
821 && ! EQ ((val = find_symbol_value (var)), Qunbound) 817 && ! EQ ((val = find_symbol_value (var)), Qunbound)
822 && ! NILP (val)) 818 && ! NILP (val))
823 { 819 {
@@ -890,7 +886,7 @@ recognize the default bindings, just as `read-key-sequence' does.")
890 if (!NILP (Voverriding_local_map)) 886 if (!NILP (Voverriding_local_map))
891 { 887 {
892 value = Flookup_key (Voverriding_local_map, key, accept_default); 888 value = Flookup_key (Voverriding_local_map, key, accept_default);
893 if (! NILP (value) && XTYPE (value) != Lisp_Int) 889 if (! NILP (value) && !INTEGERP (value))
894 RETURN_UNGCPRO (value); 890 RETURN_UNGCPRO (value);
895 } 891 }
896 else 892 else
@@ -903,21 +899,21 @@ recognize the default bindings, just as `read-key-sequence' does.")
903 if (! NILP (maps[i])) 899 if (! NILP (maps[i]))
904 { 900 {
905 value = Flookup_key (maps[i], key, accept_default); 901 value = Flookup_key (maps[i], key, accept_default);
906 if (! NILP (value) && XTYPE (value) != Lisp_Int) 902 if (! NILP (value) && !INTEGERP (value))
907 RETURN_UNGCPRO (value); 903 RETURN_UNGCPRO (value);
908 } 904 }
909 905
910 if (! NILP (current_buffer->keymap)) 906 if (! NILP (current_buffer->keymap))
911 { 907 {
912 value = Flookup_key (current_buffer->keymap, key, accept_default); 908 value = Flookup_key (current_buffer->keymap, key, accept_default);
913 if (! NILP (value) && XTYPE (value) != Lisp_Int) 909 if (! NILP (value) && !INTEGERP (value))
914 RETURN_UNGCPRO (value); 910 RETURN_UNGCPRO (value);
915 } 911 }
916 } 912 }
917 913
918 value = Flookup_key (current_global_map, key, accept_default); 914 value = Flookup_key (current_global_map, key, accept_default);
919 UNGCPRO; 915 UNGCPRO;
920 if (! NILP (value) && XTYPE (value) != Lisp_Int) 916 if (! NILP (value) && !INTEGERP (value))
921 return value; 917 return value;
922 918
923 return Qnil; 919 return Qnil;
@@ -992,7 +988,7 @@ bindings; see the description of `lookup-key' for more details about this.")
992 for (i = j = 0; i < nmaps; i++) 988 for (i = j = 0; i < nmaps; i++)
993 if (! NILP (maps[i]) 989 if (! NILP (maps[i])
994 && ! NILP (binding = Flookup_key (maps[i], key, accept_default)) 990 && ! NILP (binding = Flookup_key (maps[i], key, accept_default))
995 && XTYPE (binding) != Lisp_Int) 991 && !INTEGERP (binding))
996 { 992 {
997 if (! NILP (get_keymap (binding))) 993 if (! NILP (get_keymap (binding)))
998 maps[j++] = Fcons (modes[i], binding); 994 maps[j++] = Fcons (modes[i], binding);
@@ -1016,8 +1012,7 @@ that local binding will continue to shadow any global binding.")
1016 (keys, function) 1012 (keys, function)
1017 Lisp_Object keys, function; 1013 Lisp_Object keys, function;
1018{ 1014{
1019 if (XTYPE (keys) != Lisp_Vector 1015 if (!VECTORP (keys) && !STRINGP (keys))
1020 && XTYPE (keys) != Lisp_String)
1021 keys = wrong_type_argument (Qarrayp, keys); 1016 keys = wrong_type_argument (Qarrayp, keys);
1022 1017
1023 Fdefine_key (current_global_map, keys, function); 1018 Fdefine_key (current_global_map, keys, function);
@@ -1044,8 +1039,7 @@ which in most cases is shared with all other buffers in the same major mode.")
1044 current_buffer->keymap = map; 1039 current_buffer->keymap = map;
1045 } 1040 }
1046 1041
1047 if (XTYPE (keys) != Lisp_Vector 1042 if (!VECTORP (keys) && !STRINGP (keys))
1048 && XTYPE (keys) != Lisp_String)
1049 keys = wrong_type_argument (Qarrayp, keys); 1043 keys = wrong_type_argument (Qarrayp, keys);
1050 1044
1051 Fdefine_key (map, keys, function); 1045 Fdefine_key (map, keys, function);
@@ -1215,7 +1209,7 @@ then the value includes only maps for prefixes that start with PREFIX.")
1215 1209
1216 QUIT; 1210 QUIT;
1217 1211
1218 if (XTYPE (elt) == Lisp_Vector) 1212 if (VECTORP (elt))
1219 { 1213 {
1220 register int i; 1214 register int i;
1221 1215
@@ -1282,7 +1276,7 @@ then the value includes only maps for prefixes that start with PREFIX.")
1282 /* If the last key in thisseq is meta-prefix-char, and 1276 /* If the last key in thisseq is meta-prefix-char, and
1283 this entry is a binding for an ascii keystroke, 1277 this entry is a binding for an ascii keystroke,
1284 turn it into a meta-ized keystroke. */ 1278 turn it into a meta-ized keystroke. */
1285 if (is_metized && XTYPE (elt) == Lisp_Int) 1279 if (is_metized && INTEGERP (elt))
1286 { 1280 {
1287 tem = Fcopy_sequence (thisseq); 1281 tem = Fcopy_sequence (thisseq);
1288 Faset (tem, last, 1282 Faset (tem, last,
@@ -1583,7 +1577,7 @@ ascii_sequence_p (seq)
1583 1577
1584 elt = Faref (seq, i); 1578 elt = Faref (seq, i);
1585 1579
1586 if (XTYPE (elt) != Lisp_Int 1580 if (!INTEGERP (elt)
1587 || (XUINT (elt) & ~CHAR_META) >= 0x80) 1581 || (XUINT (elt) & ~CHAR_META) >= 0x80)
1588 return 0; 1582 return 0;
1589 } 1583 }
@@ -1694,7 +1688,7 @@ indirect definition itself.")
1694 1688
1695 /* Set key and binding to the current key and binding, and 1689 /* Set key and binding to the current key and binding, and
1696 advance map and i to the next binding. */ 1690 advance map and i to the next binding. */
1697 if (XTYPE (elt) == Lisp_Vector) 1691 if (VECTORP (elt))
1698 { 1692 {
1699 /* In a vector, look at each element. */ 1693 /* In a vector, look at each element. */
1700 binding = XVECTOR (elt)->contents[i]; 1694 binding = XVECTOR (elt)->contents[i];
@@ -1732,7 +1726,7 @@ indirect definition itself.")
1732 /* End this iteration if this element does not match 1726 /* End this iteration if this element does not match
1733 the target. */ 1727 the target. */
1734 1728
1735 if (XTYPE (definition) == Lisp_Cons) 1729 if (CONSP (definition))
1736 { 1730 {
1737 Lisp_Object tem; 1731 Lisp_Object tem;
1738 tem = Fequal (binding, definition); 1732 tem = Fequal (binding, definition);
@@ -1745,7 +1739,7 @@ indirect definition itself.")
1745 1739
1746 /* We have found a match. 1740 /* We have found a match.
1747 Construct the key sequence where we found it. */ 1741 Construct the key sequence where we found it. */
1748 if (XTYPE (key) == Lisp_Int && last_is_meta) 1742 if (INTEGERP (key) && last_is_meta)
1749 { 1743 {
1750 sequence = Fcopy_sequence (this); 1744 sequence = Fcopy_sequence (this);
1751 Faset (sequence, last, make_number (XINT (key) | meta_modifier)); 1745 Faset (sequence, last, make_number (XINT (key) | meta_modifier));
@@ -1765,9 +1759,9 @@ indirect definition itself.")
1765 if (keymap_specified) 1759 if (keymap_specified)
1766 { 1760 {
1767 binding = Flookup_key (keymap, sequence, Qnil); 1761 binding = Flookup_key (keymap, sequence, Qnil);
1768 if (!NILP (binding) && XTYPE (binding) != Lisp_Int) 1762 if (!NILP (binding) && !INTEGERP (binding))
1769 { 1763 {
1770 if (XTYPE (definition) == Lisp_Cons) 1764 if (CONSP (definition))
1771 { 1765 {
1772 Lisp_Object tem; 1766 Lisp_Object tem;
1773 tem = Fequal (binding, definition); 1767 tem = Fequal (binding, definition);
@@ -1857,7 +1851,7 @@ nominal alternate\n\
1857 Fset_buffer (Vstandard_output); 1851 Fset_buffer (Vstandard_output);
1858 1852
1859 /* Report on alternates for keys. */ 1853 /* Report on alternates for keys. */
1860 if (XTYPE (Vkeyboard_translate_table) == Lisp_String) 1854 if (STRINGP (Vkeyboard_translate_table))
1861 { 1855 {
1862 int c; 1856 int c;
1863 unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data; 1857 unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data;
@@ -1909,7 +1903,7 @@ nominal alternate\n\
1909 because it takes care of other features when doing so. */ 1903 because it takes care of other features when doing so. */
1910 char *title, *p; 1904 char *title, *p;
1911 1905
1912 if (XTYPE (modes[i]) != Lisp_Symbol) 1906 if (!SYMBOLP (modes[i]))
1913 abort(); 1907 abort();
1914 1908
1915 p = title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size); 1909 p = title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size);
@@ -2032,10 +2026,8 @@ key binding\n\
2032 2026
2033 /* If the sequence by which we reach this keymap is zero-length, 2027 /* If the sequence by which we reach this keymap is zero-length,
2034 then the shadow map for this keymap is just SHADOW. */ 2028 then the shadow map for this keymap is just SHADOW. */
2035 if ((XTYPE (prefix) == Lisp_String 2029 if ((STRINGP (prefix) && XSTRING (prefix)->size == 0)
2036 && XSTRING (prefix)->size == 0) 2030 || (VECTORP (prefix) && XVECTOR (prefix)->size == 0))
2037 || (XTYPE (prefix) == Lisp_Vector
2038 && XVECTOR (prefix)->size == 0))
2039 ; 2031 ;
2040 /* If the sequence by which we reach this keymap actually has 2032 /* If the sequence by which we reach this keymap actually has
2041 some elements, then the sequence's definition in SHADOW is 2033 some elements, then the sequence's definition in SHADOW is
@@ -2043,7 +2035,7 @@ key binding\n\
2043 else 2035 else
2044 { 2036 {
2045 shmap = Flookup_key (shmap, Fcar (elt), Qt); 2037 shmap = Flookup_key (shmap, Fcar (elt), Qt);
2046 if (XTYPE (shmap) == Lisp_Int) 2038 if (INTEGERP (shmap))
2047 shmap = Qnil; 2039 shmap = Qnil;
2048 } 2040 }
2049 2041
@@ -2077,7 +2069,7 @@ describe_command (definition)
2077 2069
2078 Findent_to (make_number (16), make_number (1)); 2070 Findent_to (make_number (16), make_number (1));
2079 2071
2080 if (XTYPE (definition) == Lisp_Symbol) 2072 if (SYMBOLP (definition))
2081 { 2073 {
2082 XSET (tem1, Lisp_String, XSYMBOL (definition)->name); 2074 XSET (tem1, Lisp_String, XSYMBOL (definition)->name);
2083 insert1 (tem1); 2075 insert1 (tem1);
@@ -2158,7 +2150,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen)
2158 { 2150 {
2159 QUIT; 2151 QUIT;
2160 2152
2161 if (XTYPE (XCONS (tail)->car) == Lisp_Vector) 2153 if (VECTORP (XCONS (tail)->car))
2162 describe_vector (XCONS (tail)->car, 2154 describe_vector (XCONS (tail)->car,
2163 elt_prefix, elt_describer, partial, shadow); 2155 elt_prefix, elt_describer, partial, shadow);
2164 else if (CONSP (XCONS (tail)->car)) 2156 else if (CONSP (XCONS (tail)->car))
@@ -2174,7 +2166,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen)
2174 2166
2175 /* Don't show undefined commands or suppressed commands. */ 2167 /* Don't show undefined commands or suppressed commands. */
2176 if (NILP (definition)) continue; 2168 if (NILP (definition)) continue;
2177 if (XTYPE (definition) == Lisp_Symbol && partial) 2169 if (SYMBOLP (definition) && partial)
2178 { 2170 {
2179 tem = Fget (definition, suppress); 2171 tem = Fget (definition, suppress);
2180 if (!NILP (tem)) 2172 if (!NILP (tem))
@@ -2285,7 +2277,7 @@ describe_vector (vector, elt_prefix, elt_describer, partial, shadow)
2285 if (NILP (tem1)) continue; 2277 if (NILP (tem1)) continue;
2286 2278
2287 /* Don't mention suppressed commands. */ 2279 /* Don't mention suppressed commands. */
2288 if (XTYPE (tem1) == Lisp_Symbol && partial) 2280 if (SYMBOLP (tem1) && partial)
2289 { 2281 {
2290 this = Fget (tem1, suppress); 2282 this = Fget (tem1, suppress);
2291 if (!NILP (this)) 2283 if (!NILP (this))