diff options
| author | Kenichi Handa | 2002-06-12 00:14:32 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-06-12 00:14:32 +0000 |
| commit | cda1ce8d883e7cf00c53fe74a302627d10408484 (patch) | |
| tree | 68f0298b2804b60b8ece9d88b736809c8f974a68 /src/keymap.c | |
| parent | e15009d96766327c7e9fb60aa1263f1521a2c92c (diff) | |
| download | emacs-cda1ce8d883e7cf00c53fe74a302627d10408484.tar.gz emacs-cda1ce8d883e7cf00c53fe74a302627d10408484.zip | |
(describe_vector): Handle a char-table directly here.
(describe_char_table): Deleted.
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 176 |
1 files changed, 36 insertions, 140 deletions
diff --git a/src/keymap.c b/src/keymap.c index c9c6390fc2d..d1b0cb827f2 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -3152,7 +3152,7 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3152 | { | 3152 | { |
| 3153 | Lisp_Object definition; | 3153 | Lisp_Object definition; |
| 3154 | Lisp_Object tem2; | 3154 | Lisp_Object tem2; |
| 3155 | register int i; | 3155 | int i; |
| 3156 | Lisp_Object suppress; | 3156 | Lisp_Object suppress; |
| 3157 | Lisp_Object kludge; | 3157 | Lisp_Object kludge; |
| 3158 | struct gcpro gcpro1, gcpro2, gcpro3; | 3158 | struct gcpro gcpro1, gcpro2, gcpro3; |
| @@ -3160,14 +3160,8 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3160 | int from, to; | 3160 | int from, to; |
| 3161 | Lisp_Object character; | 3161 | Lisp_Object character; |
| 3162 | int starting_i; | 3162 | int starting_i; |
| 3163 | int first = 1; | ||
| 3163 | 3164 | ||
| 3164 | if (CHAR_TABLE_P (vector)) | ||
| 3165 | { | ||
| 3166 | describe_char_table (vector, elt_prefix, args, elt_describer, | ||
| 3167 | partial, shadow, entire_map); | ||
| 3168 | return; | ||
| 3169 | } | ||
| 3170 | |||
| 3171 | suppress = Qnil; | 3165 | suppress = Qnil; |
| 3172 | 3166 | ||
| 3173 | definition = Qnil; | 3167 | definition = Qnil; |
| @@ -3182,13 +3176,22 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3182 | suppress = intern ("suppress-keymap"); | 3176 | suppress = intern ("suppress-keymap"); |
| 3183 | 3177 | ||
| 3184 | from = 0; | 3178 | from = 0; |
| 3185 | to = XVECTOR (vector)->size; | 3179 | to = CHAR_TABLE_P (vector) ? MAX_CHAR + 1 : XVECTOR (vector)->size; |
| 3186 | 3180 | ||
| 3187 | for (i = from; i < to; i++) | 3181 | for (i = from; i < to; i++) |
| 3188 | { | 3182 | { |
| 3183 | int range_beg, range_end; | ||
| 3184 | Lisp_Object val; | ||
| 3185 | |||
| 3189 | QUIT; | 3186 | QUIT; |
| 3190 | 3187 | ||
| 3191 | definition = get_keyelt (AREF (vector, i), 0); | 3188 | starting_i = i; |
| 3189 | |||
| 3190 | if (CHAR_TABLE_P (vector)) | ||
| 3191 | val = char_table_ref_and_range (vector, i, &range_beg, &i); | ||
| 3192 | else | ||
| 3193 | val = AREF (vector, i); | ||
| 3194 | definition = get_keyelt (val, 0); | ||
| 3192 | 3195 | ||
| 3193 | if (NILP (definition)) continue; | 3196 | if (NILP (definition)) continue; |
| 3194 | 3197 | ||
| @@ -3202,7 +3205,7 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3202 | if (!NILP (tem)) continue; | 3205 | if (!NILP (tem)) continue; |
| 3203 | } | 3206 | } |
| 3204 | 3207 | ||
| 3205 | character = make_number (i); | 3208 | character = make_number (starting_i); |
| 3206 | 3209 | ||
| 3207 | /* If this binding is shadowed by some other map, ignore it. */ | 3210 | /* If this binding is shadowed by some other map, ignore it. */ |
| 3208 | if (!NILP (shadow)) | 3211 | if (!NILP (shadow)) |
| @@ -3221,30 +3224,43 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3221 | { | 3224 | { |
| 3222 | Lisp_Object tem; | 3225 | Lisp_Object tem; |
| 3223 | 3226 | ||
| 3224 | ASET (kludge, 0, make_number (character)); | 3227 | ASET (kludge, 0, character); |
| 3225 | tem = Flookup_key (entire_map, kludge, Qt); | 3228 | tem = Flookup_key (entire_map, kludge, Qt); |
| 3226 | 3229 | ||
| 3227 | if (!EQ (tem, definition)) | 3230 | if (!EQ (tem, definition)) |
| 3228 | continue; | 3231 | continue; |
| 3229 | } | 3232 | } |
| 3230 | 3233 | ||
| 3234 | if (first) | ||
| 3235 | { | ||
| 3236 | insert ("\n", 1); | ||
| 3237 | first = 0; | ||
| 3238 | } | ||
| 3239 | |||
| 3231 | /* Output the prefix that applies to every entry in this map. */ | 3240 | /* Output the prefix that applies to every entry in this map. */ |
| 3232 | if (!NILP (elt_prefix)) | 3241 | if (!NILP (elt_prefix)) |
| 3233 | insert1 (elt_prefix); | 3242 | insert1 (elt_prefix); |
| 3234 | 3243 | ||
| 3235 | insert1 (Fsingle_key_description (make_number (character), Qnil)); | 3244 | insert1 (Fsingle_key_description (character, Qnil)); |
| 3236 | |||
| 3237 | starting_i = i; | ||
| 3238 | 3245 | ||
| 3239 | /* Find all consecutive characters or rows that have the same | 3246 | /* Find all consecutive characters or rows that have the same |
| 3240 | definition. But, for elements of a top level char table, if | 3247 | definition. But, for elements of a top level char table, if |
| 3241 | they are for charsets, we had better describe one by one even | 3248 | they are for charsets, we had better describe one by one even |
| 3242 | if they have the same definition. */ | 3249 | if they have the same definition. */ |
| 3243 | while (i + 1 < to | 3250 | if (CHAR_TABLE_P (vector)) |
| 3244 | && (tem2 = get_keyelt (AREF (vector, i + 1), 0), | 3251 | while (i + 1 < to |
| 3245 | !NILP (tem2)) | 3252 | && (val = char_table_ref_and_range (vector, i + 1, |
| 3246 | && !NILP (Fequal (tem2, definition))) | 3253 | &range_beg, &range_end), |
| 3247 | i++; | 3254 | tem2 = get_keyelt (val, 0), |
| 3255 | !NILP (tem2)) | ||
| 3256 | && !NILP (Fequal (tem2, definition))) | ||
| 3257 | i = range_end; | ||
| 3258 | else | ||
| 3259 | while (i + 1 < to | ||
| 3260 | && (tem2 = get_keyelt (AREF (vector, i + 1), 0), | ||
| 3261 | !NILP (tem2)) | ||
| 3262 | && !NILP (Fequal (tem2, definition))) | ||
| 3263 | i++; | ||
| 3248 | 3264 | ||
| 3249 | /* If we have a range of more than one character, | 3265 | /* If we have a range of more than one character, |
| 3250 | print where the range reaches to. */ | 3266 | print where the range reaches to. */ |
| @@ -3267,126 +3283,6 @@ describe_vector (vector, elt_prefix, args, elt_describer, | |||
| 3267 | UNGCPRO; | 3283 | UNGCPRO; |
| 3268 | } | 3284 | } |
| 3269 | 3285 | ||
| 3270 | /* Insert in the current buffer a description of the contents of | ||
| 3271 | char-table TABLE. We call ELT_DESCRIBER to insert the description | ||
| 3272 | of one value found in TABLE. | ||
| 3273 | |||
| 3274 | ELT_PREFIX describes what "comes before" the keys or indices defined | ||
| 3275 | by this vector. This is a human-readable string whose size | ||
| 3276 | is not necessarily related to the situation. | ||
| 3277 | |||
| 3278 | If PARTIAL is nonzero, it means do not mention suppressed commands | ||
| 3279 | (that assumes the vector is in a keymap). | ||
| 3280 | |||
| 3281 | SHADOW is a list of keymaps that shadow this map. | ||
| 3282 | If it is non-nil, then we look up the key in those maps | ||
| 3283 | and we don't mention it now if it is defined by any of them. | ||
| 3284 | |||
| 3285 | ENTIRE_MAP is the keymap in which this vector appears. | ||
| 3286 | If the definition in effect in the whole map does not match | ||
| 3287 | the one in this vector, we ignore this one. | ||
| 3288 | |||
| 3289 | ARGS is simply passed as the second argument to ELT_DESCRIBER. */ | ||
| 3290 | |||
| 3291 | void | ||
| 3292 | describe_char_table (table, elt_prefix, args, elt_describer, | ||
| 3293 | partial, shadow, entire_map) | ||
| 3294 | register Lisp_Object table; | ||
| 3295 | Lisp_Object args; | ||
| 3296 | Lisp_Object elt_prefix; | ||
| 3297 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); | ||
| 3298 | int partial; | ||
| 3299 | Lisp_Object shadow; | ||
| 3300 | Lisp_Object entire_map; | ||
| 3301 | { | ||
| 3302 | Lisp_Object definition; | ||
| 3303 | Lisp_Object tem2; | ||
| 3304 | register int i; | ||
| 3305 | Lisp_Object suppress; | ||
| 3306 | Lisp_Object kludge; | ||
| 3307 | struct gcpro gcpro1, gcpro2, gcpro3; | ||
| 3308 | /* Range of elements to be handled. */ | ||
| 3309 | int from, to; | ||
| 3310 | int c; | ||
| 3311 | int starting_i; | ||
| 3312 | |||
| 3313 | suppress = Qnil; | ||
| 3314 | |||
| 3315 | definition = Qnil; | ||
| 3316 | |||
| 3317 | /* This vector gets used to present single keys to Flookup_key. Since | ||
| 3318 | that is done once per vector element, we don't want to cons up a | ||
| 3319 | fresh vector every time. */ | ||
| 3320 | kludge = Fmake_vector (make_number (1), Qnil); | ||
| 3321 | GCPRO3 (elt_prefix, definition, kludge); | ||
| 3322 | |||
| 3323 | if (partial) | ||
| 3324 | suppress = intern ("suppress-keymap"); | ||
| 3325 | |||
| 3326 | from = 0; | ||
| 3327 | to = MAX_CHAR + 1; | ||
| 3328 | |||
| 3329 | while (from < to) | ||
| 3330 | { | ||
| 3331 | int range_beg, range_end; | ||
| 3332 | Lisp_Object val; | ||
| 3333 | |||
| 3334 | QUIT; | ||
| 3335 | |||
| 3336 | val = char_table_ref_and_range (table, from, &range_beg, &range_end); | ||
| 3337 | from = range_end + 1; | ||
| 3338 | definition = get_keyelt (val, 0); | ||
| 3339 | |||
| 3340 | if (NILP (definition)) continue; | ||
| 3341 | |||
| 3342 | /* Don't mention suppressed commands. */ | ||
| 3343 | if (SYMBOLP (definition) && partial) | ||
| 3344 | { | ||
| 3345 | Lisp_Object tem; | ||
| 3346 | |||
| 3347 | tem = Fget (definition, suppress); | ||
| 3348 | |||
| 3349 | if (!NILP (tem)) continue; | ||
| 3350 | } | ||
| 3351 | |||
| 3352 | /* Output the prefix that applies to every entry in this map. */ | ||
| 3353 | if (!NILP (elt_prefix)) | ||
| 3354 | insert1 (elt_prefix); | ||
| 3355 | |||
| 3356 | starting_i = range_beg; | ||
| 3357 | insert_char (starting_i); | ||
| 3358 | |||
| 3359 | /* Find all consecutive characters that have the same | ||
| 3360 | definition. */ | ||
| 3361 | while (from < to | ||
| 3362 | && (val = char_table_ref_and_range (table, from, | ||
| 3363 | &range_beg, &range_end), | ||
| 3364 | tem2 = get_keyelt (val, 0), | ||
| 3365 | !NILP (tem2)) | ||
| 3366 | && !NILP (Fequal (tem2, definition))) | ||
| 3367 | from = range_end + 1; | ||
| 3368 | |||
| 3369 | /* If we have a range of more than one character, | ||
| 3370 | print where the range reaches to. */ | ||
| 3371 | if (starting_i + 1 < from) | ||
| 3372 | { | ||
| 3373 | insert (" .. ", 4); | ||
| 3374 | |||
| 3375 | if (!NILP (elt_prefix)) | ||
| 3376 | insert1 (elt_prefix); | ||
| 3377 | |||
| 3378 | insert_char (from - 1); | ||
| 3379 | } | ||
| 3380 | |||
| 3381 | /* Print a description of the definition of this character. | ||
| 3382 | elt_describer will take care of spacing out far enough | ||
| 3383 | for alignment purposes. */ | ||
| 3384 | (*elt_describer) (definition, args); | ||
| 3385 | } | ||
| 3386 | |||
| 3387 | UNGCPRO; | ||
| 3388 | } | ||
| 3389 | |||
| 3390 | 3286 | ||
| 3391 | /* Apropos - finding all symbols whose names match a regexp. */ | 3287 | /* Apropos - finding all symbols whose names match a regexp. */ |
| 3392 | Lisp_Object apropos_predicate; | 3288 | Lisp_Object apropos_predicate; |