Mercurial > emacs
changeset 108678:46728260f484
* src/keymap.c (Fwhere_is_internal): Fix handling of remapping (in thread
of bug#6305).
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 31 May 2010 15:35:04 -0400 |
parents | 7a38217041bb |
children | 490548bf16c1 |
files | src/ChangeLog src/keymap.c |
diffstat | 2 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon May 31 12:16:02 2010 -0400 +++ b/src/ChangeLog Mon May 31 15:35:04 2010 -0400 @@ -1,3 +1,8 @@ +2010-05-31 Stefan Monnier <monnier@iro.umontreal.ca> + + * keymap.c (Fwhere_is_internal): Fix handling of remapping (in thread + of bug#6305). + 2010-05-27 Chong Yidong <cyd@stupidchicken.com> * xdisp.c (redisplay_window): After redisplay, check if point is
--- a/src/keymap.c Mon May 31 12:16:02 2010 -0400 +++ b/src/keymap.c Mon May 31 15:35:04 2010 -0400 @@ -2829,16 +2829,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 +2852,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)