aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-24 19:10:32 +0200
committerLars Ingebrigtsen2019-06-24 19:12:41 +0200
commit35c72aea449a0e05849cff8d8ad4b9bde25cebb5 (patch)
tree40b4faf4f3deb50b919439442a70860c1a28d743
parent9f5f5ae6386fe1ea9f31bd760d7ffd293d274502 (diff)
downloademacs-35c72aea449a0e05849cff8d8ad4b9bde25cebb5.tar.gz
emacs-35c72aea449a0e05849cff8d8ad4b9bde25cebb5.zip
rectangle--pos-cols shouldn't move point
* lisp/rect.el (rectangle--pos-cols): Don't move point while calculating the values (bug#25777).
-rw-r--r--lisp/rect.el55
1 files changed, 28 insertions, 27 deletions
diff --git a/lisp/rect.el b/lisp/rect.el
index ecf6da13817..34f79e3ed3c 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -77,34 +77,35 @@ Point is at the end of the segment of this line within the rectangle."
77 ;; At this stage, we don't know which of start/end is point/mark :-( 77 ;; At this stage, we don't know which of start/end is point/mark :-(
78 ;; And in case start=end, it might still be that point and mark have 78 ;; And in case start=end, it might still be that point and mark have
79 ;; different crutches! 79 ;; different crutches!
80 (let ((cw (window-parameter window 'rectangle--point-crutches))) 80 (save-excursion
81 (cond 81 (let ((cw (window-parameter window 'rectangle--point-crutches)))
82 ((eq start (car cw)) 82 (cond
83 (let ((sc (cdr cw)) 83 ((eq start (car cw))
84 (ec (if (eq end (car rectangle--mark-crutches)) 84 (let ((sc (cdr cw))
85 (cdr rectangle--mark-crutches) 85 (ec (if (eq end (car rectangle--mark-crutches))
86 (if rectangle--mark-crutches 86 (cdr rectangle--mark-crutches)
87 (setq rectangle--mark-crutches nil)) 87 (if rectangle--mark-crutches
88 (goto-char end) (current-column)))) 88 (setq rectangle--mark-crutches nil))
89 (if (eq start end) (cons (min sc ec) (max sc ec)) (cons sc ec)))) 89 (goto-char end) (current-column))))
90 ((eq end (car cw)) 90 (if (eq start end) (cons (min sc ec) (max sc ec)) (cons sc ec))))
91 (if (eq start (car rectangle--mark-crutches)) 91 ((eq end (car cw))
92 (cons (cdr rectangle--mark-crutches) (cdr cw)) 92 (if (eq start (car rectangle--mark-crutches))
93 (cons (cdr rectangle--mark-crutches) (cdr cw))
94 (if rectangle--mark-crutches (setq rectangle--mark-crutches nil))
95 (cons (progn (goto-char start) (current-column)) (cdr cw))))
96 ((progn
97 (if cw (setf (window-parameter nil 'rectangle--point-crutches) nil))
98 (eq start (car rectangle--mark-crutches)))
99 (let ((sc (cdr rectangle--mark-crutches))
100 (ec (progn (goto-char end) (current-column))))
101 (if (eq start end) (cons (min sc ec) (max sc ec)) (cons sc ec))))
102 ((eq end (car rectangle--mark-crutches))
103 (cons (progn (goto-char start) (current-column))
104 (cdr rectangle--mark-crutches)))
105 (t
93 (if rectangle--mark-crutches (setq rectangle--mark-crutches nil)) 106 (if rectangle--mark-crutches (setq rectangle--mark-crutches nil))
94 (cons (progn (goto-char start) (current-column)) (cdr cw)))) 107 (cons (progn (goto-char start) (current-column))
95 ((progn 108 (progn (goto-char end) (current-column))))))))
96 (if cw (setf (window-parameter nil 'rectangle--point-crutches) nil))
97 (eq start (car rectangle--mark-crutches)))
98 (let ((sc (cdr rectangle--mark-crutches))
99 (ec (progn (goto-char end) (current-column))))
100 (if (eq start end) (cons (min sc ec) (max sc ec)) (cons sc ec))))
101 ((eq end (car rectangle--mark-crutches))
102 (cons (progn (goto-char start) (current-column))
103 (cdr rectangle--mark-crutches)))
104 (t
105 (if rectangle--mark-crutches (setq rectangle--mark-crutches nil))
106 (cons (progn (goto-char start) (current-column))
107 (progn (goto-char end) (current-column)))))))
108 109
109(defun rectangle--col-pos (col kind) 110(defun rectangle--col-pos (col kind)
110 (let ((c (move-to-column col))) 111 (let ((c (move-to-column col)))