From 7818df11b85d4829b61f6d967aa421621985b18a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 11 Nov 2013 00:18:53 -0500 Subject: [PATCH] * lisp/bindings.el (ctl-x-map): Bind C-x SPC to rectangle-mark-mode. * src/keyboard.c (command_loop_1): Use region-extract-function. * src/insdel.c (Qregion_extract_function): Not static any more (can we stop pretending that these vars can benefit from being marked static?). --- etc/NEWS | 2 +- lisp/ChangeLog | 4 ++++ lisp/bindings.el | 1 + lisp/rect.el | 4 +--- src/ChangeLog | 6 ++++++ src/insdel.c | 2 +- src/keyboard.c | 17 +++++++---------- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5fa56401641..3198c0d28cc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -189,7 +189,7 @@ Czech typography rules. To globally enable this feature, evaluate: * Editing Changes in Emacs 24.4 -** New command `rectangle-mark' makes a rectangular region. +** Command `rectangle-mark-mode' bound to C-x SPC makes a rectangular region. Most commands are still unaware of it, but kill/yank do work on the rectangle. ** C-x TAB enters a transient interactive mode. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a9eacb56383..1e1992fae2a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2013-11-11 Stefan Monnier + + * bindings.el (ctl-x-map): Bind C-x SPC to rectangle-mark-mode. + 2013-11-11 Nathan Trapuzzano (tiny change) * emacs-lisp/cconv.el (cconv-convert): Print warning instead of diff --git a/lisp/bindings.el b/lisp/bindings.el index 2ea6713216d..b3b4f76b555 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -891,6 +891,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key ctl-x-map "\C-x" 'exchange-point-and-mark) (define-key ctl-x-map "\C-@" 'pop-global-mark) +(define-key ctl-x-map " " 'rectangle-mark-mode) (define-key ctl-x-map [?\C- ] 'pop-global-mark) (define-key global-map "\C-n" 'next-line) diff --git a/lisp/rect.el b/lisp/rect.el index 4335bb25409..ad94663fc96 100644 --- a/lisp/rect.el +++ b/lisp/rect.el @@ -414,9 +414,7 @@ with a prefix argument, prompt for START-AT and FORMAT." ;;; New rectangle integration with kill-ring. -;; FIXME: lots of known problems with the new rectangle support: -;; - no key binding for mark-rectangle. -;; - no access to the `string-rectangle' functionality. +;; FIXME: known problems with the new rectangle support: ;; - lots of commands handle the region without paying attention to its ;; rectangular shape. diff --git a/src/ChangeLog b/src/ChangeLog index 9a485533266..cc20b68c729 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-11-11 Stefan Monnier + + * keyboard.c (command_loop_1): Use region-extract-function. + * insdel.c (Qregion_extract_function): Not static any more (can we + stop pretending that these vars can benefit from being marked static?). + 2013-11-09 Eli Zaretskii * search.c (find_newline): If buffer text is relocated during the diff --git a/src/insdel.c b/src/insdel.c index 4b8ab19fe24..5515b641d66 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -1778,7 +1778,7 @@ modify_text (ptrdiff_t start, ptrdiff_t end) bset_point_before_scroll (current_buffer, Qnil); } -static Lisp_Object Qregion_extract_function; +Lisp_Object Qregion_extract_function; /* Check that it is okay to modify the buffer between START and END, which are char positions. diff --git a/src/keyboard.c b/src/keyboard.c index a066900fc91..0fcea387aea 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1321,6 +1321,8 @@ static void adjust_point_for_property (ptrdiff_t, bool); /* The last boundary auto-added to buffer-undo-list. */ Lisp_Object last_undo_boundary; +extern Lisp_Object Qregion_extract_function; + /* FIXME: This is wrong rather than test window-system, we should call a new set-selection, which will then dispatch to x-set-selection, or tty-set-selection, or w32-set-selection, ... */ @@ -1629,16 +1631,11 @@ command_loop_1 (void) && NILP (Fmemq (Vthis_command, Vselection_inhibit_update_commands))) { - ptrdiff_t beg - = XINT (Fmarker_position (BVAR (current_buffer, mark))); - ptrdiff_t end = PT; - if (beg < end) - call2 (Qx_set_selection, QPRIMARY, - make_buffer_string (beg, end, 0)); - else if (beg > end) - call2 (Qx_set_selection, QPRIMARY, - make_buffer_string (end, beg, 0)); - /* Don't set empty selections. */ + Lisp_Object txt + = call1 (Fsymbol_value (Qregion_extract_function), Qnil); + if (XINT (Flength (txt)) > 0) + /* Don't set empty selections. */ + call2 (Qx_set_selection, QPRIMARY, txt); } if (current_buffer != prev_buffer || MODIFF != prev_modiff) -- 2.39.2