diff options
| author | Richard M. Stallman | 1995-10-12 21:18:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-10-12 21:18:42 +0000 |
| commit | 352e5dea1ec66612122342a05cce662e027c6058 (patch) | |
| tree | 5e0c432217b27eefc61c3bd867650f8ef9e288a8 /src | |
| parent | 7f0edce7142cb13fef0350b243fc670589797d9f (diff) | |
| download | emacs-352e5dea1ec66612122342a05cce662e027c6058.tar.gz emacs-352e5dea1ec66612122342a05cce662e027c6058.zip | |
(describe_vector): Support nested char-tables.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 118 |
1 files changed, 103 insertions, 15 deletions
diff --git a/src/keymap.c b/src/keymap.c index b7cb8486056..fd5d148cee1 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2272,12 +2272,37 @@ This is text showing the elements of vector matched against indices.") | |||
| 2272 | int count = specpdl_ptr - specpdl; | 2272 | int count = specpdl_ptr - specpdl; |
| 2273 | 2273 | ||
| 2274 | specbind (Qstandard_output, Fcurrent_buffer ()); | 2274 | specbind (Qstandard_output, Fcurrent_buffer ()); |
| 2275 | CHECK_VECTOR (vector, 0); | 2275 | CHECK_VECTOR_OR_CHAR_TABLE (vector, 0); |
| 2276 | describe_vector (vector, Qnil, describe_vector_princ, 0, Qnil, Qnil); | 2276 | describe_vector (vector, Qnil, describe_vector_princ, 0, Qnil, Qnil); |
| 2277 | 2277 | ||
| 2278 | return unbind_to (count, Qnil); | 2278 | return unbind_to (count, Qnil); |
| 2279 | } | 2279 | } |
| 2280 | 2280 | ||
| 2281 | /* Insert in the current buffer a description of the contents of VECTOR. | ||
| 2282 | We call ELT_DESCRIBER to insert the description of one value found | ||
| 2283 | in VECTOR. | ||
| 2284 | |||
| 2285 | ELT_PREFIX describes what "comes before" the keys or indices defined | ||
| 2286 | by this vector. | ||
| 2287 | |||
| 2288 | If the vector is in a keymap, ELT_PREFIX is a prefix key which | ||
| 2289 | leads to this keymap. | ||
| 2290 | |||
| 2291 | If the vector is a chartable, ELT_PREFIX is the vector | ||
| 2292 | of bytes that lead to the character set or portion of a character | ||
| 2293 | set described by this chartable. | ||
| 2294 | |||
| 2295 | If PARTIAL is nonzero, it means do not mention suppressed commands | ||
| 2296 | (that assumes the vector is in a keymap). | ||
| 2297 | |||
| 2298 | SHADOW is a list of keymaps that shadow this map. | ||
| 2299 | If it is non-nil, then we look up the key in those maps | ||
| 2300 | and we don't mention it now if it is defined by any of them. | ||
| 2301 | |||
| 2302 | ENTIRE_MAP is the keymap in which this vector appears. | ||
| 2303 | If the definition in effect in the whole map does not match | ||
| 2304 | the one in this vector, we ignore this one. */ | ||
| 2305 | |||
| 2281 | describe_vector (vector, elt_prefix, elt_describer, | 2306 | describe_vector (vector, elt_prefix, elt_describer, |
| 2282 | partial, shadow, entire_map) | 2307 | partial, shadow, entire_map) |
| 2283 | register Lisp_Object vector; | 2308 | register Lisp_Object vector; |
| @@ -2294,17 +2319,19 @@ describe_vector (vector, elt_prefix, elt_describer, | |||
| 2294 | register int i; | 2319 | register int i; |
| 2295 | Lisp_Object suppress; | 2320 | Lisp_Object suppress; |
| 2296 | Lisp_Object kludge; | 2321 | Lisp_Object kludge; |
| 2322 | Lisp_Object chartable_kludge; | ||
| 2297 | int first = 1; | 2323 | int first = 1; |
| 2298 | int size; | 2324 | int size; |
| 2299 | struct gcpro gcpro1, gcpro2, gcpro3; | 2325 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 2300 | 2326 | ||
| 2301 | definition = Qnil; | 2327 | definition = Qnil; |
| 2328 | chartable_kludge = Qnil; | ||
| 2302 | 2329 | ||
| 2303 | /* This vector gets used to present single keys to Flookup_key. Since | 2330 | /* This vector gets used to present single keys to Flookup_key. Since |
| 2304 | that is done once per vector element, we don't want to cons up a | 2331 | that is done once per vector element, we don't want to cons up a |
| 2305 | fresh vector every time. */ | 2332 | fresh vector every time. */ |
| 2306 | kludge = Fmake_vector (make_number (1), Qnil); | 2333 | kludge = Fmake_vector (make_number (1), Qnil); |
| 2307 | GCPRO3 (elt_prefix, definition, kludge); | 2334 | GCPRO4 (elt_prefix, definition, kludge, chartable_kludge); |
| 2308 | 2335 | ||
| 2309 | if (partial) | 2336 | if (partial) |
| 2310 | suppress = intern ("suppress-keymap"); | 2337 | suppress = intern ("suppress-keymap"); |
| @@ -2351,22 +2378,65 @@ describe_vector (vector, elt_prefix, elt_describer, | |||
| 2351 | continue; | 2378 | continue; |
| 2352 | } | 2379 | } |
| 2353 | 2380 | ||
| 2381 | /* If we find a char-table within a char-table, | ||
| 2382 | scan it recursively; it defines the details for | ||
| 2383 | a character set or a portion of a character set. */ | ||
| 2384 | if (CHAR_TABLE_P (vector) && CHAR_TABLE_P (definition)) | ||
| 2385 | { | ||
| 2386 | int outer_level | ||
| 2387 | = !NILP (elt_prefix) ? XVECTOR (elt_prefix)->size : 0; | ||
| 2388 | if (NILP (chartable_kludge)) | ||
| 2389 | { | ||
| 2390 | chartable_kludge | ||
| 2391 | = Fmake_vector (make_number (outer_level + 1), Qnil); | ||
| 2392 | if (outer_level != 0) | ||
| 2393 | bcopy (XVECTOR (elt_prefix)->contents, | ||
| 2394 | XVECTOR (chartable_kludge)->contents, | ||
| 2395 | outer_level * sizeof (Lisp_Object)); | ||
| 2396 | } | ||
| 2397 | XVECTOR (chartable_kludge)->contents[outer_level] | ||
| 2398 | = make_number (i); | ||
| 2399 | describe_vector (definition, chartable_kludge, elt_describer, | ||
| 2400 | partial, shadow, entire_map); | ||
| 2401 | continue; | ||
| 2402 | } | ||
| 2403 | |||
| 2354 | if (first) | 2404 | if (first) |
| 2355 | { | 2405 | { |
| 2356 | insert ("\n", 1); | 2406 | insert ("\n", 1); |
| 2357 | first = 0; | 2407 | first = 0; |
| 2358 | } | 2408 | } |
| 2359 | 2409 | ||
| 2360 | /* Output the prefix that applies to every entry in this map. */ | 2410 | if (CHAR_TABLE_P (vector)) |
| 2361 | if (!NILP (elt_prefix)) | 2411 | { |
| 2362 | insert1 (elt_prefix); | 2412 | if (!NILP (elt_prefix)) |
| 2413 | { | ||
| 2414 | /* Must combine elt_prefix with i to produce a character | ||
| 2415 | code, then insert that character's description. */ | ||
| 2416 | } | ||
| 2417 | else | ||
| 2418 | { | ||
| 2419 | /* Get the string to describe the character I, and print it. */ | ||
| 2420 | XSETFASTINT (dummy, i); | ||
| 2363 | 2421 | ||
| 2364 | /* Get the string to describe the character I, and print it. */ | 2422 | /* THIS gets the string to describe the character DUMMY. */ |
| 2365 | XSETFASTINT (dummy, i); | 2423 | this = Fsingle_key_description (dummy); |
| 2424 | insert1 (this); | ||
| 2425 | } | ||
| 2426 | } | ||
| 2427 | else | ||
| 2428 | { | ||
| 2429 | /* Output the prefix that applies to every entry in this map. */ | ||
| 2430 | if (!NILP (elt_prefix)) | ||
| 2431 | insert1 (elt_prefix); | ||
| 2366 | 2432 | ||
| 2367 | /* THIS gets the string to describe the character DUMMY. */ | 2433 | /* Get the string to describe the character I, and print it. */ |
| 2368 | this = Fsingle_key_description (dummy); | 2434 | XSETFASTINT (dummy, i); |
| 2369 | insert1 (this); | 2435 | |
| 2436 | /* THIS gets the string to describe the character DUMMY. */ | ||
| 2437 | this = Fsingle_key_description (dummy); | ||
| 2438 | insert1 (this); | ||
| 2439 | } | ||
| 2370 | 2440 | ||
| 2371 | /* Find all consecutive characters that have the same definition. */ | 2441 | /* Find all consecutive characters that have the same definition. */ |
| 2372 | while (i + 1 < XVECTOR (vector)->size | 2442 | while (i + 1 < XVECTOR (vector)->size |
| @@ -2380,11 +2450,29 @@ describe_vector (vector, elt_prefix, elt_describer, | |||
| 2380 | if (i != XINT (dummy)) | 2450 | if (i != XINT (dummy)) |
| 2381 | { | 2451 | { |
| 2382 | insert (" .. ", 4); | 2452 | insert (" .. ", 4); |
| 2383 | if (!NILP (elt_prefix)) | 2453 | if (CHAR_TABLE_P (vector)) |
| 2384 | insert1 (elt_prefix); | 2454 | { |
| 2455 | if (!NILP (elt_prefix)) | ||
| 2456 | { | ||
| 2457 | /* Must combine elt_prefix with i to produce a character | ||
| 2458 | code, then insert that character's description. */ | ||
| 2459 | } | ||
| 2460 | else | ||
| 2461 | { | ||
| 2462 | XSETFASTINT (dummy, i); | ||
| 2385 | 2463 | ||
| 2386 | XSETFASTINT (dummy, i); | 2464 | this = Fsingle_key_description (dummy); |
| 2387 | insert1 (Fsingle_key_description (dummy)); | 2465 | insert1 (this); |
| 2466 | } | ||
| 2467 | } | ||
| 2468 | else | ||
| 2469 | { | ||
| 2470 | if (!NILP (elt_prefix)) | ||
| 2471 | insert1 (elt_prefix); | ||
| 2472 | |||
| 2473 | XSETFASTINT (dummy, i); | ||
| 2474 | insert1 (Fsingle_key_description (dummy)); | ||
| 2475 | } | ||
| 2388 | } | 2476 | } |
| 2389 | 2477 | ||
| 2390 | /* Print a description of the definition of this character. | 2478 | /* Print a description of the definition of this character. |