diff options
| author | Kim F. Storm | 2004-04-16 21:16:33 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-04-16 21:16:33 +0000 |
| commit | f8d8ba4051ddb0dbb4b27347bb3a6776a211f7d2 (patch) | |
| tree | 6a18025e9118882519a2b17dcdda08c426ffc048 | |
| parent | 60962ec4c24b192e169dd3e1c116ad537c03a299 (diff) | |
| download | emacs-f8d8ba4051ddb0dbb4b27347bb3a6776a211f7d2.tar.gz emacs-f8d8ba4051ddb0dbb4b27347bb3a6776a211f7d2.zip | |
(Fkey_description): Add optional PREFIX arg.
Combine prefix with KEYS to make up the full key sequence to describe.
Correlate meta_prefix_char and following (simple) key to describe
as meta modifier. All callers changed.
(describe_map): Rename arg `keys' to `prefix'. Remove local
`elt_prefix' var. Use Fkey_description with prefix instead of
elt_prefix combined with Fsingle_key_description.
(describe_vector): Declare static. Replace arg `elt_prefix' with
`prefix'. Add KEYMAP_P arg. Add local var `elt_prefix'; use it
if !KEYMAP_P. Use Fkey_description with prefix instead of
Fsingle_key_description.
| -rw-r--r-- | src/keymap.c | 227 |
1 files changed, 133 insertions, 94 deletions
diff --git a/src/keymap.c b/src/keymap.c index b181c3c5074..c9991c1874c 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -121,6 +121,9 @@ static void describe_translation P_ ((Lisp_Object, Lisp_Object)); | |||
| 121 | static void describe_map P_ ((Lisp_Object, Lisp_Object, | 121 | static void describe_map P_ ((Lisp_Object, Lisp_Object, |
| 122 | void (*) P_ ((Lisp_Object, Lisp_Object)), | 122 | void (*) P_ ((Lisp_Object, Lisp_Object)), |
| 123 | int, Lisp_Object, Lisp_Object*, int)); | 123 | int, Lisp_Object, Lisp_Object*, int)); |
| 124 | static void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object, | ||
| 125 | void (*) (Lisp_Object, Lisp_Object), int, | ||
| 126 | Lisp_Object, Lisp_Object, int *, int, int)); | ||
| 124 | static void silly_event_symbol_error P_ ((Lisp_Object)); | 127 | static void silly_event_symbol_error P_ ((Lisp_Object)); |
| 125 | 128 | ||
| 126 | /* Keymap object support - constructors and predicates. */ | 129 | /* Keymap object support - constructors and predicates. */ |
| @@ -687,7 +690,7 @@ map_keymap (map, fun, args, data, autoload) | |||
| 687 | tail = XCDR (tail)) | 690 | tail = XCDR (tail)) |
| 688 | { | 691 | { |
| 689 | Lisp_Object binding = XCAR (tail); | 692 | Lisp_Object binding = XCAR (tail); |
| 690 | 693 | ||
| 691 | if (CONSP (binding)) | 694 | if (CONSP (binding)) |
| 692 | map_keymap_item (fun, args, XCAR (binding), XCDR (binding), data); | 695 | map_keymap_item (fun, args, XCAR (binding), XCDR (binding), data); |
| 693 | else if (VECTORP (binding)) | 696 | else if (VECTORP (binding)) |
| @@ -1160,7 +1163,7 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1160 | /* We must use Fkey_description rather than just passing key to | 1163 | /* We must use Fkey_description rather than just passing key to |
| 1161 | error; key might be a vector, not a string. */ | 1164 | error; key might be a vector, not a string. */ |
| 1162 | error ("Key sequence %s uses invalid prefix characters", | 1165 | error ("Key sequence %s uses invalid prefix characters", |
| 1163 | SDATA (Fkey_description (key))); | 1166 | SDATA (Fkey_description (key, Qnil))); |
| 1164 | } | 1167 | } |
| 1165 | } | 1168 | } |
| 1166 | 1169 | ||
| @@ -1791,9 +1794,9 @@ accessible_keymaps_1 (key, cmd, maps, tail, thisseq, is_metized) | |||
| 1791 | int meta_bit = meta_modifier; | 1794 | int meta_bit = meta_modifier; |
| 1792 | Lisp_Object last = make_number (XINT (Flength (thisseq)) - 1); | 1795 | Lisp_Object last = make_number (XINT (Flength (thisseq)) - 1); |
| 1793 | tem = Fcopy_sequence (thisseq); | 1796 | tem = Fcopy_sequence (thisseq); |
| 1794 | 1797 | ||
| 1795 | Faset (tem, last, make_number (XINT (key) | meta_bit)); | 1798 | Faset (tem, last, make_number (XINT (key) | meta_bit)); |
| 1796 | 1799 | ||
| 1797 | /* This new sequence is the same length as | 1800 | /* This new sequence is the same length as |
| 1798 | thisseq, so stick it in the list right | 1801 | thisseq, so stick it in the list right |
| 1799 | after this one. */ | 1802 | after this one. */ |
| @@ -1944,78 +1947,109 @@ Lisp_Object Qsingle_key_description, Qkey_description; | |||
| 1944 | 1947 | ||
| 1945 | /* This function cannot GC. */ | 1948 | /* This function cannot GC. */ |
| 1946 | 1949 | ||
| 1947 | DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0, | 1950 | DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0, |
| 1948 | doc: /* Return a pretty description of key-sequence KEYS. | 1951 | doc: /* Return a pretty description of key-sequence KEYS. |
| 1952 | Optional arg PREFIX is the sequence of keys leading up to KEYS. | ||
| 1949 | Control characters turn into "C-foo" sequences, meta into "M-foo" | 1953 | Control characters turn into "C-foo" sequences, meta into "M-foo" |
| 1950 | spaces are put between sequence elements, etc. */) | 1954 | spaces are put between sequence elements, etc. */) |
| 1951 | (keys) | 1955 | (keys, prefix) |
| 1952 | Lisp_Object keys; | 1956 | Lisp_Object keys, prefix; |
| 1953 | { | 1957 | { |
| 1954 | int len = 0; | 1958 | int len = 0; |
| 1955 | int i, i_byte; | 1959 | int i, i_byte; |
| 1956 | Lisp_Object sep; | 1960 | Lisp_Object *args; |
| 1957 | Lisp_Object *args = NULL; | 1961 | int size = Flength (keys); |
| 1962 | Lisp_Object list; | ||
| 1963 | Lisp_Object sep = build_string (" "); | ||
| 1964 | Lisp_Object key; | ||
| 1965 | int add_meta = 0; | ||
| 1966 | |||
| 1967 | if (!NILP (prefix)) | ||
| 1968 | size += Flength (prefix); | ||
| 1969 | |||
| 1970 | /* This has one extra element at the end that we don't pass to Fconcat. */ | ||
| 1971 | args = (Lisp_Object *) alloca (size * 4 * sizeof (Lisp_Object)); | ||
| 1972 | |||
| 1973 | /* In effect, this computes | ||
| 1974 | (mapconcat 'single-key-description keys " ") | ||
| 1975 | but we shouldn't use mapconcat because it can do GC. */ | ||
| 1958 | 1976 | ||
| 1959 | if (STRINGP (keys)) | 1977 | next_list: |
| 1978 | if (!NILP (prefix)) | ||
| 1979 | list = prefix, prefix = Qnil; | ||
| 1980 | else if (!NILP (keys)) | ||
| 1981 | list = keys, keys = Qnil; | ||
| 1982 | else | ||
| 1960 | { | 1983 | { |
| 1961 | Lisp_Object vector; | 1984 | if (add_meta) |
| 1962 | vector = Fmake_vector (Flength (keys), Qnil); | ||
| 1963 | for (i = 0, i_byte = 0; i < SCHARS (keys); ) | ||
| 1964 | { | 1985 | { |
| 1965 | int c; | 1986 | args[len] = Fsingle_key_description (meta_prefix_char, Qnil); |
| 1966 | int i_before = i; | 1987 | len += 2; |
| 1967 | |||
| 1968 | FETCH_STRING_CHAR_ADVANCE (c, keys, i, i_byte); | ||
| 1969 | if (SINGLE_BYTE_CHAR_P (c) && (c & 0200)) | ||
| 1970 | c ^= 0200 | meta_modifier; | ||
| 1971 | XSETFASTINT (AREF (vector, i_before), c); | ||
| 1972 | } | 1988 | } |
| 1973 | keys = vector; | 1989 | else if (len == 0) |
| 1990 | return empty_string; | ||
| 1991 | return Fconcat (len - 1, args); | ||
| 1974 | } | 1992 | } |
| 1975 | 1993 | ||
| 1976 | if (VECTORP (keys)) | 1994 | if (STRINGP (list)) |
| 1977 | { | 1995 | size = SCHARS (list); |
| 1978 | /* In effect, this computes | 1996 | else if (VECTORP (list)) |
| 1979 | (mapconcat 'single-key-description keys " ") | 1997 | size = XVECTOR (list)->size; |
| 1980 | but we shouldn't use mapconcat because it can do GC. */ | 1998 | else if (CONSP (list)) |
| 1999 | size = Flength (list); | ||
| 2000 | else | ||
| 2001 | wrong_type_argument (Qarrayp, list); | ||
| 1981 | 2002 | ||
| 1982 | len = XVECTOR (keys)->size; | 2003 | i = i_byte = 0; |
| 1983 | sep = build_string (" "); | ||
| 1984 | /* This has one extra element at the end that we don't pass to Fconcat. */ | ||
| 1985 | args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object)); | ||
| 1986 | 2004 | ||
| 1987 | for (i = 0; i < len; i++) | 2005 | while (i < size) |
| 2006 | { | ||
| 2007 | if (STRINGP (list)) | ||
| 1988 | { | 2008 | { |
| 1989 | args[i * 2] = Fsingle_key_description (AREF (keys, i), Qnil); | 2009 | int c; |
| 1990 | args[i * 2 + 1] = sep; | 2010 | FETCH_STRING_CHAR_ADVANCE (c, list, i, i_byte); |
| 2011 | if (SINGLE_BYTE_CHAR_P (c) && (c & 0200)) | ||
| 2012 | c ^= 0200 | meta_modifier; | ||
| 2013 | XSETFASTINT (key, c); | ||
| 2014 | } | ||
| 2015 | else if (VECTORP (list)) | ||
| 2016 | { | ||
| 2017 | key = AREF (list, i++); | ||
| 2018 | } | ||
| 2019 | else | ||
| 2020 | { | ||
| 2021 | key = XCAR (list); | ||
| 2022 | list = XCDR (list); | ||
| 2023 | i++; | ||
| 1991 | } | 2024 | } |
| 1992 | } | ||
| 1993 | else if (CONSP (keys)) | ||
| 1994 | { | ||
| 1995 | /* In effect, this computes | ||
| 1996 | (mapconcat 'single-key-description keys " ") | ||
| 1997 | but we shouldn't use mapconcat because it can do GC. */ | ||
| 1998 | |||
| 1999 | len = XFASTINT (Flength (keys)); | ||
| 2000 | sep = build_string (" "); | ||
| 2001 | /* This has one extra element at the end that we don't pass to Fconcat. */ | ||
| 2002 | args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object)); | ||
| 2003 | 2025 | ||
| 2004 | for (i = 0; i < len; i++) | 2026 | if (add_meta) |
| 2027 | { | ||
| 2028 | if (!INTEGERP (key) | ||
| 2029 | || EQ (key, meta_prefix_char) | ||
| 2030 | || (XINT (key) & meta_modifier)) | ||
| 2031 | { | ||
| 2032 | args[len++] = Fsingle_key_description (meta_prefix_char, Qnil); | ||
| 2033 | args[len++] = sep; | ||
| 2034 | if (EQ (key, meta_prefix_char)) | ||
| 2035 | continue; | ||
| 2036 | } | ||
| 2037 | else | ||
| 2038 | XSETINT (key, (XINT (key) | meta_modifier) & ~0x80); | ||
| 2039 | add_meta = 0; | ||
| 2040 | } | ||
| 2041 | else if (EQ (key, meta_prefix_char)) | ||
| 2005 | { | 2042 | { |
| 2006 | args[i * 2] = Fsingle_key_description (XCAR (keys), Qnil); | 2043 | add_meta = 1; |
| 2007 | args[i * 2 + 1] = sep; | 2044 | continue; |
| 2008 | keys = XCDR (keys); | ||
| 2009 | } | 2045 | } |
| 2046 | args[len++] = Fsingle_key_description (key, Qnil); | ||
| 2047 | args[len++] = sep; | ||
| 2010 | } | 2048 | } |
| 2011 | else | 2049 | goto next_list; |
| 2012 | keys = wrong_type_argument (Qarrayp, keys); | ||
| 2013 | |||
| 2014 | if (len == 0) | ||
| 2015 | return empty_string; | ||
| 2016 | return Fconcat (len * 2 - 1, args); | ||
| 2017 | } | 2050 | } |
| 2018 | 2051 | ||
| 2052 | |||
| 2019 | char * | 2053 | char * |
| 2020 | push_key_description (c, p, force_multibyte) | 2054 | push_key_description (c, p, force_multibyte) |
| 2021 | register unsigned int c; | 2055 | register unsigned int c; |
| @@ -2937,7 +2971,7 @@ key binding\n\ | |||
| 2937 | if (!NILP (prefix)) | 2971 | if (!NILP (prefix)) |
| 2938 | { | 2972 | { |
| 2939 | insert_string (" Starting With "); | 2973 | insert_string (" Starting With "); |
| 2940 | insert1 (Fkey_description (prefix)); | 2974 | insert1 (Fkey_description (prefix, Qnil)); |
| 2941 | } | 2975 | } |
| 2942 | insert_string (":\n"); | 2976 | insert_string (":\n"); |
| 2943 | } | 2977 | } |
| @@ -3062,7 +3096,7 @@ describe_translation (definition, args) | |||
| 3062 | } | 3096 | } |
| 3063 | else if (STRINGP (definition) || VECTORP (definition)) | 3097 | else if (STRINGP (definition) || VECTORP (definition)) |
| 3064 | { | 3098 | { |
| 3065 | insert1 (Fkey_description (definition)); | 3099 | insert1 (Fkey_description (definition, Qnil)); |
| 3066 | insert_string ("\n"); | 3100 | insert_string ("\n"); |
| 3067 | } | 3101 | } |
| 3068 | else if (KEYMAPP (definition)) | 3102 | else if (KEYMAPP (definition)) |
| @@ -3072,20 +3106,19 @@ describe_translation (definition, args) | |||
| 3072 | } | 3106 | } |
| 3073 | 3107 | ||
| 3074 | /* Describe the contents of map MAP, assuming that this map itself is | 3108 | /* Describe the contents of map MAP, assuming that this map itself is |
| 3075 | reached by the sequence of prefix keys KEYS (a string or vector). | 3109 | reached by the sequence of prefix keys PREFIX (a string or vector). |
| 3076 | PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ | 3110 | PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ |
| 3077 | 3111 | ||
| 3078 | static void | 3112 | static void |
| 3079 | describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | 3113 | describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu) |
| 3080 | register Lisp_Object map; | 3114 | register Lisp_Object map; |
| 3081 | Lisp_Object keys; | 3115 | Lisp_Object prefix; |
| 3082 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); | 3116 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); |
| 3083 | int partial; | 3117 | int partial; |
| 3084 | Lisp_Object shadow; | 3118 | Lisp_Object shadow; |
| 3085 | Lisp_Object *seen; | 3119 | Lisp_Object *seen; |
| 3086 | int nomenu; | 3120 | int nomenu; |
| 3087 | { | 3121 | { |
| 3088 | Lisp_Object elt_prefix; | ||
| 3089 | Lisp_Object tail, definition, event; | 3122 | Lisp_Object tail, definition, event; |
| 3090 | Lisp_Object tem; | 3123 | Lisp_Object tem; |
| 3091 | Lisp_Object suppress; | 3124 | Lisp_Object suppress; |
| @@ -3095,15 +3128,6 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 3095 | 3128 | ||
| 3096 | suppress = Qnil; | 3129 | suppress = Qnil; |
| 3097 | 3130 | ||
| 3098 | if (!NILP (keys) && XFASTINT (Flength (keys)) > 0) | ||
| 3099 | { | ||
| 3100 | /* Call Fkey_description first, to avoid GC bug for the other string. */ | ||
| 3101 | tem = Fkey_description (keys); | ||
| 3102 | elt_prefix = concat2 (tem, build_string (" ")); | ||
| 3103 | } | ||
| 3104 | else | ||
| 3105 | elt_prefix = Qnil; | ||
| 3106 | |||
| 3107 | if (partial) | 3131 | if (partial) |
| 3108 | suppress = intern ("suppress-keymap"); | 3132 | suppress = intern ("suppress-keymap"); |
| 3109 | 3133 | ||
| @@ -3113,7 +3137,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 3113 | kludge = Fmake_vector (make_number (1), Qnil); | 3137 | kludge = Fmake_vector (make_number (1), Qnil); |
| 3114 | definition = Qnil; | 3138 | definition = Qnil; |
| 3115 | 3139 | ||
| 3116 | GCPRO3 (elt_prefix, definition, kludge); | 3140 | GCPRO3 (prefix, definition, kludge); |
| 3117 | 3141 | ||
| 3118 | for (tail = map; CONSP (tail); tail = XCDR (tail)) | 3142 | for (tail = map; CONSP (tail); tail = XCDR (tail)) |
| 3119 | { | 3143 | { |
| @@ -3122,13 +3146,13 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 3122 | if (VECTORP (XCAR (tail)) | 3146 | if (VECTORP (XCAR (tail)) |
| 3123 | || CHAR_TABLE_P (XCAR (tail))) | 3147 | || CHAR_TABLE_P (XCAR (tail))) |
| 3124 | describe_vector (XCAR (tail), | 3148 | describe_vector (XCAR (tail), |
| 3125 | elt_prefix, Qnil, elt_describer, partial, shadow, map, | 3149 | prefix, Qnil, elt_describer, partial, shadow, map, |
| 3126 | (int *)0, 0); | 3150 | (int *)0, 0, 1); |
| 3127 | else if (CONSP (XCAR (tail))) | 3151 | else if (CONSP (XCAR (tail))) |
| 3128 | { | 3152 | { |
| 3129 | event = XCAR (XCAR (tail)); | 3153 | event = XCAR (XCAR (tail)); |
| 3130 | 3154 | ||
| 3131 | /* Ignore bindings whose "keys" are not really valid events. | 3155 | /* Ignore bindings whose "prefix" are not really valid events. |
| 3132 | (We get these in the frames and buffers menu.) */ | 3156 | (We get these in the frames and buffers menu.) */ |
| 3133 | if (!(SYMBOLP (event) || INTEGERP (event))) | 3157 | if (!(SYMBOLP (event) || INTEGERP (event))) |
| 3134 | continue; | 3158 | continue; |
| @@ -3167,11 +3191,8 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 3167 | first = 0; | 3191 | first = 0; |
| 3168 | } | 3192 | } |
| 3169 | 3193 | ||
| 3170 | if (!NILP (elt_prefix)) | ||
| 3171 | insert1 (elt_prefix); | ||
| 3172 | |||
| 3173 | /* THIS gets the string to describe the character EVENT. */ | 3194 | /* THIS gets the string to describe the character EVENT. */ |
| 3174 | insert1 (Fsingle_key_description (event, Qnil)); | 3195 | insert1 (Fkey_description (kludge, prefix)); |
| 3175 | 3196 | ||
| 3176 | /* Print a description of the definition of this character. | 3197 | /* Print a description of the definition of this character. |
| 3177 | elt_describer will take care of spacing out far enough | 3198 | elt_describer will take care of spacing out far enough |
| @@ -3184,9 +3205,9 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 3184 | using an inherited keymap. So skip anything we've already | 3205 | using an inherited keymap. So skip anything we've already |
| 3185 | encountered. */ | 3206 | encountered. */ |
| 3186 | tem = Fassq (tail, *seen); | 3207 | tem = Fassq (tail, *seen); |
| 3187 | if (CONSP (tem) && !NILP (Fequal (XCAR (tem), keys))) | 3208 | if (CONSP (tem) && !NILP (Fequal (XCAR (tem), prefix))) |
| 3188 | break; | 3209 | break; |
| 3189 | *seen = Fcons (Fcons (tail, keys), *seen); | 3210 | *seen = Fcons (Fcons (tail, prefix), *seen); |
| 3190 | } | 3211 | } |
| 3191 | } | 3212 | } |
| 3192 | 3213 | ||
| @@ -3214,7 +3235,7 @@ This is text showing the elements of vector matched against indices. */) | |||
| 3214 | specbind (Qstandard_output, Fcurrent_buffer ()); | 3235 | specbind (Qstandard_output, Fcurrent_buffer ()); |
| 3215 | CHECK_VECTOR_OR_CHAR_TABLE (vector); | 3236 | CHECK_VECTOR_OR_CHAR_TABLE (vector); |
| 3216 | describe_vector (vector, Qnil, describer, describe_vector_princ, 0, | 3237 | describe_vector (vector, Qnil, describer, describe_vector_princ, 0, |
| 3217 | Qnil, Qnil, (int *)0, 0); | 3238 | Qnil, Qnil, (int *)0, 0, 0); |
| 3218 | 3239 | ||
| 3219 | return unbind_to (count, Qnil); | 3240 | return unbind_to (count, Qnil); |
| 3220 | } | 3241 | } |
| @@ -3249,28 +3270,32 @@ This is text showing the elements of vector matched against indices. */) | |||
| 3249 | indices at higher levels in this char-table, | 3270 | indices at higher levels in this char-table, |
| 3250 | and CHAR_TABLE_DEPTH says how many levels down we have gone. | 3271 | and CHAR_TABLE_DEPTH says how many levels down we have gone. |
| 3251 | 3272 | ||
| 3273 | KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-. | ||
| 3274 | |||
| 3252 | ARGS is simply passed as the second argument to ELT_DESCRIBER. */ | 3275 | ARGS is simply passed as the second argument to ELT_DESCRIBER. */ |
| 3253 | 3276 | ||
| 3254 | void | 3277 | static void |
| 3255 | describe_vector (vector, elt_prefix, args, elt_describer, | 3278 | describe_vector (vector, prefix, args, elt_describer, |
| 3256 | partial, shadow, entire_map, | 3279 | partial, shadow, entire_map, |
| 3257 | indices, char_table_depth) | 3280 | indices, char_table_depth, keymap_p) |
| 3258 | register Lisp_Object vector; | 3281 | register Lisp_Object vector; |
| 3259 | Lisp_Object elt_prefix, args; | 3282 | Lisp_Object prefix, args; |
| 3260 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); | 3283 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); |
| 3261 | int partial; | 3284 | int partial; |
| 3262 | Lisp_Object shadow; | 3285 | Lisp_Object shadow; |
| 3263 | Lisp_Object entire_map; | 3286 | Lisp_Object entire_map; |
| 3264 | int *indices; | 3287 | int *indices; |
| 3265 | int char_table_depth; | 3288 | int char_table_depth; |
| 3289 | int keymap_p; | ||
| 3266 | { | 3290 | { |
| 3267 | Lisp_Object definition; | 3291 | Lisp_Object definition; |
| 3268 | Lisp_Object tem2; | 3292 | Lisp_Object tem2; |
| 3293 | Lisp_Object elt_prefix = Qnil; | ||
| 3269 | register int i; | 3294 | register int i; |
| 3270 | Lisp_Object suppress; | 3295 | Lisp_Object suppress; |
| 3271 | Lisp_Object kludge; | 3296 | Lisp_Object kludge; |
| 3272 | int first = 1; | 3297 | int first = 1; |
| 3273 | struct gcpro gcpro1, gcpro2, gcpro3; | 3298 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 3274 | /* Range of elements to be handled. */ | 3299 | /* Range of elements to be handled. */ |
| 3275 | int from, to; | 3300 | int from, to; |
| 3276 | /* A flag to tell if a leaf in this level of char-table is not a | 3301 | /* A flag to tell if a leaf in this level of char-table is not a |
| @@ -3286,11 +3311,23 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3286 | 3311 | ||
| 3287 | definition = Qnil; | 3312 | definition = Qnil; |
| 3288 | 3313 | ||
| 3314 | if (!keymap_p) | ||
| 3315 | { | ||
| 3316 | /* Call Fkey_description first, to avoid GC bug for the other string. */ | ||
| 3317 | if (!NILP (prefix) && XFASTINT (Flength (prefix)) > 0) | ||
| 3318 | { | ||
| 3319 | Lisp_Object tem; | ||
| 3320 | tem = Fkey_description (prefix, Qnil); | ||
| 3321 | elt_prefix = concat2 (tem, build_string (" ")); | ||
| 3322 | } | ||
| 3323 | prefix = Qnil; | ||
| 3324 | } | ||
| 3325 | |||
| 3289 | /* This vector gets used to present single keys to Flookup_key. Since | 3326 | /* This vector gets used to present single keys to Flookup_key. Since |
| 3290 | that is done once per vector element, we don't want to cons up a | 3327 | that is done once per vector element, we don't want to cons up a |
| 3291 | fresh vector every time. */ | 3328 | fresh vector every time. */ |
| 3292 | kludge = Fmake_vector (make_number (1), Qnil); | 3329 | kludge = Fmake_vector (make_number (1), Qnil); |
| 3293 | GCPRO3 (elt_prefix, definition, kludge); | 3330 | GCPRO4 (elt_prefix, prefix, definition, kludge); |
| 3294 | 3331 | ||
| 3295 | if (partial) | 3332 | if (partial) |
| 3296 | suppress = intern ("suppress-keymap"); | 3333 | suppress = intern ("suppress-keymap"); |
| @@ -3383,12 +3420,13 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3383 | else | 3420 | else |
| 3384 | character = i; | 3421 | character = i; |
| 3385 | 3422 | ||
| 3423 | ASET (kludge, 0, make_number (character)); | ||
| 3424 | |||
| 3386 | /* If this binding is shadowed by some other map, ignore it. */ | 3425 | /* If this binding is shadowed by some other map, ignore it. */ |
| 3387 | if (!NILP (shadow) && complete_char) | 3426 | if (!NILP (shadow) && complete_char) |
| 3388 | { | 3427 | { |
| 3389 | Lisp_Object tem; | 3428 | Lisp_Object tem; |
| 3390 | 3429 | ||
| 3391 | ASET (kludge, 0, make_number (character)); | ||
| 3392 | tem = shadow_lookup (shadow, kludge, Qt); | 3430 | tem = shadow_lookup (shadow, kludge, Qt); |
| 3393 | 3431 | ||
| 3394 | if (!NILP (tem)) continue; | 3432 | if (!NILP (tem)) continue; |
| @@ -3400,7 +3438,6 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3400 | { | 3438 | { |
| 3401 | Lisp_Object tem; | 3439 | Lisp_Object tem; |
| 3402 | 3440 | ||
| 3403 | ASET (kludge, 0, make_number (character)); | ||
| 3404 | tem = Flookup_key (entire_map, kludge, Qt); | 3441 | tem = Flookup_key (entire_map, kludge, Qt); |
| 3405 | 3442 | ||
| 3406 | if (!EQ (tem, definition)) | 3443 | if (!EQ (tem, definition)) |
| @@ -3441,7 +3478,7 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3441 | else if (CHAR_TABLE_P (vector)) | 3478 | else if (CHAR_TABLE_P (vector)) |
| 3442 | { | 3479 | { |
| 3443 | if (complete_char) | 3480 | if (complete_char) |
| 3444 | insert1 (Fsingle_key_description (make_number (character), Qnil)); | 3481 | insert1 (Fkey_description (kludge, prefix)); |
| 3445 | else | 3482 | else |
| 3446 | { | 3483 | { |
| 3447 | /* Print the information for this character set. */ | 3484 | /* Print the information for this character set. */ |
| @@ -3457,7 +3494,7 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3457 | } | 3494 | } |
| 3458 | else | 3495 | else |
| 3459 | { | 3496 | { |
| 3460 | insert1 (Fsingle_key_description (make_number (character), Qnil)); | 3497 | insert1 (Fkey_description (kludge, prefix)); |
| 3461 | } | 3498 | } |
| 3462 | 3499 | ||
| 3463 | /* If we find a sub char-table within a char-table, | 3500 | /* If we find a sub char-table within a char-table, |
| @@ -3466,9 +3503,9 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3466 | if (CHAR_TABLE_P (vector) && SUB_CHAR_TABLE_P (definition)) | 3503 | if (CHAR_TABLE_P (vector) && SUB_CHAR_TABLE_P (definition)) |
| 3467 | { | 3504 | { |
| 3468 | insert ("\n", 1); | 3505 | insert ("\n", 1); |
| 3469 | describe_vector (definition, elt_prefix, args, elt_describer, | 3506 | describe_vector (definition, prefix, args, elt_describer, |
| 3470 | partial, shadow, entire_map, | 3507 | partial, shadow, entire_map, |
| 3471 | indices, char_table_depth + 1); | 3508 | indices, char_table_depth + 1, keymap_p); |
| 3472 | continue; | 3509 | continue; |
| 3473 | } | 3510 | } |
| 3474 | 3511 | ||
| @@ -3506,6 +3543,8 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3506 | { | 3543 | { |
| 3507 | insert (" .. ", 4); | 3544 | insert (" .. ", 4); |
| 3508 | 3545 | ||
| 3546 | ASET (kludge, 0, make_number (i)); | ||
| 3547 | |||
| 3509 | if (!NILP (elt_prefix)) | 3548 | if (!NILP (elt_prefix)) |
| 3510 | insert1 (elt_prefix); | 3549 | insert1 (elt_prefix); |
| 3511 | 3550 | ||
| @@ -3513,7 +3552,7 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3513 | { | 3552 | { |
| 3514 | if (char_table_depth == 0) | 3553 | if (char_table_depth == 0) |
| 3515 | { | 3554 | { |
| 3516 | insert1 (Fsingle_key_description (make_number (i), Qnil)); | 3555 | insert1 (Fkey_description (kludge, prefix)); |
| 3517 | } | 3556 | } |
| 3518 | else if (complete_char) | 3557 | else if (complete_char) |
| 3519 | { | 3558 | { |
| @@ -3532,7 +3571,7 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3532 | } | 3571 | } |
| 3533 | else | 3572 | else |
| 3534 | { | 3573 | { |
| 3535 | insert1 (Fsingle_key_description (make_number (i), Qnil)); | 3574 | insert1 (Fkey_description (kludge, prefix)); |
| 3536 | } | 3575 | } |
| 3537 | } | 3576 | } |
| 3538 | 3577 | ||