Make registers and delete-selection-mode work on rectangles.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 8 Dec 2013 04:20:50 +0000 (23:20 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 8 Dec 2013 04:20:50 +0000 (23:20 -0500)
* lisp/register.el (describe-register-1): Don't modify the register's value.
(copy-to-register): Obey region-extract-function.
* lisp/delsel.el (delete-active-region): Obey region-extract-function.

lisp/ChangeLog
lisp/delsel.el
lisp/register.el

index c489bd3..fafeb95 100644 (file)
@@ -1,3 +1,10 @@
+2013-12-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       Make registers and delete-selection-mode work on rectangles.
+       * register.el (describe-register-1): Don't modify the register's value.
+       (copy-to-register): Obey region-extract-function.
+       * delsel.el (delete-active-region): Obey region-extract-function.
+
 2013-12-08  Leo Liu  <sdl.web@gmail.com>
 
        * progmodes/flymake.el (flymake, flymake-error-bitmap)
@@ -29,8 +36,7 @@
 
 2013-12-07  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * net/shr.el (shr-tag-img): Don't bug out on <img src="">
-       data.
+       * net/shr.el (shr-tag-img): Don't bug out on <img src=""> data.
 
 2013-12-06  Michael Albinus  <michael.albinus@gmx.de>
 
@@ -42,8 +48,8 @@
 
 2013-12-06  Dmitry Gutov  <dgutov@yandex.ru>
 
-       * progmodes/ruby-mode.el (ruby-syntax-propertize-function): Touch
-       up the last change.
+       * progmodes/ruby-mode.el (ruby-syntax-propertize-function):
+       Touch up the last change.
 
 2013-12-06  Leo Liu  <sdl.web@gmail.com>
 
@@ -73,8 +79,8 @@
 
 2013-12-06  Dmitry Gutov  <dgutov@yandex.ru>
 
-       * progmodes/octave.el (inferior-octave-completion-table): Turn
-       back into function, use `completion-table-with-cache'
+       * progmodes/octave.el (inferior-octave-completion-table):
+       Turn back into function, use `completion-table-with-cache'
        (Bug#11906).  Update all references.
 
        * minibuffer.el (completion-table-with-cache): New function.
index 07a7a37..3c9a656 100644 (file)
@@ -78,8 +78,8 @@ any selection."
   "Delete the active region.
 If KILLP in not-nil, the active region is killed instead of deleted."
   (if killp
-      (kill-region (point) (mark))
-    (delete-region (point) (mark)))
+      (kill-region (point) (mark) t)
+    (funcall region-extract-function 'delete-only))
   t)
 
 (defun delete-selection-helper (type)
@@ -197,9 +197,9 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
   (define-key minibuffer-local-completion-map "\C-g" 'abort-recursive-edit)
   (define-key minibuffer-local-must-match-map "\C-g" 'abort-recursive-edit)
   (define-key minibuffer-local-isearch-map "\C-g" 'abort-recursive-edit)
-  (dolist (sym '(self-insert-command self-insert-iso yank clipboard-yank
-                insert-register delete-backward-char backward-delete-char-untabify
-                delete-char newline-and-indent newline open-line))
+  (dolist (sym '(self-insert-command yank clipboard-yank
+                insert-register
+                 newline-and-indent newline open-line))
     (put sym 'delete-selection nil))
   ;; continue standard unloading
   nil)
index 2e22502..623b1f2 100644 (file)
@@ -364,6 +364,7 @@ The Lisp value REGISTER is a character."
        (princ (car val))))
 
      ((stringp val)
+      (setq val (copy-sequence val))
       (if (eq yank-excluded-properties t)
          (set-text-properties 0 (length val) nil val)
        (remove-list-of-text-properties 0 (length val)
@@ -417,19 +418,24 @@ Interactively, second arg is non-nil if prefix arg is supplied."
       (error "Register does not contain text"))))
   (if (not arg) (exchange-point-and-mark)))
 
-(defun copy-to-register (register start end &optional delete-flag)
+(defun copy-to-register (register start end &optional delete-flag region)
   "Copy region into register REGISTER.
 With prefix arg, delete as well.
 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
-START and END are buffer positions indicating what to copy."
+START and END are buffer positions indicating what to copy.
+The optional argument REGION if non-nil, indicates that we're not just copying
+some text between START and END, but we're copying the region."
   (interactive (list (register-read-with-preview "Copy to register: ")
                     (region-beginning)
                     (region-end)
-                    current-prefix-arg))
-  (set-register register (filter-buffer-substring start end))
+                    current-prefix-arg
+                    t))
+  (set-register register (if region
+                            (funcall region-extract-function delete-flag)
+                          (prog1 (filter-buffer-substring start end)
+                            (if delete-flag (delete-region start end)))))
   (setq deactivate-mark t)
-  (cond (delete-flag
-        (delete-region start end))
+  (cond (delete-flag)
        ((called-interactively-p 'interactive)
         (indicate-copied-region))))