From aea2f28eadadb7d48ffc6c597f5d0b3497c92096 Mon Sep 17 00:00:00 2001 From: John Foerch Date: Sat, 6 Feb 2010 11:04:37 -0500 Subject: [PATCH] sequence-abort: C-g can abort an ongoing key sequence --- modules/bindings/default/global.js | 4 ++++ modules/input.js | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/bindings/default/global.js b/modules/bindings/default/global.js index 02f3db8..a0ca7d8 100644 --- a/modules/bindings/default/global.js +++ b/modules/bindings/default/global.js @@ -29,6 +29,10 @@ define_keymap("sequence_help_keymap"); define_key(sequence_help_keymap, "C-h", "describe-active-bindings"); +define_keymap("sequence_abort_keymap"); +define_key(sequence_abort_keymap, "C-g", "sequence-abort"); + + /** * Note: Most buffer keymaps should set this as the parent. */ diff --git a/modules/input.js b/modules/input.js index a50a293..4c9b6a0 100644 --- a/modules/input.js +++ b/modules/input.js @@ -168,7 +168,7 @@ sequence: // make the combo string var combo = format_key_combo(clone); - I.key_sequence.push(combo); + var canabort = I.key_sequence.push(combo) > 1; I.combo = combo; I.event = clone; @@ -180,7 +180,9 @@ sequence: var overlay_keymap = I.overlay_keymap; - var binding = (overlay_keymap && keymap_lookup([overlay_keymap], combo, event)) || + var binding = + (canabort && keymap_lookup([sequence_abort_keymap], combo, event)) || + (overlay_keymap && keymap_lookup([overlay_keymap], combo, event)) || keymap_lookup(keymaps, combo, event) || keymap_lookup([sequence_help_keymap], combo, event); @@ -330,3 +332,8 @@ function input_initialize_window (window) { } add_hook("window_initialize_hook", input_initialize_window); + + +interactive("sequence-abort", + "Abort an ongoing key sequence.", + function (I) { I.minibuffer.message("abort sequence"); }); -- 2.11.4.GIT