# HG changeset patch # User Aidan Kehoe # Date 1346873878 -3600 # Node ID 4af5a3435c94358798bcd2e56c51eaebbc5f36d2 # Parent 8a2ac78cb97d31a39208d1c6c5081477daac61eb Don't sanity-check commands with (define-key KEYMAP [remap COMMAND1] COMMAND2). lisp/ChangeLog addition: 2012-09-05 Aidan Kehoe * 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! diff -r 8a2ac78cb97d -r 4af5a3435c94 src/ChangeLog --- 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 + + * 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 * regex.c (re_search_2): diff -r 8a2ac78cb97d -r 4af5a3435c94 src/keymap.c --- 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) {