changeset 5681:4af5a3435c94

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!
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 05 Sep 2012 20:37:58 +0100
parents 8a2ac78cb97d
children dae33b5feffe
files src/ChangeLog src/keymap.c
diffstat 2 files changed, 41 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Sep 02 17:36:47 2012 +0100
+++ b/src/ChangeLog	Wed Sep 05 20:37:58 2012 +0100
@@ -1,3 +1,13 @@
+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):
--- a/src/keymap.c	Sun Sep 02 17:36:47 2012 +0100
+++ b/src/keymap.c	Wed Sep 05 20:37:58 2012 +0100
@@ -195,8 +195,9 @@
 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),
@@ -1939,12 +1940,6 @@
 
   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,
@@ -1958,6 +1953,13 @@
 
   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)
     {
@@ -2066,22 +2068,11 @@
     }
 }
 
-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);
@@ -2099,6 +2090,24 @@
   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)
 {