diff options
| author | Miles Bader | 2008-02-01 16:01:31 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-02-01 16:01:31 +0000 |
| commit | 6cc41fb06c37234822d5aedf7ce0f77b88bb450a (patch) | |
| tree | a130326faf29d4410ed126e4f0d6a13f11a19df3 /src/keymap.c | |
| parent | b502217bd845bc6280fd2bb1eacce176ed4f7d90 (diff) | |
| parent | dd559368b0db67654f643320b1d84afdabe60e97 (diff) | |
| download | emacs-6cc41fb06c37234822d5aedf7ce0f77b88bb450a.tar.gz emacs-6cc41fb06c37234822d5aedf7ce0f77b88bb450a.zip | |
Merge unicode branch
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1037
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 422 |
1 files changed, 125 insertions, 297 deletions
diff --git a/src/keymap.c b/src/keymap.c index 905ea68973d..1cb481fc050 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -29,6 +29,7 @@ Boston, MA 02110-1301, USA. */ | |||
| 29 | #include "lisp.h" | 29 | #include "lisp.h" |
| 30 | #include "commands.h" | 30 | #include "commands.h" |
| 31 | #include "buffer.h" | 31 | #include "buffer.h" |
| 32 | #include "character.h" | ||
| 32 | #include "charset.h" | 33 | #include "charset.h" |
| 33 | #include "keyboard.h" | 34 | #include "keyboard.h" |
| 34 | #include "frame.h" | 35 | #include "frame.h" |
| @@ -422,11 +423,7 @@ Return PARENT. PARENT should be nil or another keymap. */) | |||
| 422 | 423 | ||
| 423 | if (CHAR_TABLE_P (XCAR (list))) | 424 | if (CHAR_TABLE_P (XCAR (list))) |
| 424 | { | 425 | { |
| 425 | int indices[3]; | 426 | map_char_table (fix_submap_inheritance, Qnil, XCAR (list), keymap); |
| 426 | |||
| 427 | map_char_table (fix_submap_inheritance, Qnil, | ||
| 428 | XCAR (list), XCAR (list), | ||
| 429 | keymap, 0, indices); | ||
| 430 | } | 427 | } |
| 431 | } | 428 | } |
| 432 | 429 | ||
| @@ -566,9 +563,7 @@ access_keymap (map, idx, t_ok, noinherit, autoload) | |||
| 566 | 563 | ||
| 567 | GCPRO4 (map, tail, idx, t_binding); | 564 | GCPRO4 (map, tail, idx, t_binding); |
| 568 | 565 | ||
| 569 | /* If `t_ok' is 2, both `t' and generic-char bindings are accepted. | 566 | /* If `t_ok' is 2, both `t' is accepted. */ |
| 570 | If it is 1, only generic-char bindings are accepted. | ||
| 571 | Otherwise, neither are. */ | ||
| 572 | t_ok = t_ok ? 2 : 0; | 567 | t_ok = t_ok ? 2 : 0; |
| 573 | 568 | ||
| 574 | for (tail = XCDR (map); | 569 | for (tail = XCDR (map); |
| @@ -592,24 +587,6 @@ access_keymap (map, idx, t_ok, noinherit, autoload) | |||
| 592 | 587 | ||
| 593 | if (EQ (key, idx)) | 588 | if (EQ (key, idx)) |
| 594 | val = XCDR (binding); | 589 | val = XCDR (binding); |
| 595 | else if (t_ok | ||
| 596 | && INTEGERP (idx) | ||
| 597 | && (XINT (idx) & CHAR_MODIFIER_MASK) == 0 | ||
| 598 | && INTEGERP (key) | ||
| 599 | && (XINT (key) & CHAR_MODIFIER_MASK) == 0 | ||
| 600 | && !SINGLE_BYTE_CHAR_P (XINT (idx)) | ||
| 601 | && !SINGLE_BYTE_CHAR_P (XINT (key)) | ||
| 602 | && CHAR_VALID_P (XINT (key), 1) | ||
| 603 | && !CHAR_VALID_P (XINT (key), 0) | ||
| 604 | && (CHAR_CHARSET (XINT (key)) | ||
| 605 | == CHAR_CHARSET (XINT (idx)))) | ||
| 606 | { | ||
| 607 | /* KEY is the generic character of the charset of IDX. | ||
| 608 | Use KEY's binding if there isn't a binding for IDX | ||
| 609 | itself. */ | ||
| 610 | t_binding = XCDR (binding); | ||
| 611 | t_ok = 0; | ||
| 612 | } | ||
| 613 | else if (t_ok > 1 && EQ (key, Qt)) | 590 | else if (t_ok > 1 && EQ (key, Qt)) |
| 614 | { | 591 | { |
| 615 | t_binding = XCDR (binding); | 592 | t_binding = XCDR (binding); |
| @@ -721,12 +698,10 @@ map_keymap (map, fun, args, data, autoload) | |||
| 721 | } | 698 | } |
| 722 | else if (CHAR_TABLE_P (binding)) | 699 | else if (CHAR_TABLE_P (binding)) |
| 723 | { | 700 | { |
| 724 | int indices[3]; | 701 | map_char_table (map_keymap_char_table_item, Qnil, binding, |
| 725 | map_char_table (map_keymap_char_table_item, Qnil, binding, binding, | ||
| 726 | Fcons (make_save_value (fun, 0), | 702 | Fcons (make_save_value (fun, 0), |
| 727 | Fcons (make_save_value (data, 0), | 703 | Fcons (make_save_value (data, 0), |
| 728 | args)), | 704 | args))); |
| 729 | 0, indices); | ||
| 730 | } | 705 | } |
| 731 | } | 706 | } |
| 732 | UNGCPRO; | 707 | UNGCPRO; |
| @@ -881,10 +856,15 @@ store_in_keymap (keymap, idx, def) | |||
| 881 | if (!CONSP (keymap) || !EQ (XCAR (keymap), Qkeymap)) | 856 | if (!CONSP (keymap) || !EQ (XCAR (keymap), Qkeymap)) |
| 882 | error ("attempt to define a key in a non-keymap"); | 857 | error ("attempt to define a key in a non-keymap"); |
| 883 | 858 | ||
| 884 | /* If idx is a list (some sort of mouse click, perhaps?), | 859 | /* If idx is a cons, and the car part is a character, idx must be of |
| 885 | the index we want to use is the car of the list, which | 860 | the form (FROM-CHAR . TO-CHAR). */ |
| 886 | ought to be a symbol. */ | 861 | if (CONSP (idx) && CHARACTERP (XCAR (idx))) |
| 887 | idx = EVENT_HEAD (idx); | 862 | CHECK_CHARACTER_CDR (idx); |
| 863 | else | ||
| 864 | /* If idx is a list (some sort of mouse click, perhaps?), | ||
| 865 | the index we want to use is the car of the list, which | ||
| 866 | ought to be a symbol. */ | ||
| 867 | idx = EVENT_HEAD (idx); | ||
| 888 | 868 | ||
| 889 | /* If idx is a symbol, it might have modifiers, which need to | 869 | /* If idx is a symbol, it might have modifiers, which need to |
| 890 | be put in the canonical order. */ | 870 | be put in the canonical order. */ |
| @@ -921,6 +901,19 @@ store_in_keymap (keymap, idx, def) | |||
| 921 | ASET (elt, XFASTINT (idx), def); | 901 | ASET (elt, XFASTINT (idx), def); |
| 922 | return def; | 902 | return def; |
| 923 | } | 903 | } |
| 904 | else if (CONSP (idx) && CHARACTERP (XCAR (idx))) | ||
| 905 | { | ||
| 906 | int from = XFASTINT (XCAR (idx)); | ||
| 907 | int to = XFASTINT (XCDR (idx)); | ||
| 908 | |||
| 909 | if (to >= ASIZE (elt)) | ||
| 910 | to = ASIZE (elt) - 1; | ||
| 911 | for (; from <= to; from++) | ||
| 912 | ASET (elt, from, def); | ||
| 913 | if (to == XFASTINT (XCDR (idx))) | ||
| 914 | /* We have defined all keys in IDX. */ | ||
| 915 | return def; | ||
| 916 | } | ||
| 924 | insertion_point = tail; | 917 | insertion_point = tail; |
| 925 | } | 918 | } |
| 926 | else if (CHAR_TABLE_P (elt)) | 919 | else if (CHAR_TABLE_P (elt)) |
| @@ -937,6 +930,11 @@ store_in_keymap (keymap, idx, def) | |||
| 937 | NILP (def) ? Qt : def); | 930 | NILP (def) ? Qt : def); |
| 938 | return def; | 931 | return def; |
| 939 | } | 932 | } |
| 933 | else if (CONSP (idx) && CHARACTERP (XCAR (idx))) | ||
| 934 | { | ||
| 935 | Fset_char_table_range (elt, idx, NILP (def) ? Qt : def); | ||
| 936 | return def; | ||
| 937 | } | ||
| 940 | insertion_point = tail; | 938 | insertion_point = tail; |
| 941 | } | 939 | } |
| 942 | else if (CONSP (elt)) | 940 | else if (CONSP (elt)) |
| @@ -947,6 +945,19 @@ store_in_keymap (keymap, idx, def) | |||
| 947 | XSETCDR (elt, def); | 945 | XSETCDR (elt, def); |
| 948 | return def; | 946 | return def; |
| 949 | } | 947 | } |
| 948 | else if (CONSP (idx) && CHARACTERP (XCAR (idx))) | ||
| 949 | { | ||
| 950 | int from = XFASTINT (XCAR (idx)); | ||
| 951 | int to = XFASTINT (XCDR (idx)); | ||
| 952 | |||
| 953 | if (from <= XFASTINT (XCAR (elt)) | ||
| 954 | && to >= XFASTINT (XCAR (elt))) | ||
| 955 | { | ||
| 956 | XSETCDR (elt, def); | ||
| 957 | if (from == to) | ||
| 958 | return def; | ||
| 959 | } | ||
| 960 | } | ||
| 950 | } | 961 | } |
| 951 | else if (EQ (elt, Qkeymap)) | 962 | else if (EQ (elt, Qkeymap)) |
| 952 | /* If we find a 'keymap' symbol in the spine of KEYMAP, | 963 | /* If we find a 'keymap' symbol in the spine of KEYMAP, |
| @@ -961,9 +972,22 @@ store_in_keymap (keymap, idx, def) | |||
| 961 | keymap_end: | 972 | keymap_end: |
| 962 | /* We have scanned the entire keymap, and not found a binding for | 973 | /* We have scanned the entire keymap, and not found a binding for |
| 963 | IDX. Let's add one. */ | 974 | IDX. Let's add one. */ |
| 964 | CHECK_IMPURE (insertion_point); | 975 | { |
| 965 | XSETCDR (insertion_point, | 976 | Lisp_Object elt; |
| 966 | Fcons (Fcons (idx, def), XCDR (insertion_point))); | 977 | |
| 978 | if (CONSP (idx) && CHARACTERP (XCAR (idx))) | ||
| 979 | { | ||
| 980 | /* IDX specifies a range of characters, and not all of them | ||
| 981 | were handled yet, which means this keymap doesn't have a | ||
| 982 | char-table. So, we insert a char-table now. */ | ||
| 983 | elt = Fmake_char_table (Qkeymap, Qnil); | ||
| 984 | Fset_char_table_range (elt, idx, NILP (def) ? Qt : def); | ||
| 985 | } | ||
| 986 | else | ||
| 987 | elt = Fcons (idx, def); | ||
| 988 | CHECK_IMPURE (insertion_point); | ||
| 989 | XSETCDR (insertion_point, Fcons (elt, XCDR (insertion_point))); | ||
| 990 | } | ||
| 967 | } | 991 | } |
| 968 | 992 | ||
| 969 | return def; | 993 | return def; |
| @@ -1049,7 +1073,7 @@ static void | |||
| 1049 | copy_keymap_1 (chartable, idx, elt) | 1073 | copy_keymap_1 (chartable, idx, elt) |
| 1050 | Lisp_Object chartable, idx, elt; | 1074 | Lisp_Object chartable, idx, elt; |
| 1051 | { | 1075 | { |
| 1052 | Faset (chartable, idx, copy_keymap_item (elt)); | 1076 | Fset_char_table_range (chartable, idx, copy_keymap_item (elt)); |
| 1053 | } | 1077 | } |
| 1054 | 1078 | ||
| 1055 | DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0, | 1079 | DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0, |
| @@ -1072,9 +1096,8 @@ is not copied. */) | |||
| 1072 | Lisp_Object elt = XCAR (keymap); | 1096 | Lisp_Object elt = XCAR (keymap); |
| 1073 | if (CHAR_TABLE_P (elt)) | 1097 | if (CHAR_TABLE_P (elt)) |
| 1074 | { | 1098 | { |
| 1075 | int indices[3]; | ||
| 1076 | elt = Fcopy_sequence (elt); | 1099 | elt = Fcopy_sequence (elt); |
| 1077 | map_char_table (copy_keymap_1, Qnil, elt, elt, elt, 0, indices); | 1100 | map_char_table (copy_keymap_1, Qnil, elt, elt); |
| 1078 | } | 1101 | } |
| 1079 | else if (VECTORP (elt)) | 1102 | else if (VECTORP (elt)) |
| 1080 | { | 1103 | { |
| @@ -1171,8 +1194,15 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1171 | { | 1194 | { |
| 1172 | c = Faref (key, make_number (idx)); | 1195 | c = Faref (key, make_number (idx)); |
| 1173 | 1196 | ||
| 1174 | if (CONSP (c) && lucid_event_type_list_p (c)) | 1197 | if (CONSP (c)) |
| 1175 | c = Fevent_convert_list (c); | 1198 | { |
| 1199 | /* C may be a Lucid style event type list or a cons (FROM . | ||
| 1200 | TO) specifying a range of characters. */ | ||
| 1201 | if (lucid_event_type_list_p (c)) | ||
| 1202 | c = Fevent_convert_list (c); | ||
| 1203 | else if (CHARACTERP (XCAR (c))) | ||
| 1204 | CHECK_CHARACTER_CDR (c); | ||
| 1205 | } | ||
| 1176 | 1206 | ||
| 1177 | if (SYMBOLP (c)) | 1207 | if (SYMBOLP (c)) |
| 1178 | silly_event_symbol_error (c); | 1208 | silly_event_symbol_error (c); |
| @@ -1193,7 +1223,10 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1193 | idx++; | 1223 | idx++; |
| 1194 | } | 1224 | } |
| 1195 | 1225 | ||
| 1196 | if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c)) | 1226 | if (!INTEGERP (c) && !SYMBOLP (c) |
| 1227 | && (!CONSP (c) | ||
| 1228 | /* If C is a range, it must be a leaf. */ | ||
| 1229 | || (INTEGERP (XCAR (c)) && idx != length))) | ||
| 1197 | error ("Key sequence contains invalid event"); | 1230 | error ("Key sequence contains invalid event"); |
| 1198 | 1231 | ||
| 1199 | if (idx == length) | 1232 | if (idx == length) |
| @@ -2314,15 +2347,13 @@ push_key_description (c, p, force_multibyte) | |||
| 2314 | int force_multibyte; | 2347 | int force_multibyte; |
| 2315 | { | 2348 | { |
| 2316 | unsigned c2; | 2349 | unsigned c2; |
| 2317 | int valid_p; | ||
| 2318 | 2350 | ||
| 2319 | /* Clear all the meaningless bits above the meta bit. */ | 2351 | /* Clear all the meaningless bits above the meta bit. */ |
| 2320 | c &= meta_modifier | ~ - meta_modifier; | 2352 | c &= meta_modifier | ~ - meta_modifier; |
| 2321 | c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier | 2353 | c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier |
| 2322 | | meta_modifier | shift_modifier | super_modifier); | 2354 | | meta_modifier | shift_modifier | super_modifier); |
| 2323 | 2355 | ||
| 2324 | valid_p = SINGLE_BYTE_CHAR_P (c2) || char_valid_p (c2, 0); | 2356 | if (! CHARACTERP (make_number (c2))) |
| 2325 | if (! valid_p) | ||
| 2326 | { | 2357 | { |
| 2327 | /* KEY_DESCRIPTION_SIZE is large enough for this. */ | 2358 | /* KEY_DESCRIPTION_SIZE is large enough for this. */ |
| 2328 | p += sprintf (p, "[%d]", c); | 2359 | p += sprintf (p, "[%d]", c); |
| @@ -2416,25 +2447,12 @@ push_key_description (c, p, force_multibyte) | |||
| 2416 | } | 2447 | } |
| 2417 | else | 2448 | else |
| 2418 | { | 2449 | { |
| 2419 | if (force_multibyte) | 2450 | /* Now we are sure that C is a valid character code. */ |
| 2420 | { | 2451 | if (NILP (current_buffer->enable_multibyte_characters) |
| 2421 | if (SINGLE_BYTE_CHAR_P (c)) | 2452 | && ! force_multibyte) |
| 2422 | c = unibyte_char_to_multibyte (c); | 2453 | *p++ = multibyte_char_to_unibyte (c, Qnil); |
| 2423 | p += CHAR_STRING (c, p); | ||
| 2424 | } | ||
| 2425 | else if (NILP (current_buffer->enable_multibyte_characters)) | ||
| 2426 | { | ||
| 2427 | int bit_offset; | ||
| 2428 | *p++ = '\\'; | ||
| 2429 | /* The biggest character code uses 19 bits. */ | ||
| 2430 | for (bit_offset = 18; bit_offset >= 0; bit_offset -= 3) | ||
| 2431 | { | ||
| 2432 | if (c >= (1 << bit_offset)) | ||
| 2433 | *p++ = ((c & (7 << bit_offset)) >> bit_offset) + '0'; | ||
| 2434 | } | ||
| 2435 | } | ||
| 2436 | else | 2454 | else |
| 2437 | p += CHAR_STRING (c, p); | 2455 | p += CHAR_STRING (c, (unsigned char *) p); |
| 2438 | } | 2456 | } |
| 2439 | 2457 | ||
| 2440 | return p; | 2458 | return p; |
| @@ -2458,56 +2476,10 @@ around function keys and event symbols. */) | |||
| 2458 | 2476 | ||
| 2459 | if (INTEGERP (key)) /* Normal character */ | 2477 | if (INTEGERP (key)) /* Normal character */ |
| 2460 | { | 2478 | { |
| 2461 | unsigned int charset, c1, c2; | 2479 | char tem[KEY_DESCRIPTION_SIZE]; |
| 2462 | int without_bits = XINT (key) & ~((-1) << CHARACTERBITS); | ||
| 2463 | |||
| 2464 | if (SINGLE_BYTE_CHAR_P (without_bits)) | ||
| 2465 | charset = 0; | ||
| 2466 | else | ||
| 2467 | SPLIT_CHAR (without_bits, charset, c1, c2); | ||
| 2468 | |||
| 2469 | if (! CHAR_VALID_P (without_bits, 1)) | ||
| 2470 | { | ||
| 2471 | char buf[256]; | ||
| 2472 | 2480 | ||
| 2473 | sprintf (buf, "Invalid char code %ld", (long) XINT (key)); | 2481 | *push_key_description (XUINT (key), tem, 1) = 0; |
| 2474 | return build_string (buf); | 2482 | return build_string (tem); |
| 2475 | } | ||
| 2476 | else if (charset | ||
| 2477 | && ((c1 == 0 && c2 == -1) || c2 == 0)) | ||
| 2478 | { | ||
| 2479 | /* Handle a generic character. */ | ||
| 2480 | Lisp_Object name; | ||
| 2481 | char buf[256]; | ||
| 2482 | |||
| 2483 | name = CHARSET_TABLE_INFO (charset, CHARSET_SHORT_NAME_IDX); | ||
| 2484 | CHECK_STRING (name); | ||
| 2485 | if (c1 == 0) | ||
| 2486 | /* Only a charset is specified. */ | ||
| 2487 | sprintf (buf, "Generic char %d: all of ", without_bits); | ||
| 2488 | else | ||
| 2489 | /* 1st code-point of 2-dimensional charset is specified. */ | ||
| 2490 | sprintf (buf, "Generic char %d: row %d of ", without_bits, c1); | ||
| 2491 | return concat2 (build_string (buf), name); | ||
| 2492 | } | ||
| 2493 | else | ||
| 2494 | { | ||
| 2495 | char tem[KEY_DESCRIPTION_SIZE], *end; | ||
| 2496 | int nbytes, nchars; | ||
| 2497 | Lisp_Object string; | ||
| 2498 | |||
| 2499 | end = push_key_description (XUINT (key), tem, 1); | ||
| 2500 | nbytes = end - tem; | ||
| 2501 | nchars = multibyte_chars_in_text (tem, nbytes); | ||
| 2502 | if (nchars == nbytes) | ||
| 2503 | { | ||
| 2504 | *end = '\0'; | ||
| 2505 | string = build_string (tem); | ||
| 2506 | } | ||
| 2507 | else | ||
| 2508 | string = make_multibyte_string (tem, nchars, nbytes); | ||
| 2509 | return string; | ||
| 2510 | } | ||
| 2511 | } | 2483 | } |
| 2512 | else if (SYMBOLP (key)) /* Function key or event-symbol */ | 2484 | else if (SYMBOLP (key)) /* Function key or event-symbol */ |
| 2513 | { | 2485 | { |
| @@ -2573,7 +2545,7 @@ See Info node `(elisp)Describing Characters' for examples. */) | |||
| 2573 | CHECK_NUMBER (character); | 2545 | CHECK_NUMBER (character); |
| 2574 | 2546 | ||
| 2575 | c = XINT (character); | 2547 | c = XINT (character); |
| 2576 | if (!SINGLE_BYTE_CHAR_P (c)) | 2548 | if (!ASCII_CHAR_P (c)) |
| 2577 | { | 2549 | { |
| 2578 | int len = CHAR_STRING (c, str); | 2550 | int len = CHAR_STRING (c, str); |
| 2579 | 2551 | ||
| @@ -2952,7 +2924,11 @@ where_is_internal_1 (key, binding, args, data) | |||
| 2952 | Faset (sequence, last, make_number (XINT (key) | meta_modifier)); | 2924 | Faset (sequence, last, make_number (XINT (key) | meta_modifier)); |
| 2953 | } | 2925 | } |
| 2954 | else | 2926 | else |
| 2955 | sequence = append_key (this, key); | 2927 | { |
| 2928 | if (CONSP (key)) | ||
| 2929 | key = Fcons (XCAR (key), XCDR (key)); | ||
| 2930 | sequence = append_key (this, key); | ||
| 2931 | } | ||
| 2956 | 2932 | ||
| 2957 | if (!NILP (where_is_cache)) | 2933 | if (!NILP (where_is_cache)) |
| 2958 | { | 2934 | { |
| @@ -3608,9 +3584,10 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3608 | If the definition in effect in the whole map does not match | 3584 | If the definition in effect in the whole map does not match |
| 3609 | the one in this vector, we ignore this one. | 3585 | the one in this vector, we ignore this one. |
| 3610 | 3586 | ||
| 3611 | When describing a sub-char-table, INDICES is a list of | 3587 | ARGS is simply passed as the second argument to ELT_DESCRIBER. |
| 3612 | indices at higher levels in this char-table, | 3588 | |
| 3613 | and CHAR_TABLE_DEPTH says how many levels down we have gone. | 3589 | INDICES and CHAR_TABLE_DEPTH are ignored. They will be removed in |
| 3590 | the near future. | ||
| 3614 | 3591 | ||
| 3615 | KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-. | 3592 | KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-. |
| 3616 | 3593 | ||
| @@ -3635,24 +3612,18 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3635 | Lisp_Object definition; | 3612 | Lisp_Object definition; |
| 3636 | Lisp_Object tem2; | 3613 | Lisp_Object tem2; |
| 3637 | Lisp_Object elt_prefix = Qnil; | 3614 | Lisp_Object elt_prefix = Qnil; |
| 3638 | register int i; | 3615 | int i; |
| 3639 | Lisp_Object suppress; | 3616 | Lisp_Object suppress; |
| 3640 | Lisp_Object kludge; | 3617 | Lisp_Object kludge; |
| 3641 | int first = 1; | 3618 | int first = 1; |
| 3642 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 3619 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 3643 | /* Range of elements to be handled. */ | 3620 | /* Range of elements to be handled. */ |
| 3644 | int from, to; | 3621 | int from, to; |
| 3645 | /* A flag to tell if a leaf in this level of char-table is not a | 3622 | Lisp_Object character; |
| 3646 | generic character (i.e. a complete multibyte character). */ | ||
| 3647 | int complete_char; | ||
| 3648 | int character; | ||
| 3649 | int starting_i; | 3623 | int starting_i; |
| 3650 | 3624 | ||
| 3651 | suppress = Qnil; | 3625 | suppress = Qnil; |
| 3652 | 3626 | ||
| 3653 | if (indices == 0) | ||
| 3654 | indices = (int *) alloca (3 * sizeof (int)); | ||
| 3655 | |||
| 3656 | definition = Qnil; | 3627 | definition = Qnil; |
| 3657 | 3628 | ||
| 3658 | if (!keymap_p) | 3629 | if (!keymap_p) |
| @@ -3676,61 +3647,24 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3676 | if (partial) | 3647 | if (partial) |
| 3677 | suppress = intern ("suppress-keymap"); | 3648 | suppress = intern ("suppress-keymap"); |
| 3678 | 3649 | ||
| 3679 | if (CHAR_TABLE_P (vector)) | 3650 | from = 0; |
| 3680 | { | 3651 | to = CHAR_TABLE_P (vector) ? MAX_CHAR + 1 : XVECTOR (vector)->size; |
| 3681 | if (char_table_depth == 0) | ||
| 3682 | { | ||
| 3683 | /* VECTOR is a top level char-table. */ | ||
| 3684 | complete_char = 1; | ||
| 3685 | from = 0; | ||
| 3686 | to = CHAR_TABLE_ORDINARY_SLOTS; | ||
| 3687 | } | ||
| 3688 | else | ||
| 3689 | { | ||
| 3690 | /* VECTOR is a sub char-table. */ | ||
| 3691 | if (char_table_depth >= 3) | ||
| 3692 | /* A char-table is never that deep. */ | ||
| 3693 | error ("Too deep char table"); | ||
| 3694 | |||
| 3695 | complete_char | ||
| 3696 | = (CHARSET_VALID_P (indices[0]) | ||
| 3697 | && ((CHARSET_DIMENSION (indices[0]) == 1 | ||
| 3698 | && char_table_depth == 1) | ||
| 3699 | || char_table_depth == 2)); | ||
| 3700 | |||
| 3701 | /* Meaningful elements are from 32th to 127th. */ | ||
| 3702 | from = 32; | ||
| 3703 | to = SUB_CHAR_TABLE_ORDINARY_SLOTS; | ||
| 3704 | } | ||
| 3705 | } | ||
| 3706 | else | ||
| 3707 | { | ||
| 3708 | /* This does the right thing for ordinary vectors. */ | ||
| 3709 | |||
| 3710 | complete_char = 1; | ||
| 3711 | from = 0; | ||
| 3712 | to = XVECTOR (vector)->size; | ||
| 3713 | } | ||
| 3714 | 3652 | ||
| 3715 | for (i = from; i < to; i++) | 3653 | for (i = from; i < to; i++) |
| 3716 | { | 3654 | { |
| 3717 | int this_shadowed = 0; | 3655 | int this_shadowed = 0; |
| 3718 | QUIT; | 3656 | int range_beg, range_end; |
| 3657 | Lisp_Object val; | ||
| 3719 | 3658 | ||
| 3720 | if (CHAR_TABLE_P (vector)) | 3659 | QUIT; |
| 3721 | { | ||
| 3722 | if (char_table_depth == 0 && i >= CHAR_TABLE_SINGLE_BYTE_SLOTS) | ||
| 3723 | complete_char = 0; | ||
| 3724 | 3660 | ||
| 3725 | if (i >= CHAR_TABLE_SINGLE_BYTE_SLOTS | 3661 | starting_i = i; |
| 3726 | && !CHARSET_DEFINED_P (i - 128)) | ||
| 3727 | continue; | ||
| 3728 | 3662 | ||
| 3729 | definition | 3663 | if (CHAR_TABLE_P (vector)) |
| 3730 | = get_keyelt (XCHAR_TABLE (vector)->contents[i], 0); | 3664 | val = char_table_ref_and_range (vector, i, &range_beg, &i); |
| 3731 | } | ||
| 3732 | else | 3665 | else |
| 3733 | definition = get_keyelt (AREF (vector, i), 0); | 3666 | val = AREF (vector, i); |
| 3667 | definition = get_keyelt (val, 0); | ||
| 3734 | 3668 | ||
| 3735 | if (NILP (definition)) continue; | 3669 | if (NILP (definition)) continue; |
| 3736 | 3670 | ||
| @@ -3744,31 +3678,11 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3744 | if (!NILP (tem)) continue; | 3678 | if (!NILP (tem)) continue; |
| 3745 | } | 3679 | } |
| 3746 | 3680 | ||
| 3747 | /* Set CHARACTER to the character this entry describes, if any. | 3681 | character = make_number (starting_i); |
| 3748 | Also update *INDICES. */ | 3682 | ASET (kludge, 0, character); |
| 3749 | if (CHAR_TABLE_P (vector)) | ||
| 3750 | { | ||
| 3751 | indices[char_table_depth] = i; | ||
| 3752 | |||
| 3753 | if (char_table_depth == 0) | ||
| 3754 | { | ||
| 3755 | character = i; | ||
| 3756 | indices[0] = i - 128; | ||
| 3757 | } | ||
| 3758 | else if (complete_char) | ||
| 3759 | { | ||
| 3760 | character = MAKE_CHAR (indices[0], indices[1], indices[2]); | ||
| 3761 | } | ||
| 3762 | else | ||
| 3763 | character = 0; | ||
| 3764 | } | ||
| 3765 | else | ||
| 3766 | character = i; | ||
| 3767 | |||
| 3768 | ASET (kludge, 0, make_number (character)); | ||
| 3769 | 3683 | ||
| 3770 | /* If this binding is shadowed by some other map, ignore it. */ | 3684 | /* If this binding is shadowed by some other map, ignore it. */ |
| 3771 | if (!NILP (shadow) && complete_char) | 3685 | if (!NILP (shadow)) |
| 3772 | { | 3686 | { |
| 3773 | Lisp_Object tem; | 3687 | Lisp_Object tem; |
| 3774 | 3688 | ||
| @@ -3785,7 +3699,7 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3785 | 3699 | ||
| 3786 | /* Ignore this definition if it is shadowed by an earlier | 3700 | /* Ignore this definition if it is shadowed by an earlier |
| 3787 | one in the same keymap. */ | 3701 | one in the same keymap. */ |
| 3788 | if (!NILP (entire_map) && complete_char) | 3702 | if (!NILP (entire_map)) |
| 3789 | { | 3703 | { |
| 3790 | Lisp_Object tem; | 3704 | Lisp_Object tem; |
| 3791 | 3705 | ||
| @@ -3797,89 +3711,28 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3797 | 3711 | ||
| 3798 | if (first) | 3712 | if (first) |
| 3799 | { | 3713 | { |
| 3800 | if (char_table_depth == 0) | 3714 | insert ("\n", 1); |
| 3801 | insert ("\n", 1); | ||
| 3802 | first = 0; | 3715 | first = 0; |
| 3803 | } | 3716 | } |
| 3804 | 3717 | ||
| 3805 | /* For a sub char-table, show the depth by indentation. | ||
| 3806 | CHAR_TABLE_DEPTH can be greater than 0 only for a char-table. */ | ||
| 3807 | if (char_table_depth > 0) | ||
| 3808 | insert (" ", char_table_depth * 2); /* depth is 1 or 2. */ | ||
| 3809 | |||
| 3810 | /* Output the prefix that applies to every entry in this map. */ | 3718 | /* Output the prefix that applies to every entry in this map. */ |
| 3811 | if (!NILP (elt_prefix)) | 3719 | if (!NILP (elt_prefix)) |
| 3812 | insert1 (elt_prefix); | 3720 | insert1 (elt_prefix); |
| 3813 | 3721 | ||
| 3814 | /* Insert or describe the character this slot is for, | 3722 | insert1 (Fkey_description (kludge, prefix)); |
| 3815 | or a description of what it is for. */ | ||
| 3816 | if (SUB_CHAR_TABLE_P (vector)) | ||
| 3817 | { | ||
| 3818 | if (complete_char) | ||
| 3819 | insert_char (character); | ||
| 3820 | else | ||
| 3821 | { | ||
| 3822 | /* We need an octal representation for this block of | ||
| 3823 | characters. */ | ||
| 3824 | char work[16]; | ||
| 3825 | sprintf (work, "(row %d)", i); | ||
| 3826 | insert (work, strlen (work)); | ||
| 3827 | } | ||
| 3828 | } | ||
| 3829 | else if (CHAR_TABLE_P (vector)) | ||
| 3830 | { | ||
| 3831 | if (complete_char) | ||
| 3832 | insert1 (Fkey_description (kludge, prefix)); | ||
| 3833 | else | ||
| 3834 | { | ||
| 3835 | /* Print the information for this character set. */ | ||
| 3836 | insert_string ("<"); | ||
| 3837 | tem2 = CHARSET_TABLE_INFO (i - 128, CHARSET_SHORT_NAME_IDX); | ||
| 3838 | if (STRINGP (tem2)) | ||
| 3839 | insert_from_string (tem2, 0, 0, SCHARS (tem2), | ||
| 3840 | SBYTES (tem2), 0); | ||
| 3841 | else | ||
| 3842 | insert ("?", 1); | ||
| 3843 | insert (">", 1); | ||
| 3844 | } | ||
| 3845 | } | ||
| 3846 | else | ||
| 3847 | { | ||
| 3848 | insert1 (Fkey_description (kludge, prefix)); | ||
| 3849 | } | ||
| 3850 | |||
| 3851 | /* If we find a sub char-table within a char-table, | ||
| 3852 | scan it recursively; it defines the details for | ||
| 3853 | a character set or a portion of a character set. */ | ||
| 3854 | if (CHAR_TABLE_P (vector) && SUB_CHAR_TABLE_P (definition)) | ||
| 3855 | { | ||
| 3856 | insert ("\n", 1); | ||
| 3857 | describe_vector (definition, prefix, args, elt_describer, | ||
| 3858 | partial, shadow, entire_map, | ||
| 3859 | indices, char_table_depth + 1, keymap_p, | ||
| 3860 | mention_shadow); | ||
| 3861 | continue; | ||
| 3862 | } | ||
| 3863 | |||
| 3864 | starting_i = i; | ||
| 3865 | 3723 | ||
| 3866 | /* Find all consecutive characters or rows that have the same | 3724 | /* Find all consecutive characters or rows that have the same |
| 3867 | definition. But, for elements of a top level char table, if | 3725 | definition. But, for elements of a top level char table, if |
| 3868 | they are for charsets, we had better describe one by one even | 3726 | they are for charsets, we had better describe one by one even |
| 3869 | if they have the same definition. */ | 3727 | if they have the same definition. */ |
| 3870 | if (CHAR_TABLE_P (vector)) | 3728 | if (CHAR_TABLE_P (vector)) |
| 3871 | { | 3729 | while (i + 1 < to |
| 3872 | int limit = to; | 3730 | && (val = char_table_ref_and_range (vector, i + 1, |
| 3873 | 3731 | &range_beg, &range_end), | |
| 3874 | if (char_table_depth == 0) | 3732 | tem2 = get_keyelt (val, 0), |
| 3875 | limit = CHAR_TABLE_SINGLE_BYTE_SLOTS; | 3733 | !NILP (tem2)) |
| 3876 | 3734 | && !NILP (Fequal (tem2, definition))) | |
| 3877 | while (i + 1 < limit | 3735 | i = range_end; |
| 3878 | && (tem2 = get_keyelt (XCHAR_TABLE (vector)->contents[i + 1], 0), | ||
| 3879 | !NILP (tem2)) | ||
| 3880 | && !NILP (Fequal (tem2, definition))) | ||
| 3881 | i++; | ||
| 3882 | } | ||
| 3883 | else | 3736 | else |
| 3884 | while (i + 1 < to | 3737 | while (i + 1 < to |
| 3885 | && (tem2 = get_keyelt (AREF (vector, i + 1), 0), | 3738 | && (tem2 = get_keyelt (AREF (vector, i + 1), 0), |
| @@ -3887,7 +3740,6 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3887 | && !NILP (Fequal (tem2, definition))) | 3740 | && !NILP (Fequal (tem2, definition))) |
| 3888 | i++; | 3741 | i++; |
| 3889 | 3742 | ||
| 3890 | |||
| 3891 | /* If we have a range of more than one character, | 3743 | /* If we have a range of more than one character, |
| 3892 | print where the range reaches to. */ | 3744 | print where the range reaches to. */ |
| 3893 | 3745 | ||
| @@ -3900,31 +3752,7 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3900 | if (!NILP (elt_prefix)) | 3752 | if (!NILP (elt_prefix)) |
| 3901 | insert1 (elt_prefix); | 3753 | insert1 (elt_prefix); |
| 3902 | 3754 | ||
| 3903 | if (CHAR_TABLE_P (vector)) | 3755 | insert1 (Fkey_description (kludge, prefix)); |
| 3904 | { | ||
| 3905 | if (char_table_depth == 0) | ||
| 3906 | { | ||
| 3907 | insert1 (Fkey_description (kludge, prefix)); | ||
| 3908 | } | ||
| 3909 | else if (complete_char) | ||
| 3910 | { | ||
| 3911 | indices[char_table_depth] = i; | ||
| 3912 | character = MAKE_CHAR (indices[0], indices[1], indices[2]); | ||
| 3913 | insert_char (character); | ||
| 3914 | } | ||
| 3915 | else | ||
| 3916 | { | ||
| 3917 | /* We need an octal representation for this block of | ||
| 3918 | characters. */ | ||
| 3919 | char work[16]; | ||
| 3920 | sprintf (work, "(row %d)", i); | ||
| 3921 | insert (work, strlen (work)); | ||
| 3922 | } | ||
| 3923 | } | ||
| 3924 | else | ||
| 3925 | { | ||
| 3926 | insert1 (Fkey_description (kludge, prefix)); | ||
| 3927 | } | ||
| 3928 | } | 3756 | } |
| 3929 | 3757 | ||
| 3930 | /* Print a description of the definition of this character. | 3758 | /* Print a description of the definition of this character. |
| @@ -3940,11 +3768,11 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3940 | } | 3768 | } |
| 3941 | } | 3769 | } |
| 3942 | 3770 | ||
| 3943 | /* For (sub) char-table, print `defalt' slot at last. */ | 3771 | if (CHAR_TABLE_P (vector) && ! NILP (XCHAR_TABLE (vector)->defalt)) |
| 3944 | if (CHAR_TABLE_P (vector) && !NILP (XCHAR_TABLE (vector)->defalt)) | ||
| 3945 | { | 3772 | { |
| 3946 | insert (" ", char_table_depth * 2); | 3773 | if (!NILP (elt_prefix)) |
| 3947 | insert_string ("<<default>>"); | 3774 | insert1 (elt_prefix); |
| 3775 | insert ("default", 7); | ||
| 3948 | (*elt_describer) (XCHAR_TABLE (vector)->defalt, args); | 3776 | (*elt_describer) (XCHAR_TABLE (vector)->defalt, args); |
| 3949 | } | 3777 | } |
| 3950 | 3778 | ||