Mercurial > emacs
comparison src/keymap.c @ 106972:d026329addd9
* 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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 24 Jan 2010 03:42:22 -0500 |
parents | 1d1d5d9bd884 |
children | e09a216f2aab |
comparison
equal
deleted
inserted
replaced
106953:a1e356d208cd | 106972:d026329addd9 |
---|---|
2648 | 2648 |
2649 static void where_is_internal_1 P_ ((Lisp_Object key, Lisp_Object binding, | 2649 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 |
2661 for (tail = shadow; CONSP (tail); tail = XCDR (tail)) | 2663 for (tail = shadow; CONSP (tail); tail = XCDR (tail)) |
2662 { | 2664 { |
2667 Fsubstring (key, make_number (0), value), flag); | 2669 Fsubstring (key, make_number (0), value), flag); |
2668 if (!NILP (value)) | 2670 if (!NILP (value)) |
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 } |
2676 | 2686 |
2677 static Lisp_Object Vmouse_events; | 2687 static Lisp_Object Vmouse_events; |
2858 && !NILP (firstonly) | 2868 && !NILP (firstonly) |
2859 && !NILP (tem = Fget (definition, QCadvertised_binding))) | 2869 && !NILP (tem = Fget (definition, QCadvertised_binding))) |
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 |
2890 Mechanism: look for local definition of this key and if | 2900 Mechanism: look for local definition of this key and if |
2891 it is defined and does not match what we found then | 2901 it is defined and does not match what we found then |
2892 ignore this key. | 2902 ignore this key. |
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 |
2900 format [remap COMMAND], find the key sequences | 2911 format [remap COMMAND], find the key sequences |
2901 which run COMMAND, and use those sequences instead. */ | 2912 which run COMMAND, and use those sequences instead. */ |
3504 because a local definition of the same key shadows it. */ | 3515 because a local definition of the same key shadows it. */ |
3505 | 3516 |
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, |
3513 so don't say it is shadowed. */ | 3524 so don't say it is shadowed. */ |
3514 if (KEYMAPP (definition) && KEYMAPP (tem)) | 3525 if (KEYMAPP (definition) && KEYMAPP (tem)) |
3774 /* If this binding is shadowed by some other map, ignore it. */ | 3785 /* If this binding is shadowed by some other map, ignore it. */ |
3775 if (!NILP (shadow)) | 3786 if (!NILP (shadow)) |
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 { |
3783 if (mention_shadow) | 3794 if (mention_shadow) |
3784 this_shadowed = 1; | 3795 this_shadowed = 1; |