diff options
| author | Stefan Monnier | 2010-01-24 03:42:22 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2010-01-24 03:42:22 -0500 |
| commit | bd4b5750a0b44b065ff269db274d69d110777058 (patch) | |
| tree | 7bfe814a4df23efc2868ee96aea21e93d8ea96ff /src | |
| parent | c893016b07f33eb8d56e1011245fe59a67cb4ee0 (diff) | |
| download | emacs-bd4b5750a0b44b065ff269db274d69d110777058.tar.gz emacs-bd4b5750a0b44b065ff269db274d69d110777058.zip | |
* keymap.c (shadow_lookup): Add `remap' arg.
(describe_map, describe_vector): Update calls to shadow_lookup.
(Fwhere_is_internal): Fix up handling of `remapped_sequences' and
`remapped' so this flag is applicable to `sequence'. Be careful to
perform remapping during shadow_lookup check of remapped_equences.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/keymap.c | 43 |
2 files changed, 35 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5589b7f34a2..7a2f0dad1f3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-01-24 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * keymap.c (shadow_lookup): Add `remap' arg. | ||
| 4 | (describe_map, describe_vector): Update calls to shadow_lookup. | ||
| 5 | (Fwhere_is_internal): Fix up handling of `remapped_sequences' and | ||
| 6 | `remapped' so this flag is applicable to `sequence'. Be careful to | ||
| 7 | perform remapping during shadow_lookup check of remapped_equences. | ||
| 8 | |||
| 1 | 2010-01-22 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 9 | 2010-01-22 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | 10 | ||
| 3 | * lisp.h (make_pure_string): String pointer arg now points to const. | 11 | * lisp.h (make_pure_string): String pointer arg now points to const. |
diff --git a/src/keymap.c b/src/keymap.c index 17666c7efcc..98774d5d685 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2650,11 +2650,13 @@ static void where_is_internal_1 P_ ((Lisp_Object key, Lisp_Object binding, | |||
| 2650 | Lisp_Object args, void *data)); | 2650 | Lisp_Object args, void *data)); |
| 2651 | 2651 | ||
| 2652 | /* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map. | 2652 | /* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map. |
| 2653 | Returns the first non-nil binding found in any of those maps. */ | 2653 | Returns the first non-nil binding found in any of those maps. |
| 2654 | If REMAP is true, pass the result of the lookup through command | ||
| 2655 | remapping before returning it. */ | ||
| 2654 | 2656 | ||
| 2655 | static Lisp_Object | 2657 | static Lisp_Object |
| 2656 | shadow_lookup (shadow, key, flag) | 2658 | shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag, |
| 2657 | Lisp_Object shadow, key, flag; | 2659 | int remap) |
| 2658 | { | 2660 | { |
| 2659 | Lisp_Object tail, value; | 2661 | Lisp_Object tail, value; |
| 2660 | 2662 | ||
| @@ -2669,7 +2671,15 @@ shadow_lookup (shadow, key, flag) | |||
| 2669 | return Qnil; | 2671 | return Qnil; |
| 2670 | } | 2672 | } |
| 2671 | else if (!NILP (value)) | 2673 | else if (!NILP (value)) |
| 2672 | return value; | 2674 | { |
| 2675 | Lisp_Object remapping; | ||
| 2676 | if (remap && SYMBOLP (value) | ||
| 2677 | && (remapping = Fcommand_remapping (value, Qnil, shadow), | ||
| 2678 | !NILP (remapping))) | ||
| 2679 | return remapping; | ||
| 2680 | else | ||
| 2681 | return value; | ||
| 2682 | } | ||
| 2673 | } | 2683 | } |
| 2674 | return Qnil; | 2684 | return Qnil; |
| 2675 | } | 2685 | } |
| @@ -2860,30 +2870,30 @@ remapped command in the returned list. */) | |||
| 2860 | { | 2870 | { |
| 2861 | /* We have a list of advertized bindings. */ | 2871 | /* We have a list of advertized bindings. */ |
| 2862 | while (CONSP (tem)) | 2872 | while (CONSP (tem)) |
| 2863 | if (EQ (shadow_lookup (keymaps, XCAR (tem), Qnil), definition)) | 2873 | if (EQ (shadow_lookup (keymaps, XCAR (tem), Qnil, 0), definition)) |
| 2864 | return XCAR (tem); | 2874 | return XCAR (tem); |
| 2865 | else | 2875 | else |
| 2866 | tem = XCDR (tem); | 2876 | tem = XCDR (tem); |
| 2867 | if (EQ (shadow_lookup (keymaps, tem, Qnil), definition)) | 2877 | if (EQ (shadow_lookup (keymaps, tem, Qnil, 0), definition)) |
| 2868 | return tem; | 2878 | return tem; |
| 2869 | } | 2879 | } |
| 2870 | 2880 | ||
| 2871 | sequences = Freverse (where_is_internal (definition, keymaps, | 2881 | sequences = Freverse (where_is_internal (definition, keymaps, |
| 2872 | !NILP (noindirect), nomenus)); | 2882 | !NILP (noindirect), nomenus)); |
| 2873 | 2883 | ||
| 2874 | while (CONSP (sequences)) | 2884 | while (CONSP (sequences) |
| 2885 | /* If we're at the end of the `sequences' list and we haven't | ||
| 2886 | considered remapped sequences yet, copy them over and | ||
| 2887 | process them. */ | ||
| 2888 | || (!remapped && (sequences = remapped_sequences, | ||
| 2889 | remapped = 1), | ||
| 2890 | CONSP (sequences))) | ||
| 2875 | { | 2891 | { |
| 2876 | Lisp_Object sequence, function; | 2892 | Lisp_Object sequence, function; |
| 2877 | 2893 | ||
| 2878 | sequence = XCAR (sequences); | 2894 | sequence = XCAR (sequences); |
| 2879 | sequences = XCDR (sequences); | 2895 | sequences = XCDR (sequences); |
| 2880 | 2896 | ||
| 2881 | if (NILP (sequences) && !remapped) | ||
| 2882 | { | ||
| 2883 | sequences = remapped_sequences; | ||
| 2884 | remapped = 1; | ||
| 2885 | } | ||
| 2886 | |||
| 2887 | /* Verify that this key binding is not shadowed by another | 2897 | /* Verify that this key binding is not shadowed by another |
| 2888 | binding for the same key, before we say it exists. | 2898 | binding for the same key, before we say it exists. |
| 2889 | 2899 | ||
| @@ -2893,7 +2903,8 @@ remapped command in the returned list. */) | |||
| 2893 | 2903 | ||
| 2894 | Either nil or number as value from Flookup_key | 2904 | Either nil or number as value from Flookup_key |
| 2895 | means undefined. */ | 2905 | means undefined. */ |
| 2896 | if (!EQ (shadow_lookup (keymaps, sequence, Qnil), definition)) | 2906 | if (!EQ (shadow_lookup (keymaps, sequence, Qnil, remapped), |
| 2907 | definition)) | ||
| 2897 | continue; | 2908 | continue; |
| 2898 | 2909 | ||
| 2899 | /* If the current sequence is a command remapping with | 2910 | /* If the current sequence is a command remapping with |
| @@ -3506,7 +3517,7 @@ describe_map (map, prefix, elt_describer, partial, shadow, | |||
| 3506 | ASET (kludge, 0, event); | 3517 | ASET (kludge, 0, event); |
| 3507 | if (!NILP (shadow)) | 3518 | if (!NILP (shadow)) |
| 3508 | { | 3519 | { |
| 3509 | tem = shadow_lookup (shadow, kludge, Qt); | 3520 | tem = shadow_lookup (shadow, kludge, Qt, 0); |
| 3510 | if (!NILP (tem)) | 3521 | if (!NILP (tem)) |
| 3511 | { | 3522 | { |
| 3512 | /* If both bindings are keymaps, this key is a prefix key, | 3523 | /* If both bindings are keymaps, this key is a prefix key, |
| @@ -3776,7 +3787,7 @@ describe_vector (vector, prefix, args, elt_describer, | |||
| 3776 | { | 3787 | { |
| 3777 | Lisp_Object tem; | 3788 | Lisp_Object tem; |
| 3778 | 3789 | ||
| 3779 | tem = shadow_lookup (shadow, kludge, Qt); | 3790 | tem = shadow_lookup (shadow, kludge, Qt, 0); |
| 3780 | 3791 | ||
| 3781 | if (!NILP (tem)) | 3792 | if (!NILP (tem)) |
| 3782 | { | 3793 | { |