diff options
| author | Richard M. Stallman | 2005-02-15 06:39:18 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-02-15 06:39:18 +0000 |
| commit | b88e82fd1f4ad3607ef11dd12e8c78c4eea0a4dc (patch) | |
| tree | 7429a2ffbbbaecfafbc4db339a00339079228d68 /src/keymap.c | |
| parent | e679a3c1d50168cffb09f8a8f9128f8fdc07b355 (diff) | |
| download | emacs-b88e82fd1f4ad3607ef11dd12e8c78c4eea0a4dc.tar.gz emacs-b88e82fd1f4ad3607ef11dd12e8c78c4eea0a4dc.zip | |
(describe_map_tree): New arg MENTION_SHADOW. Calls changed.
(describe_map, describe_vector): Likewise. When it's 1,
don't omit shadowed bindings, instead mark them as shadowed.
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 80 |
1 files changed, 60 insertions, 20 deletions
diff --git a/src/keymap.c b/src/keymap.c index 260d7232bb0..10ae718ba0d 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -120,10 +120,11 @@ static void describe_command P_ ((Lisp_Object, Lisp_Object)); | |||
| 120 | static void describe_translation P_ ((Lisp_Object, Lisp_Object)); | 120 | 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, int)); |
| 124 | static void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object, | 124 | static void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object, |
| 125 | void (*) (Lisp_Object, Lisp_Object), int, | 125 | void (*) (Lisp_Object, Lisp_Object), int, |
| 126 | Lisp_Object, Lisp_Object, int *, int, int)); | 126 | Lisp_Object, Lisp_Object, int *, |
| 127 | int, int, int)); | ||
| 127 | static void silly_event_symbol_error P_ ((Lisp_Object)); | 128 | static void silly_event_symbol_error P_ ((Lisp_Object)); |
| 128 | 129 | ||
| 129 | /* Keymap object support - constructors and predicates. */ | 130 | /* Keymap object support - constructors and predicates. */ |
| @@ -2834,7 +2835,7 @@ You type Translation\n\ | |||
| 2834 | 2835 | ||
| 2835 | if (!NILP (Vkey_translation_map)) | 2836 | if (!NILP (Vkey_translation_map)) |
| 2836 | describe_map_tree (Vkey_translation_map, 0, Qnil, prefix, | 2837 | describe_map_tree (Vkey_translation_map, 0, Qnil, prefix, |
| 2837 | "Key translations", nomenu, 1, 0); | 2838 | "Key translations", nomenu, 1, 0, 0); |
| 2838 | 2839 | ||
| 2839 | 2840 | ||
| 2840 | /* Print the (major mode) local map. */ | 2841 | /* Print the (major mode) local map. */ |
| @@ -2847,7 +2848,7 @@ You type Translation\n\ | |||
| 2847 | if (!NILP (start1)) | 2848 | if (!NILP (start1)) |
| 2848 | { | 2849 | { |
| 2849 | describe_map_tree (start1, 1, shadow, prefix, | 2850 | describe_map_tree (start1, 1, shadow, prefix, |
| 2850 | "\f\nOverriding Bindings", nomenu, 0, 0); | 2851 | "\f\nOverriding Bindings", nomenu, 0, 0, 0); |
| 2851 | shadow = Fcons (start1, shadow); | 2852 | shadow = Fcons (start1, shadow); |
| 2852 | } | 2853 | } |
| 2853 | else | 2854 | else |
| @@ -2868,7 +2869,8 @@ You type Translation\n\ | |||
| 2868 | if (!NILP (start1)) | 2869 | if (!NILP (start1)) |
| 2869 | { | 2870 | { |
| 2870 | describe_map_tree (start1, 1, shadow, prefix, | 2871 | describe_map_tree (start1, 1, shadow, prefix, |
| 2871 | "\f\n`keymap' Property Bindings", nomenu, 0, 0); | 2872 | "\f\n`keymap' Property Bindings", nomenu, |
| 2873 | 0, 0, 0); | ||
| 2872 | shadow = Fcons (start1, shadow); | 2874 | shadow = Fcons (start1, shadow); |
| 2873 | } | 2875 | } |
| 2874 | 2876 | ||
| @@ -2896,7 +2898,8 @@ You type Translation\n\ | |||
| 2896 | p += sizeof (" Minor Mode Bindings") - 1; | 2898 | p += sizeof (" Minor Mode Bindings") - 1; |
| 2897 | *p = 0; | 2899 | *p = 0; |
| 2898 | 2900 | ||
| 2899 | describe_map_tree (maps[i], 1, shadow, prefix, title, nomenu, 0, 0); | 2901 | describe_map_tree (maps[i], 1, shadow, prefix, |
| 2902 | title, nomenu, 0, 0, 0); | ||
| 2900 | shadow = Fcons (maps[i], shadow); | 2903 | shadow = Fcons (maps[i], shadow); |
| 2901 | } | 2904 | } |
| 2902 | 2905 | ||
| @@ -2906,23 +2909,23 @@ You type Translation\n\ | |||
| 2906 | { | 2909 | { |
| 2907 | if (EQ (start1, XBUFFER (buffer)->keymap)) | 2910 | if (EQ (start1, XBUFFER (buffer)->keymap)) |
| 2908 | describe_map_tree (start1, 1, shadow, prefix, | 2911 | describe_map_tree (start1, 1, shadow, prefix, |
| 2909 | "\f\nMajor Mode Bindings", nomenu, 0, 0); | 2912 | "\f\nMajor Mode Bindings", nomenu, 0, 0, 0); |
| 2910 | else | 2913 | else |
| 2911 | describe_map_tree (start1, 1, shadow, prefix, | 2914 | describe_map_tree (start1, 1, shadow, prefix, |
| 2912 | "\f\n`local-map' Property Bindings", | 2915 | "\f\n`local-map' Property Bindings", |
| 2913 | nomenu, 0, 0); | 2916 | nomenu, 0, 0, 0); |
| 2914 | 2917 | ||
| 2915 | shadow = Fcons (start1, shadow); | 2918 | shadow = Fcons (start1, shadow); |
| 2916 | } | 2919 | } |
| 2917 | } | 2920 | } |
| 2918 | 2921 | ||
| 2919 | describe_map_tree (current_global_map, 1, shadow, prefix, | 2922 | describe_map_tree (current_global_map, 1, shadow, prefix, |
| 2920 | "\f\nGlobal Bindings", nomenu, 0, 1); | 2923 | "\f\nGlobal Bindings", nomenu, 0, 1, 0); |
| 2921 | 2924 | ||
| 2922 | /* Print the function-key-map translations under this prefix. */ | 2925 | /* Print the function-key-map translations under this prefix. */ |
| 2923 | if (!NILP (Vfunction_key_map)) | 2926 | if (!NILP (Vfunction_key_map)) |
| 2924 | describe_map_tree (Vfunction_key_map, 0, Qnil, prefix, | 2927 | describe_map_tree (Vfunction_key_map, 0, Qnil, prefix, |
| 2925 | "\f\nFunction key map translations", nomenu, 1, 0); | 2928 | "\f\nFunction key map translations", nomenu, 1, 0, 0); |
| 2926 | 2929 | ||
| 2927 | UNGCPRO; | 2930 | UNGCPRO; |
| 2928 | return Qnil; | 2931 | return Qnil; |
| @@ -2943,17 +2946,21 @@ You type Translation\n\ | |||
| 2943 | so print strings and vectors differently. | 2946 | so print strings and vectors differently. |
| 2944 | 2947 | ||
| 2945 | If ALWAYS_TITLE is nonzero, print the title even if there are no maps | 2948 | If ALWAYS_TITLE is nonzero, print the title even if there are no maps |
| 2946 | to look through. */ | 2949 | to look through. |
| 2950 | |||
| 2951 | If MENTION_SHADOW is nonzero, then when something is shadowed by SHADOW, | ||
| 2952 | don't omit it; instead, mention it but say it is shadowed. */ | ||
| 2947 | 2953 | ||
| 2948 | void | 2954 | void |
| 2949 | describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl, | 2955 | describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl, |
| 2950 | always_title) | 2956 | always_title, mention_shadow) |
| 2951 | Lisp_Object startmap, shadow, prefix; | 2957 | Lisp_Object startmap, shadow, prefix; |
| 2952 | int partial; | 2958 | int partial; |
| 2953 | char *title; | 2959 | char *title; |
| 2954 | int nomenu; | 2960 | int nomenu; |
| 2955 | int transl; | 2961 | int transl; |
| 2956 | int always_title; | 2962 | int always_title; |
| 2963 | int mention_shadow; | ||
| 2957 | { | 2964 | { |
| 2958 | Lisp_Object maps, orig_maps, seen, sub_shadows; | 2965 | Lisp_Object maps, orig_maps, seen, sub_shadows; |
| 2959 | struct gcpro gcpro1, gcpro2, gcpro3; | 2966 | struct gcpro gcpro1, gcpro2, gcpro3; |
| @@ -3055,7 +3062,7 @@ key binding\n\ | |||
| 3055 | 3062 | ||
| 3056 | describe_map (Fcdr (elt), prefix, | 3063 | describe_map (Fcdr (elt), prefix, |
| 3057 | transl ? describe_translation : describe_command, | 3064 | transl ? describe_translation : describe_command, |
| 3058 | partial, sub_shadows, &seen, nomenu); | 3065 | partial, sub_shadows, &seen, nomenu, mention_shadow); |
| 3059 | 3066 | ||
| 3060 | skip: ; | 3067 | skip: ; |
| 3061 | } | 3068 | } |
| @@ -3135,7 +3142,8 @@ describe_translation (definition, args) | |||
| 3135 | PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ | 3142 | PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ |
| 3136 | 3143 | ||
| 3137 | static void | 3144 | static void |
| 3138 | describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu) | 3145 | describe_map (map, prefix, elt_describer, partial, shadow, |
| 3146 | seen, nomenu, mention_shadow) | ||
| 3139 | register Lisp_Object map; | 3147 | register Lisp_Object map; |
| 3140 | Lisp_Object prefix; | 3148 | Lisp_Object prefix; |
| 3141 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); | 3149 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); |
| @@ -3143,6 +3151,7 @@ describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu) | |||
| 3143 | Lisp_Object shadow; | 3151 | Lisp_Object shadow; |
| 3144 | Lisp_Object *seen; | 3152 | Lisp_Object *seen; |
| 3145 | int nomenu; | 3153 | int nomenu; |
| 3154 | int mention_shadow; | ||
| 3146 | { | 3155 | { |
| 3147 | Lisp_Object tail, definition, event; | 3156 | Lisp_Object tail, definition, event; |
| 3148 | Lisp_Object tem; | 3157 | Lisp_Object tem; |
| @@ -3172,9 +3181,10 @@ describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu) | |||
| 3172 | || CHAR_TABLE_P (XCAR (tail))) | 3181 | || CHAR_TABLE_P (XCAR (tail))) |
| 3173 | describe_vector (XCAR (tail), | 3182 | describe_vector (XCAR (tail), |
| 3174 | prefix, Qnil, elt_describer, partial, shadow, map, | 3183 | prefix, Qnil, elt_describer, partial, shadow, map, |
| 3175 | (int *)0, 0, 1); | 3184 | (int *)0, 0, 1, mention_shadow); |
| 3176 | else if (CONSP (XCAR (tail))) | 3185 | else if (CONSP (XCAR (tail))) |
| 3177 | { | 3186 | { |
| 3187 | int this_shadowed = 0; | ||
| 3178 | event = XCAR (XCAR (tail)); | 3188 | event = XCAR (XCAR (tail)); |
| 3179 | 3189 | ||
| 3180 | /* Ignore bindings whose "prefix" are not really valid events. | 3190 | /* Ignore bindings whose "prefix" are not really valid events. |
| @@ -3203,7 +3213,13 @@ describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu) | |||
| 3203 | if (!NILP (shadow)) | 3213 | if (!NILP (shadow)) |
| 3204 | { | 3214 | { |
| 3205 | tem = shadow_lookup (shadow, kludge, Qt); | 3215 | tem = shadow_lookup (shadow, kludge, Qt); |
| 3206 | if (!NILP (tem)) continue; | 3216 | if (!NILP (tem)) |
| 3217 | { | ||
| 3218 | if (mention_shadow) | ||
| 3219 | this_shadowed = 1; | ||
| 3220 | else | ||
| 3221 | continue; | ||
| 3222 | } | ||
| 3207 | } | 3223 | } |
| 3208 | 3224 | ||
| 3209 | tem = Flookup_key (map, kludge, Qt); | 3225 | tem = Flookup_key (map, kludge, Qt); |
| @@ -3223,6 +3239,13 @@ describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu) | |||
| 3223 | elt_describer will take care of spacing out far enough | 3239 | elt_describer will take care of spacing out far enough |
| 3224 | for alignment purposes. */ | 3240 | for alignment purposes. */ |
| 3225 | (*elt_describer) (definition, Qnil); | 3241 | (*elt_describer) (definition, Qnil); |
| 3242 | |||
| 3243 | if (this_shadowed) | ||
| 3244 | { | ||
| 3245 | SET_PT (PT - 1); | ||
| 3246 | insert_string (" (binding currently shadowed)"); | ||
| 3247 | SET_PT (PT + 1); | ||
| 3248 | } | ||
| 3226 | } | 3249 | } |
| 3227 | else if (EQ (XCAR (tail), Qkeymap)) | 3250 | else if (EQ (XCAR (tail), Qkeymap)) |
| 3228 | { | 3251 | { |
| @@ -3261,7 +3284,7 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3261 | specbind (Qstandard_output, Fcurrent_buffer ()); | 3284 | specbind (Qstandard_output, Fcurrent_buffer ()); |
| 3262 | CHECK_VECTOR_OR_CHAR_TABLE (vector); | 3285 | CHECK_VECTOR_OR_CHAR_TABLE (vector); |
| 3263 | describe_vector (vector, Qnil, describer, describe_vector_princ, 0, | 3286 | describe_vector (vector, Qnil, describer, describe_vector_princ, 0, |
| 3264 | Qnil, Qnil, (int *)0, 0, 0); | 3287 | Qnil, Qnil, (int *)0, 0, 0, 0); |
| 3265 | 3288 | ||
| 3266 | return unbind_to (count, Qnil); | 3289 | return unbind_to (count, Qnil); |
| 3267 | } | 3290 | } |
| @@ -3303,7 +3326,8 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3303 | static void | 3326 | static void |
| 3304 | describe_vector (vector, prefix, args, elt_describer, | 3327 | describe_vector (vector, prefix, args, elt_describer, |
| 3305 | partial, shadow, entire_map, | 3328 | partial, shadow, entire_map, |
| 3306 | indices, char_table_depth, keymap_p) | 3329 | indices, char_table_depth, keymap_p, |
| 3330 | mention_shadow) | ||
| 3307 | register Lisp_Object vector; | 3331 | register Lisp_Object vector; |
| 3308 | Lisp_Object prefix, args; | 3332 | Lisp_Object prefix, args; |
| 3309 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); | 3333 | void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); |
| @@ -3313,6 +3337,7 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3313 | int *indices; | 3337 | int *indices; |
| 3314 | int char_table_depth; | 3338 | int char_table_depth; |
| 3315 | int keymap_p; | 3339 | int keymap_p; |
| 3340 | int mention_shadow; | ||
| 3316 | { | 3341 | { |
| 3317 | Lisp_Object definition; | 3342 | Lisp_Object definition; |
| 3318 | Lisp_Object tem2; | 3343 | Lisp_Object tem2; |
| @@ -3396,6 +3421,7 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3396 | 3421 | ||
| 3397 | for (i = from; i < to; i++) | 3422 | for (i = from; i < to; i++) |
| 3398 | { | 3423 | { |
| 3424 | int this_shadowed = 0; | ||
| 3399 | QUIT; | 3425 | QUIT; |
| 3400 | 3426 | ||
| 3401 | if (CHAR_TABLE_P (vector)) | 3427 | if (CHAR_TABLE_P (vector)) |
| @@ -3455,7 +3481,13 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3455 | 3481 | ||
| 3456 | tem = shadow_lookup (shadow, kludge, Qt); | 3482 | tem = shadow_lookup (shadow, kludge, Qt); |
| 3457 | 3483 | ||
| 3458 | if (!NILP (tem)) continue; | 3484 | if (!NILP (tem)) |
| 3485 | { | ||
| 3486 | if (mention_shadow) | ||
| 3487 | this_shadowed = 1; | ||
| 3488 | else | ||
| 3489 | continue; | ||
| 3490 | } | ||
| 3459 | } | 3491 | } |
| 3460 | 3492 | ||
| 3461 | /* Ignore this definition if it is shadowed by an earlier | 3493 | /* Ignore this definition if it is shadowed by an earlier |
| @@ -3531,7 +3563,8 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3531 | insert ("\n", 1); | 3563 | insert ("\n", 1); |
| 3532 | describe_vector (definition, prefix, args, elt_describer, | 3564 | describe_vector (definition, prefix, args, elt_describer, |
| 3533 | partial, shadow, entire_map, | 3565 | partial, shadow, entire_map, |
| 3534 | indices, char_table_depth + 1, keymap_p); | 3566 | indices, char_table_depth + 1, keymap_p, |
| 3567 | mention_shadow); | ||
| 3535 | continue; | 3568 | continue; |
| 3536 | } | 3569 | } |
| 3537 | 3570 | ||
| @@ -3605,6 +3638,13 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3605 | elt_describer will take care of spacing out far enough | 3638 | elt_describer will take care of spacing out far enough |
| 3606 | for alignment purposes. */ | 3639 | for alignment purposes. */ |
| 3607 | (*elt_describer) (definition, args); | 3640 | (*elt_describer) (definition, args); |
| 3641 | |||
| 3642 | if (this_shadowed) | ||
| 3643 | { | ||
| 3644 | SET_PT (PT - 1); | ||
| 3645 | insert_string (" (binding currently shadowed)"); | ||
| 3646 | SET_PT (PT + 1); | ||
| 3647 | } | ||
| 3608 | } | 3648 | } |
| 3609 | 3649 | ||
| 3610 | /* For (sub) char-table, print `defalt' slot at last. */ | 3650 | /* For (sub) char-table, print `defalt' slot at last. */ |