From 85699737f1f7d1a006e3d7819c5f9d7aca3409d6 Mon Sep 17 00:00:00 2001 From: John Foerch Date: Sun, 23 May 2010 22:06:21 -0400 Subject: [PATCH] call_on_focused_field: support deactivating the mark causes the following commands to deactivate the mark: transpose-chars, insert-parentheses, open-line, paste-x-primary-selection. --- modules/commands.js | 8 ++++---- modules/text.js | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/commands.js b/modules/commands.js index 02a3d00..f64b88b 100644 --- a/modules/commands.js +++ b/modules/commands.js @@ -80,7 +80,7 @@ interactive("paste-x-primary-selection", "Insert the contents of the X primary selection into the selected field or "+ "minibuffer. Deactivates the region if it is active, and leaves the point "+ "after the inserted text.", - function (I) call_on_focused_field(I, paste_x_primary_selection)); + function (I) call_on_focused_field(I, paste_x_primary_selection, true)); function open_line (field) { @@ -89,7 +89,7 @@ function open_line (field) { interactive("open-line", "If there is an active region, replace is with a newline, otherwise just "+ "insert a newline. In both cases leave point before the inserted newline.", - function (I) call_on_focused_field(I, open_line)); + function (I) call_on_focused_field(I, open_line, true)); interactive("insert-parentheses", @@ -101,7 +101,7 @@ interactive("insert-parentheses", function (str) { return ["("+str+")", (str ? str.length+2 : 1)]; }); - }); + }, true); }); @@ -131,7 +131,7 @@ function transpose_chars (field) { } interactive("transpose-chars", "Interchange characters around point, moving forward one character.", - function (I) call_on_focused_field(I, transpose_chars)); + function (I) call_on_focused_field(I, transpose_chars, true)); interactive("execute-extended-command", diff --git a/modules/text.js b/modules/text.js index e4a63b4..fe0738e 100644 --- a/modules/text.js +++ b/modules/text.js @@ -16,7 +16,7 @@ in_module(null); * the field. See `paste_x_primary_selection' and `open_line' for * examples. */ -function call_on_focused_field (I, func) { +function call_on_focused_field (I, func, clear_mark) { var m = I.window.minibuffer; var s = m.current_state; if (m._input_mode_enabled) { @@ -25,6 +25,12 @@ function call_on_focused_field (I, func) { } else var e = I.buffer.focused_element; func(e); + if (clear_mark) { + if (m._input_mode_enabled) + s.mark_active = false; + else + I.buffer.mark_active = false; + } scroll_selection_into_view(e); if (s && s.handle_input) s.handle_input(m); -- 2.11.4.GIT