aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorMiles Bader2004-06-28 07:56:49 +0000
committerMiles Bader2004-06-28 07:56:49 +0000
commit327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801 (patch)
tree21de188e13b5e41a79bb50040933072ae0235217 /src/keymap.c
parent852f73b7fa7b71910282eacb6263b3ecfd4ee783 (diff)
parent376de73927383d6062483db10b8a82448505f52b (diff)
downloademacs-327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801.tar.gz
emacs-327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c233
1 files changed, 137 insertions, 96 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 62ea237b85c..fbf1263a71b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -122,6 +122,9 @@ static void describe_translation P_ ((Lisp_Object, Lisp_Object));
122static void describe_map P_ ((Lisp_Object, Lisp_Object, 122static void describe_map P_ ((Lisp_Object, Lisp_Object,
123 void (*) P_ ((Lisp_Object, Lisp_Object)), 123 void (*) P_ ((Lisp_Object, Lisp_Object)),
124 int, Lisp_Object, Lisp_Object*, int)); 124 int, Lisp_Object, Lisp_Object*, int));
125static void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
126 void (*) (Lisp_Object, Lisp_Object), int,
127 Lisp_Object, Lisp_Object, int *, int, int));
125static void silly_event_symbol_error P_ ((Lisp_Object)); 128static void silly_event_symbol_error P_ ((Lisp_Object));
126 129
127/* Keymap object support - constructors and predicates. */ 130/* Keymap object support - constructors and predicates. */
@@ -1098,15 +1101,15 @@ event type that has no other definition in this keymap.
1098 1101
1099DEF is anything that can be a key's definition: 1102DEF is anything that can be a key's definition:
1100 nil (means key is undefined in this keymap), 1103 nil (means key is undefined in this keymap),
1101 a command (a Lisp function suitable for interactive calling) 1104 a command (a Lisp function suitable for interactive calling),
1102 a string (treated as a keyboard macro), 1105 a string (treated as a keyboard macro),
1103 a keymap (to define a prefix key), 1106 a keymap (to define a prefix key),
1104 a symbol. When the key is looked up, the symbol will stand for its 1107 a symbol (when the key is looked up, the symbol will stand for its
1105 function definition, which should at that time be one of the above, 1108 function definition, which should at that time be one of the above,
1106 or another symbol whose function definition is used, etc. 1109 or another symbol whose function definition is used, etc.),
1107 a cons (STRING . DEFN), meaning that DEFN is the definition 1110 a cons (STRING . DEFN), meaning that DEFN is the definition
1108 (DEFN should be a valid definition in its own right), 1111 (DEFN should be a valid definition in its own right),
1109 or a cons (KEYMAP . CHAR), meaning use definition of CHAR in map KEYMAP. 1112 or a cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP.
1110 1113
1111If KEYMAP is a sparse keymap with a binding for KEY, the existing 1114If KEYMAP is a sparse keymap with a binding for KEY, the existing
1112binding is altered. If there is no binding for KEY, the new pair 1115binding is altered. If there is no binding for KEY, the new pair
@@ -1193,7 +1196,7 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1193 /* We must use Fkey_description rather than just passing key to 1196 /* We must use Fkey_description rather than just passing key to
1194 error; key might be a vector, not a string. */ 1197 error; key might be a vector, not a string. */
1195 error ("Key sequence %s uses invalid prefix characters", 1198 error ("Key sequence %s uses invalid prefix characters",
1196 SDATA (Fkey_description (key))); 1199 SDATA (Fkey_description (key, Qnil)));
1197 } 1200 }
1198} 1201}
1199 1202
@@ -1653,7 +1656,7 @@ DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 2, 0,
1653 doc: /* Return the binding for command KEYS in current global keymap only. 1656 doc: /* Return the binding for command KEYS in current global keymap only.
1654KEYS is a string, a sequence of keystrokes. 1657KEYS is a string, a sequence of keystrokes.
1655The binding is probably a symbol with a function definition. 1658The binding is probably a symbol with a function definition.
1656This function's return values are the same as those of lookup-key 1659This function's return values are the same as those of `lookup-key'
1657\(which see). 1660\(which see).
1658 1661
1659If optional argument ACCEPT-DEFAULT is non-nil, recognize default 1662If optional argument ACCEPT-DEFAULT is non-nil, recognize default
@@ -1974,78 +1977,109 @@ Lisp_Object Qsingle_key_description, Qkey_description;
1974 1977
1975/* This function cannot GC. */ 1978/* This function cannot GC. */
1976 1979
1977DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0, 1980DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0,
1978 doc: /* Return a pretty description of key-sequence KEYS. 1981 doc: /* Return a pretty description of key-sequence KEYS.
1979Control characters turn into "C-foo" sequences, meta into "M-foo" 1982Optional arg PREFIX is the sequence of keys leading up to KEYS.
1983Control characters turn into "C-foo" sequences, meta into "M-foo",
1980spaces are put between sequence elements, etc. */) 1984spaces are put between sequence elements, etc. */)
1981 (keys) 1985 (keys, prefix)
1982 Lisp_Object keys; 1986 Lisp_Object keys, prefix;
1983{ 1987{
1984 int len = 0; 1988 int len = 0;
1985 int i, i_byte; 1989 int i, i_byte;
1986 Lisp_Object sep; 1990 Lisp_Object *args;
1987 Lisp_Object *args = NULL; 1991 int size = XINT (Flength (keys));
1992 Lisp_Object list;
1993 Lisp_Object sep = build_string (" ");
1994 Lisp_Object key;
1995 int add_meta = 0;
1996
1997 if (!NILP (prefix))
1998 size += XINT (Flength (prefix));
1999
2000 /* This has one extra element at the end that we don't pass to Fconcat. */
2001 args = (Lisp_Object *) alloca (size * 4 * sizeof (Lisp_Object));
1988 2002
1989 if (STRINGP (keys)) 2003 /* In effect, this computes
2004 (mapconcat 'single-key-description keys " ")
2005 but we shouldn't use mapconcat because it can do GC. */
2006
2007 next_list:
2008 if (!NILP (prefix))
2009 list = prefix, prefix = Qnil;
2010 else if (!NILP (keys))
2011 list = keys, keys = Qnil;
2012 else
1990 { 2013 {
1991 Lisp_Object vector; 2014 if (add_meta)
1992 vector = Fmake_vector (Flength (keys), Qnil);
1993 for (i = 0, i_byte = 0; i < SCHARS (keys); )
1994 { 2015 {
1995 int c; 2016 args[len] = Fsingle_key_description (meta_prefix_char, Qnil);
1996 int i_before = i; 2017 len += 2;
1997
1998 FETCH_STRING_CHAR_ADVANCE (c, keys, i, i_byte);
1999 if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
2000 c ^= 0200 | meta_modifier;
2001 XSETFASTINT (AREF (vector, i_before), c);
2002 } 2018 }
2003 keys = vector; 2019 else if (len == 0)
2020 return empty_string;
2021 return Fconcat (len - 1, args);
2004 } 2022 }
2005 2023
2006 if (VECTORP (keys)) 2024 if (STRINGP (list))
2007 { 2025 size = SCHARS (list);
2008 /* In effect, this computes 2026 else if (VECTORP (list))
2009 (mapconcat 'single-key-description keys " ") 2027 size = XVECTOR (list)->size;
2010 but we shouldn't use mapconcat because it can do GC. */ 2028 else if (CONSP (list))
2029 size = XINT (Flength (list));
2030 else
2031 wrong_type_argument (Qarrayp, list);
2011 2032
2012 len = XVECTOR (keys)->size; 2033 i = i_byte = 0;
2013 sep = build_string (" ");
2014 /* This has one extra element at the end that we don't pass to Fconcat. */
2015 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
2016 2034
2017 for (i = 0; i < len; i++) 2035 while (i < size)
2036 {
2037 if (STRINGP (list))
2018 { 2038 {
2019 args[i * 2] = Fsingle_key_description (AREF (keys, i), Qnil); 2039 int c;
2020 args[i * 2 + 1] = sep; 2040 FETCH_STRING_CHAR_ADVANCE (c, list, i, i_byte);
2041 if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
2042 c ^= 0200 | meta_modifier;
2043 XSETFASTINT (key, c);
2044 }
2045 else if (VECTORP (list))
2046 {
2047 key = AREF (list, i++);
2048 }
2049 else
2050 {
2051 key = XCAR (list);
2052 list = XCDR (list);
2053 i++;
2021 } 2054 }
2022 }
2023 else if (CONSP (keys))
2024 {
2025 /* In effect, this computes
2026 (mapconcat 'single-key-description keys " ")
2027 but we shouldn't use mapconcat because it can do GC. */
2028
2029 len = XFASTINT (Flength (keys));
2030 sep = build_string (" ");
2031 /* This has one extra element at the end that we don't pass to Fconcat. */
2032 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
2033 2055
2034 for (i = 0; i < len; i++) 2056 if (add_meta)
2057 {
2058 if (!INTEGERP (key)
2059 || EQ (key, meta_prefix_char)
2060 || (XINT (key) & meta_modifier))
2061 {
2062 args[len++] = Fsingle_key_description (meta_prefix_char, Qnil);
2063 args[len++] = sep;
2064 if (EQ (key, meta_prefix_char))
2065 continue;
2066 }
2067 else
2068 XSETINT (key, (XINT (key) | meta_modifier) & ~0x80);
2069 add_meta = 0;
2070 }
2071 else if (EQ (key, meta_prefix_char))
2035 { 2072 {
2036 args[i * 2] = Fsingle_key_description (XCAR (keys), Qnil); 2073 add_meta = 1;
2037 args[i * 2 + 1] = sep; 2074 continue;
2038 keys = XCDR (keys);
2039 } 2075 }
2076 args[len++] = Fsingle_key_description (key, Qnil);
2077 args[len++] = sep;
2040 } 2078 }
2041 else 2079 goto next_list;
2042 keys = wrong_type_argument (Qarrayp, keys);
2043
2044 if (len == 0)
2045 return empty_string;
2046 return Fconcat (len * 2 - 1, args);
2047} 2080}
2048 2081
2082
2049char * 2083char *
2050push_key_description (c, p, force_multibyte) 2084push_key_description (c, p, force_multibyte)
2051 register unsigned int c; 2085 register unsigned int c;
@@ -2926,7 +2960,7 @@ key binding\n\
2926 if (!NILP (prefix)) 2960 if (!NILP (prefix))
2927 { 2961 {
2928 insert_string (" Starting With "); 2962 insert_string (" Starting With ");
2929 insert1 (Fkey_description (prefix)); 2963 insert1 (Fkey_description (prefix, Qnil));
2930 } 2964 }
2931 insert_string (":\n"); 2965 insert_string (":\n");
2932 } 2966 }
@@ -3051,7 +3085,7 @@ describe_translation (definition, args)
3051 } 3085 }
3052 else if (STRINGP (definition) || VECTORP (definition)) 3086 else if (STRINGP (definition) || VECTORP (definition))
3053 { 3087 {
3054 insert1 (Fkey_description (definition)); 3088 insert1 (Fkey_description (definition, Qnil));
3055 insert_string ("\n"); 3089 insert_string ("\n");
3056 } 3090 }
3057 else if (KEYMAPP (definition)) 3091 else if (KEYMAPP (definition))
@@ -3061,20 +3095,19 @@ describe_translation (definition, args)
3061} 3095}
3062 3096
3063/* Describe the contents of map MAP, assuming that this map itself is 3097/* Describe the contents of map MAP, assuming that this map itself is
3064 reached by the sequence of prefix keys KEYS (a string or vector). 3098 reached by the sequence of prefix keys PREFIX (a string or vector).
3065 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ 3099 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */
3066 3100
3067static void 3101static void
3068describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) 3102describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu)
3069 register Lisp_Object map; 3103 register Lisp_Object map;
3070 Lisp_Object keys; 3104 Lisp_Object prefix;
3071 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); 3105 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object));
3072 int partial; 3106 int partial;
3073 Lisp_Object shadow; 3107 Lisp_Object shadow;
3074 Lisp_Object *seen; 3108 Lisp_Object *seen;
3075 int nomenu; 3109 int nomenu;
3076{ 3110{
3077 Lisp_Object elt_prefix;
3078 Lisp_Object tail, definition, event; 3111 Lisp_Object tail, definition, event;
3079 Lisp_Object tem; 3112 Lisp_Object tem;
3080 Lisp_Object suppress; 3113 Lisp_Object suppress;
@@ -3084,15 +3117,6 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3084 3117
3085 suppress = Qnil; 3118 suppress = Qnil;
3086 3119
3087 if (!NILP (keys) && XFASTINT (Flength (keys)) > 0)
3088 {
3089 /* Call Fkey_description first, to avoid GC bug for the other string. */
3090 tem = Fkey_description (keys);
3091 elt_prefix = concat2 (tem, build_string (" "));
3092 }
3093 else
3094 elt_prefix = Qnil;
3095
3096 if (partial) 3120 if (partial)
3097 suppress = intern ("suppress-keymap"); 3121 suppress = intern ("suppress-keymap");
3098 3122
@@ -3102,7 +3126,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3102 kludge = Fmake_vector (make_number (1), Qnil); 3126 kludge = Fmake_vector (make_number (1), Qnil);
3103 definition = Qnil; 3127 definition = Qnil;
3104 3128
3105 GCPRO3 (elt_prefix, definition, kludge); 3129 GCPRO3 (prefix, definition, kludge);
3106 3130
3107 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3131 for (tail = map; CONSP (tail); tail = XCDR (tail))
3108 { 3132 {
@@ -3111,13 +3135,13 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3111 if (VECTORP (XCAR (tail)) 3135 if (VECTORP (XCAR (tail))
3112 || CHAR_TABLE_P (XCAR (tail))) 3136 || CHAR_TABLE_P (XCAR (tail)))
3113 describe_vector (XCAR (tail), 3137 describe_vector (XCAR (tail),
3114 elt_prefix, Qnil, elt_describer, partial, shadow, map, 3138 prefix, Qnil, elt_describer, partial, shadow, map,
3115 (int *)0, 0); 3139 (int *)0, 0, 1);
3116 else if (CONSP (XCAR (tail))) 3140 else if (CONSP (XCAR (tail)))
3117 { 3141 {
3118 event = XCAR (XCAR (tail)); 3142 event = XCAR (XCAR (tail));
3119 3143
3120 /* Ignore bindings whose "keys" are not really valid events. 3144 /* Ignore bindings whose "prefix" are not really valid events.
3121 (We get these in the frames and buffers menu.) */ 3145 (We get these in the frames and buffers menu.) */
3122 if (!(SYMBOLP (event) || INTEGERP (event))) 3146 if (!(SYMBOLP (event) || INTEGERP (event)))
3123 continue; 3147 continue;
@@ -3156,11 +3180,8 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3156 first = 0; 3180 first = 0;
3157 } 3181 }
3158 3182
3159 if (!NILP (elt_prefix))
3160 insert1 (elt_prefix);
3161
3162 /* THIS gets the string to describe the character EVENT. */ 3183 /* THIS gets the string to describe the character EVENT. */
3163 insert1 (Fsingle_key_description (event, Qnil)); 3184 insert1 (Fkey_description (kludge, prefix));
3164 3185
3165 /* Print a description of the definition of this character. 3186 /* Print a description of the definition of this character.
3166 elt_describer will take care of spacing out far enough 3187 elt_describer will take care of spacing out far enough
@@ -3173,9 +3194,9 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3173 using an inherited keymap. So skip anything we've already 3194 using an inherited keymap. So skip anything we've already
3174 encountered. */ 3195 encountered. */
3175 tem = Fassq (tail, *seen); 3196 tem = Fassq (tail, *seen);
3176 if (CONSP (tem) && !NILP (Fequal (XCAR (tem), keys))) 3197 if (CONSP (tem) && !NILP (Fequal (XCAR (tem), prefix)))
3177 break; 3198 break;
3178 *seen = Fcons (Fcons (tail, keys), *seen); 3199 *seen = Fcons (Fcons (tail, prefix), *seen);
3179 } 3200 }
3180 } 3201 }
3181 3202
@@ -3193,7 +3214,8 @@ describe_vector_princ (elt, fun)
3193 3214
3194DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0, 3215DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0,
3195 doc: /* Insert a description of contents of VECTOR. 3216 doc: /* Insert a description of contents of VECTOR.
3196This is text showing the elements of vector matched against indices. */) 3217This is text showing the elements of vector matched against indices.
3218DESCRIBER is the output function used; nil means use `princ'. */)
3197 (vector, describer) 3219 (vector, describer)
3198 Lisp_Object vector, describer; 3220 Lisp_Object vector, describer;
3199{ 3221{
@@ -3203,7 +3225,7 @@ This is text showing the elements of vector matched against indices. */)
3203 specbind (Qstandard_output, Fcurrent_buffer ()); 3225 specbind (Qstandard_output, Fcurrent_buffer ());
3204 CHECK_VECTOR_OR_CHAR_TABLE (vector); 3226 CHECK_VECTOR_OR_CHAR_TABLE (vector);
3205 describe_vector (vector, Qnil, describer, describe_vector_princ, 0, 3227 describe_vector (vector, Qnil, describer, describe_vector_princ, 0,
3206 Qnil, Qnil, (int *)0, 0); 3228 Qnil, Qnil, (int *)0, 0, 0);
3207 3229
3208 return unbind_to (count, Qnil); 3230 return unbind_to (count, Qnil);
3209} 3231}
@@ -3237,42 +3259,60 @@ This is text showing the elements of vector matched against indices. */)
3237 ARGS is simply passed as the second argument to ELT_DESCRIBER. 3259 ARGS is simply passed as the second argument to ELT_DESCRIBER.
3238 3260
3239 INDICES and CHAR_TABLE_DEPTH are ignored. They will be removed in 3261 INDICES and CHAR_TABLE_DEPTH are ignored. They will be removed in
3240 the near future. */ 3262 the near future.
3241 3263
3242void 3264 KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-.
3243describe_vector (vector, elt_prefix, args, elt_describer, 3265
3266 ARGS is simply passed as the second argument to ELT_DESCRIBER. */
3267
3268static void
3269describe_vector (vector, prefix, args, elt_describer,
3244 partial, shadow, entire_map, 3270 partial, shadow, entire_map,
3245 indices, char_table_depth) 3271 indices, char_table_depth, keymap_p)
3246 register Lisp_Object vector; 3272 register Lisp_Object vector;
3247 Lisp_Object elt_prefix, args; 3273 Lisp_Object prefix, args;
3248 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); 3274 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object));
3249 int partial; 3275 int partial;
3250 Lisp_Object shadow; 3276 Lisp_Object shadow;
3251 Lisp_Object entire_map; 3277 Lisp_Object entire_map;
3252 int *indices; 3278 int *indices;
3253 int char_table_depth; 3279 int char_table_depth;
3280 int keymap_p;
3254{ 3281{
3255 Lisp_Object definition; 3282 Lisp_Object definition;
3256 Lisp_Object tem2; 3283 Lisp_Object tem2;
3284 Lisp_Object elt_prefix = Qnil;
3257 int i; 3285 int i;
3258 Lisp_Object suppress; 3286 Lisp_Object suppress;
3259 Lisp_Object kludge; 3287 Lisp_Object kludge;
3260 struct gcpro gcpro1, gcpro2, gcpro3; 3288 int first = 1;
3289 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3261 /* Range of elements to be handled. */ 3290 /* Range of elements to be handled. */
3262 int from, to; 3291 int from, to;
3263 Lisp_Object character; 3292 Lisp_Object character;
3264 int starting_i; 3293 int starting_i;
3265 int first = 1;
3266 3294
3267 suppress = Qnil; 3295 suppress = Qnil;
3268 3296
3269 definition = Qnil; 3297 definition = Qnil;
3270 3298
3299 if (!keymap_p)
3300 {
3301 /* Call Fkey_description first, to avoid GC bug for the other string. */
3302 if (!NILP (prefix) && XFASTINT (Flength (prefix)) > 0)
3303 {
3304 Lisp_Object tem;
3305 tem = Fkey_description (prefix, Qnil);
3306 elt_prefix = concat2 (tem, build_string (" "));
3307 }
3308 prefix = Qnil;
3309 }
3310
3271 /* This vector gets used to present single keys to Flookup_key. Since 3311 /* This vector gets used to present single keys to Flookup_key. Since
3272 that is done once per vector element, we don't want to cons up a 3312 that is done once per vector element, we don't want to cons up a
3273 fresh vector every time. */ 3313 fresh vector every time. */
3274 kludge = Fmake_vector (make_number (1), Qnil); 3314 kludge = Fmake_vector (make_number (1), Qnil);
3275 GCPRO3 (elt_prefix, definition, kludge); 3315 GCPRO4 (elt_prefix, prefix, definition, kludge);
3276 3316
3277 if (partial) 3317 if (partial)
3278 suppress = intern ("suppress-keymap"); 3318 suppress = intern ("suppress-keymap");
@@ -3308,13 +3348,13 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3308 } 3348 }
3309 3349
3310 character = make_number (starting_i); 3350 character = make_number (starting_i);
3351 ASET (kludge, 0, character);
3311 3352
3312 /* If this binding is shadowed by some other map, ignore it. */ 3353 /* If this binding is shadowed by some other map, ignore it. */
3313 if (!NILP (shadow)) 3354 if (!NILP (shadow))
3314 { 3355 {
3315 Lisp_Object tem; 3356 Lisp_Object tem;
3316 3357
3317 ASET (kludge, 0, character);
3318 tem = shadow_lookup (shadow, kludge, Qt); 3358 tem = shadow_lookup (shadow, kludge, Qt);
3319 3359
3320 if (!NILP (tem)) continue; 3360 if (!NILP (tem)) continue;
@@ -3326,7 +3366,6 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3326 { 3366 {
3327 Lisp_Object tem; 3367 Lisp_Object tem;
3328 3368
3329 ASET (kludge, 0, character);
3330 tem = Flookup_key (entire_map, kludge, Qt); 3369 tem = Flookup_key (entire_map, kludge, Qt);
3331 3370
3332 if (!EQ (tem, definition)) 3371 if (!EQ (tem, definition))
@@ -3343,7 +3382,7 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3343 if (!NILP (elt_prefix)) 3382 if (!NILP (elt_prefix))
3344 insert1 (elt_prefix); 3383 insert1 (elt_prefix);
3345 3384
3346 insert1 (Fsingle_key_description (character, Qnil)); 3385 insert1 (Fkey_description (kludge, prefix));
3347 3386
3348 /* Find all consecutive characters or rows that have the same 3387 /* Find all consecutive characters or rows that have the same
3349 definition. But, for elements of a top level char table, if 3388 definition. But, for elements of a top level char table, if
@@ -3371,10 +3410,12 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3371 { 3410 {
3372 insert (" .. ", 4); 3411 insert (" .. ", 4);
3373 3412
3413 ASET (kludge, 0, make_number (i));
3414
3374 if (!NILP (elt_prefix)) 3415 if (!NILP (elt_prefix))
3375 insert1 (elt_prefix); 3416 insert1 (elt_prefix);
3376 3417
3377 insert1 (Fsingle_key_description (make_number (i), Qnil)); 3418 insert1 (Fkey_description (kludge, prefix));
3378 } 3419 }
3379 3420
3380 /* Print a description of the definition of this character. 3421 /* Print a description of the definition of this character.