Commits

Aidan Kehoe committed 4af5a34

Don't sanity-check commands with (define-key KEYMAP [remap COMMAND1] COMMAND2).

lisp/ChangeLog addition:

2012-09-05 Aidan Kehoe <kehoea@parhasard.net>

* keymap.c:
* keymap.c (Fdefine_key):
* keymap.c (remap_command):
* keymap.c (Fremap_command):
Don't sanity-check commands to be remapped with the (define-key
KEYMAP [remap COMMAND1] COMMAND2) syntax, for better compatibility
with GNU Emacs. Thank you Robert Pluim!

Comments (0)

Files changed (2)

+2012-09-05  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* keymap.c:
+	* keymap.c (Fdefine_key):
+	* keymap.c (remap_command):
+	* keymap.c (Fremap_command):
+	Don't sanity-check commands to be remapped with the (define-key
+	KEYMAP [remap COMMAND1] COMMAND2) syntax, for better compatibility
+	with GNU Emacs. Thank you Robert Pluim!
+
 2012-09-02  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* regex.c (re_search_2):
 EXFUN (Fkeymap_fullness, 1);
 EXFUN (Fset_keymap_name, 2);
 EXFUN (Fsingle_key_description, 1);
-EXFUN (Fremap_command, 3);
-
+
+static Lisp_Object remap_command (Lisp_Object keymap, Lisp_Object old,
+                                  Lisp_Object new_);
 static void describe_command (Lisp_Object definition, Lisp_Object buffer);
 static void describe_map (Lisp_Object keymap, Lisp_Object elt_prefix,
 			  void (*elt_describer) (Lisp_Object, Lisp_Object),
 
   GCPRO3 (keymap, keys, def);
 
-  /* Allow access to any keys named remap, use our uninterned symbol. */
-  if (2 == len && VECTORP (keys) && EQ (Qremap, XVECTOR_DATA (keys) [0]))
-    {
-      return Fremap_command (keymap, XVECTOR_DATA (keys) [1], def);
-    }
-
   /* ASCII grunge.
      When the user defines a key which, in a strictly ASCII world, would be
      produced by two different keys (^J and linefeed, or ^H and backspace,
 
   keymap = get_keymap (keymap, 1, 1);
 
+  /* Allow access to any keys named remap, use our uninterned symbol. For
+     compatibility, don't sanity-check (aref KEYS 1) or DEF. */
+  if (2 == len && VECTORP (keys) && EQ (Qremap, XVECTOR_DATA (keys) [0]))
+    {
+      RETURN_UNGCPRO (remap_command (keymap, XVECTOR_DATA (keys) [1], def));
+    }
+
   idx = 0;
   while (1)
     {
     }
 }
 
-DEFUN ("remap-command", Fremap_command, 3, 3, 0, /*
-Ensure that NEW is called when previously OLD would be, in KEYMAP.
-
-NEW and OLD are both command symbols.  KEYMAP is a keymap object.
-
-This is equivalent to `(define-key KEYMAP [remap OLD] NEW])'.  See also
-`substitute-key-definition', an older way of doing a similar thing.
-*/
-       (keymap, old, new_))
+static Lisp_Object
+remap_command (Lisp_Object keymap, Lisp_Object old, Lisp_Object new_)
 {
+  Lisp_Key_Data parsed;
   Lisp_Object cmd;
-  Lisp_Key_Data parsed;
-
-  keymap = get_keymap (keymap, 1, 1);
-  CHECK_COMMAND (old);
-  CHECK_COMMAND (new_);
 
   define_key_parser (Qxemacs_command_remapping, &parsed);
   cmd = keymap_lookup_1 (keymap, &parsed, 0);
   return new_;
 }
 
+
+DEFUN ("remap-command", Fremap_command, 3, 3, 0, /*
+Ensure that NEW is called when previously OLD would be, in KEYMAP.
+
+NEW and OLD are both command symbols.  KEYMAP is a keymap object.
+
+This is equivalent to `(define-key KEYMAP [remap OLD] NEW])'.  See also
+`substitute-key-definition', an older way of doing a similar thing.
+*/
+       (keymap, old, new_))
+{
+  keymap = get_keymap (keymap, 1, 1);
+  CHECK_COMMAND (old);
+  CHECK_COMMAND (new_);
+
+  return remap_command (keymap, old, new_);
+}
+
 static Lisp_Object
 command_remapping (Lisp_Object definition, int nmaps, Lisp_Object *maps)
 {