summaryrefslogtreecommitdiff
path: root/lisp/rect.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/rect.el')
-rw-r--r--lisp/rect.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/rect.el b/lisp/rect.el
index 70a542d6724..f9bebc47fef 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -108,7 +108,7 @@ Point is at the end of the segment of this line within the rectangle."
(defun rectangle--col-pos (col kind)
(let ((c (move-to-column col)))
- (if (= c col)
+ (if (and (= c col) (not (eolp)))
(if (eq kind 'point)
(if (window-parameter nil 'rectangle--point-crutches)
(setf (window-parameter nil 'rectangle--point-crutches) nil))
@@ -473,10 +473,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)))