emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r99825: * src/keymap.c (Fwhere_is_


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r99825: * src/keymap.c (Fwhere_is_internal): Fix handling of remapping (in thread
Date: Mon, 31 May 2010 15:35:04 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99825
committer: Stefan Monnier <address@hidden>
branch nick: emacs-23
timestamp: Mon 2010-05-31 15:35:04 -0400
message:
  * src/keymap.c (Fwhere_is_internal): Fix handling of remapping (in thread
  of bug#6305).
modified:
  src/ChangeLog
  src/keymap.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-05-30 23:09:32 +0000
+++ b/src/ChangeLog     2010-05-31 19:35:04 +0000
@@ -1,3 +1,8 @@
+2010-05-31  Stefan Monnier  <address@hidden>
+
+       * keymap.c (Fwhere_is_internal): Fix handling of remapping (in thread
+       of bug#6305).
+
 2010-05-27  Chong Yidong  <address@hidden>
 
        * xdisp.c (redisplay_window): After redisplay, check if point is

=== modified file 'src/keymap.c'
--- a/src/keymap.c      2010-03-03 17:31:50 +0000
+++ b/src/keymap.c      2010-05-31 19:35:04 +0000
@@ -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);
+  GCPRO6 (definition, keymaps, found, sequences, remapped_sequences, tem);
 
-  /* 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);
+  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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]