Commits

Aidan Kehoe committed 7371081

Have command remapping work interactively too, thank you Robert Pluim!

src/ChangeLog addition:

2012-10-14 Aidan Kehoe <kehoea@parhasard.net>

Have command remapping work interactively too, thank you Robert
Pluim.
* event-stream.c (Fdispatch_event):
Obey command remapping here, it wasn't done for us.
* keymap.c:
* keymap.c (command_remapping_for_event): New, needed to observe
command remapping interactively.
* lisp.h: Make it available.

lisp/ChangeLog addition:

2012-10-14 Aidan Kehoe <kehoea@parhasard.net>

* help.el:
* help.el (describe-function-1):
Add some newlines here when dealing with remapped commands, thank
you Robert Pluim.

Comments (0)

Files changed (6)

+2012-10-14  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* help.el:
+	* help.el (describe-function-1):
+	Add some newlines here when dealing with remapped commands, thank
+	you Robert Pluim.
+
 2012-10-13  Mats Lidell  <matsl@xemacs.org>
 
 	* process.el (call-process-shell-command): New function from GNU.
                                    (format "\n\\[%s]" function))))
                        (when commands-remapped-to
                          (if (cdr commands-remapped-to)
-                             (princ (format "The following functions are \
+                             (princ (format "\n\nThe following functions are \
 remapped to it:\n`%s'" (mapconcat #'prin1-to-string commands-remapped-to
                                   "', `")))
-                           (princ (format "`%s' is remapped to it.\n"
+                           (princ (format "\n\n`%s' is remapped to it.\n"
                                           (car
                                            commands-remapped-to))))))))))))))
 
+2012-10-14  Aidan Kehoe  <kehoea@parhasard.net>
+
+	Have command remapping work interactively too, thank you Robert
+	Pluim.
+	* event-stream.c (Fdispatch_event):
+	Obey command remapping here, it wasn't done for us.
+	* keymap.c:
+	* keymap.c (command_remapping_for_event): New, needed to observe
+	command remapping interactively.
+	* lisp.h: Make it available.
+
 2012-10-14  Aidan Kehoe  <kehoea@parhasard.net>
 
 	Respect face and display table information in the minibuffer

src/event-stream.c

 	    int magic_undo = 0;
 	    Elemcount magic_undo_count = 20;
 
-	    Vthis_command = leaf;
-
 	    /* Don't push an undo boundary if the command set the prefix arg,
 	       or if we are executing a keyboard macro, or if in the
 	       minibuffer.  If the command we are about to execute is
 	    if (SYMBOLP (leaf))
 	      {
 		Lisp_Object prop = Fget (leaf, Qself_insert_defer_undo, Qnil);
+                Lisp_Object remap = Qnil;
+
 		if (NATNUMP (prop))
                   {
                     magic_undo = 1;
 		  magic_undo = 1;
 		else if (EQ (leaf, Qself_insert_command))
 		  magic_undo = 1;
+
+                remap = command_remapping_for_event (leaf, event);
+                if (!NILP (remap))
+                  {
+                    leaf = remap;
+                  }
 	      }
 
+	    Vthis_command = leaf;
+
 	    if (!magic_undo)
 	      command_builder->self_insert_countdown = 0;
 	    if (NILP (XCONSOLE (console)->prefix_arg)
   return Qnil;
 }
 
+Lisp_Object
+command_remapping_for_event (Lisp_Object command, Lisp_Object event0)
+{
+  /* This function can GC */
+  Lisp_Object maps[100];
+  int nmaps;
+
+  nmaps = get_relevant_keymaps (event0, Qnil, countof (maps), maps);
+  if (nmaps > countof (maps))
+    nmaps = countof (maps);
+
+  return command_remapping (command, nmaps, maps);
+}                             
+
 DEFUN ("command-remapping", Fcommand_remapping, 1, 3, 0, /*
 Return the remapping for command COMMAND.
 
 EXFUN (Fmake_sparse_keymap, 1);
 EXFUN (Fset_keymap_parents, 2);
 
+Lisp_Object command_remapping_for_event (Lisp_Object command,
+                                         Lisp_Object event0);
+
 void where_is_to_char (Lisp_Object, Eistring *);
 
 /* Defined in lread.c */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.