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