From df1bbe5b135a64bf547bb298b88c82065ef2790a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 3 Oct 2011 16:50:54 -0400 Subject: [PATCH] * src/keyboard.c (read_key_sequence_remapped): New var. (read_key_sequence): Compute remapping in the right buffer. (command_loop_1): Use read_key_sequence's remapping directly. --- src/ChangeLog | 6 ++++++ src/keyboard.c | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bc9ffc8f3fe..b697ee43376 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-10-03 Stefan Monnier + + * keyboard.c (read_key_sequence_remapped): New var. + (read_key_sequence): Compute remapping in the right buffer. + (command_loop_1): Use read_key_sequence's remapping directly. + 2011-10-02 Stefan Monnier * dired.c (file_name_completion): Don't expand file name. diff --git a/src/keyboard.c b/src/keyboard.c index 26407785c86..6f3bfd8c1e7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -252,6 +252,7 @@ static Lisp_Object Qtimer_event_handler; /* read_key_sequence stores here the command definition of the key sequence that it reads. */ static Lisp_Object read_key_sequence_cmd; +static Lisp_Object read_key_sequence_remapped; static Lisp_Object Qinput_method_function; @@ -1514,14 +1515,10 @@ command_loop_1 (void) reset it before we execute the command. */ Vdeactivate_mark = Qnil; - /* Remap command through active keymaps */ + /* Remap command through active keymaps. */ Vthis_original_command = cmd; - if (SYMBOLP (cmd)) - { - Lisp_Object cmd1; - if (cmd1 = Fcommand_remapping (cmd, Qnil, Qnil), !NILP (cmd1)) - cmd = cmd1; - } + if (!NILP (read_key_sequence_remapped)) + cmd = read_key_sequence_remapped; /* Execute the command. */ @@ -9999,6 +9996,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, read_key_sequence_cmd = (first_binding < nmaps ? defs[first_binding] : Qnil); + read_key_sequence_remapped + /* Remap command through active keymaps. + Do the remapping here, before the unbind_to so it uses the keymaps + of the appropriate buffer. */ + = SYMBOLP (read_key_sequence_cmd) + ? Fcommand_remapping (read_key_sequence_cmd, Qnil, Qnil) + : Qnil; unread_switch_frame = delayed_switch_frame; unbind_to (count, Qnil); @@ -11663,6 +11667,8 @@ syms_of_keyboard (void) read_key_sequence_cmd = Qnil; staticpro (&read_key_sequence_cmd); + read_key_sequence_remapped = Qnil; + staticpro (&read_key_sequence_remapped); menu_bar_one_keymap_changed_items = Qnil; staticpro (&menu_bar_one_keymap_changed_items); -- 2.11.4.GIT