]> code.delx.au - gnu-emacs/commitdiff
Make `undo' of `C-x r t' put point where it should be
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2016 23:15:16 +0000 (01:15 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2016 23:15:16 +0000 (01:15 +0200)
* lisp/rect.el (string-rectangle): Make `undo' of a this
command put point back where it was (bug#7522).

lisp/rect.el

index 6056b14734d021296d8aab19d8c2f7078b8cfd35..07e0f6fc14bec2645ab55bcf681614177d99f8b6 100644 (file)
@@ -476,10 +476,15 @@ Called from a program, takes three args; START, END and STRING."
                              #'rectangle--string-erase-preview nil t)
                    (add-hook 'post-command-hook
                              #'rectangle--string-preview nil t))
-          (read-string (format "String rectangle (default %s): "
-                               (or (car string-rectangle-history) ""))
-                       nil 'string-rectangle-history
+               (read-string (format "String rectangle (default %s): "
+                                    (or (car string-rectangle-history) ""))
+                            nil 'string-rectangle-history
                             (car string-rectangle-history)))))))
+  ;; If we undo this change, we want to have the point back where we
+  ;; are now, and not after the first line in the rectangle (which is
+  ;; the first line to be changed by the following command).
+  (unless (eq buffer-undo-list t)
+    (push (point) buffer-undo-list))
   (goto-char
    (apply-on-rectangle 'string-rectangle-line start end string t)))