Mercurial > emacs
diff src/keymap.c @ 110091:66a2fac996a4
merge emacs-23
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 27 Aug 2010 23:05:43 +0900 |
parents | d657dd1ad387 |
children | 60516122d066 376148b31b5e |
line wrap: on
line diff
--- a/src/keymap.c Sat Apr 03 19:40:20 2010 -0400 +++ b/src/keymap.c Fri Aug 27 23:05:43 2010 +0900 @@ -1175,11 +1175,13 @@ doc: /* In KEYMAP, define key sequence KEY as DEF. KEYMAP is a keymap. -KEY is a string or a vector of symbols and characters meaning a +KEY is a string or a vector of symbols and characters, representing a sequence of keystrokes and events. Non-ASCII characters with codes -above 127 (such as ISO Latin-1) can be included if you use a vector. -Using [t] for KEY creates a default definition, which applies to any -event type that has no other definition in this keymap. +above 127 (such as ISO Latin-1) can be represented by vectors. +Two types of vector have special meanings: + [remap COMMAND] remaps any key binding for COMMAND in KEYMAP. + [t] creates a default definition, which applies to any event with no + other definition in KEYMAP. DEF is anything that can be a key's definition: nil (means key is undefined in this keymap), @@ -2829,16 +2831,16 @@ Lisp_Object found = Qnil; /* 1 means ignore all menu bindings entirely. */ int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); - struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; /* List of sequences found via remapping. Keep them in a separate variable, so as to push them later, since we prefer non-remapped binding. */ Lisp_Object remapped_sequences = Qnil; /* Whether or not we're handling remapped sequences. This is needed because remapping is not done recursively by Fcommand_remapping: you - can't remap and remapped command. */ + can't remap a remapped command. */ int remapped = 0; - Lisp_Object tem; + Lisp_Object tem = Qnil; /* Refresh the C version of the modifier preference. */ where_is_preferred_modifier @@ -2852,17 +2854,25 @@ else keymaps = Fcurrent_active_maps (Qnil, Qnil); - GCPRO5 (definition, keymaps, found, sequences, remapped_sequences); - - /* If this command is remapped, then it has no key bindings of its own. - FIXME: Actually, this is not quite right: if A is remapped to - `definition', then bindings to A will actually bind the key to - `definition' despite the remapping from `definition' to something else. - Another corner case is if `definition' is remapped to itself. */ - if (NILP (no_remap) - && SYMBOLP (definition) - && !NILP (Fcommand_remapping (definition, Qnil, keymaps))) - RETURN_UNGCPRO (Qnil); + GCPRO6 (definition, keymaps, found, sequences, remapped_sequences, tem); + + tem = Fcommand_remapping (definition, Qnil, keymaps); + /* If `definition' is remapped to tem', then OT1H no key will run + that command (since they will run `tem' instead), so we should + return nil; but OTOH all keys bound to `definition' (or to `tem') + will run the same command. + So for menu-shortcut purposes, we want to find all the keys bound (maybe + via remapping) to `tem'. But for the purpose of finding the keys that + run `definition', then we'd want to just return nil. + We choose to make it work right for menu-shortcuts, since it's the most + common use. + Known bugs: if you remap switch-to-buffer to toto, C-h f switch-to-buffer + will tell you that switch-to-buffer is bound to C-x b even though C-x b + will run toto instead. And if `toto' is itself remapped to forward-char, + then C-h f toto will tell you that it's bound to C-f even though C-f does + not run toto and it won't tell you that C-x b does run toto. */ + if (NILP (no_remap) && !NILP (tem)) + definition = tem; if (SYMBOLP (definition) && !NILP (firstonly)