unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point
@ 2017-02-17 17:51 Drew Adams
  2017-02-19 17:38 ` Drew Adams
  0 siblings, 1 reply; 22+ messages in thread
From: Drew Adams @ 2017-02-17 17:51 UTC (permalink / raw)
  To: 25777

The code defining `rectangle--pos-cols' mistakenly moves point.  All of
the calls to `goto-char' in this function need to be wrapped in
`save-excursion'.  Below is a patch that does this.

(This bug causes a regression from the correct behavior in Emacs 24.5,
BTW.)

I think that most, if not all, of the other uses of `goto-char' in
rect.el also need to be wrapped with `save-excursion'.  But as I am not
sure of this, I leave it to someone else to take a close look and DTRT.

-------------------------

diff -u rect.el rect-2017-02-17-patched.el
--- rect.el	2017-02-17 09:37:56.938748300 -0800
+++ rect-2017-02-17-patched.el	2017-02-17 09:43:13.884439700 -0800
@@ -85,26 +85,26 @@
                     (cdr rectangle--mark-crutches)
                   (if rectangle--mark-crutches
                       (setq rectangle--mark-crutches nil))
-                  (goto-char end) (current-column))))
+                  (save-excursion (goto-char end) (current-column)))))
         (if (eq start end) (cons (min sc ec) (max sc ec)) (cons sc ec))))
      ((eq end (car cw))
       (if (eq start (car rectangle--mark-crutches))
           (cons (cdr rectangle--mark-crutches) (cdr cw))
         (if rectangle--mark-crutches (setq rectangle--mark-crutches nil))
-        (cons (progn (goto-char start) (current-column)) (cdr cw))))
+        (cons (save-excursion (goto-char start) (current-column)) (cdr cw))))
      ((progn
         (if cw (setf (window-parameter nil 'rectangle--point-crutches) nil))
         (eq start (car rectangle--mark-crutches)))
       (let ((sc (cdr rectangle--mark-crutches))
-            (ec (progn (goto-char end) (current-column))))
+            (ec (save-excursion (goto-char end) (current-column))))
         (if (eq start end) (cons (min sc ec) (max sc ec)) (cons sc ec))))
      ((eq end (car rectangle--mark-crutches))
-      (cons (progn (goto-char start) (current-column))
+      (cons (save-excursion (goto-char start) (current-column))
             (cdr rectangle--mark-crutches)))
      (t
       (if rectangle--mark-crutches (setq rectangle--mark-crutches nil))
-      (cons (progn (goto-char start) (current-column))
-            (progn (goto-char end) (current-column)))))))
+      (cons (save-excursion (goto-char start) (current-column))
+            (save-excursion (goto-char end) (current-column)))))))
 
 (defun rectangle--col-pos (col kind)
   (let ((c (move-to-column col)))

---------------------


In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-11-15
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''





^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-06-24 17:10 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17 17:51 bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point Drew Adams
2017-02-19 17:38 ` Drew Adams
2017-02-27  1:37   ` npostavs
2017-02-27  6:24     ` Drew Adams
2017-02-27 13:44       ` npostavs
2017-02-27 17:51         ` Drew Adams
2017-02-27 18:50           ` Noam Postavsky
2017-02-27 19:21             ` Drew Adams
2017-02-27 19:47               ` Noam Postavsky
2017-02-27 20:35                 ` Drew Adams
2017-02-28  4:57           ` npostavs
2017-02-28 15:11             ` Drew Adams
2017-03-02  1:21               ` npostavs
2017-03-02  2:32                 ` Drew Adams
2017-03-02 18:13                   ` Drew Adams
2017-03-03  2:09                     ` npostavs
2017-03-03  6:29                       ` Drew Adams
2017-03-03 13:28                         ` npostavs
2017-03-03 16:44                           ` Drew Adams
2017-03-03 18:16                             ` Noam Postavsky
2017-03-03 19:17                               ` Drew Adams
2019-06-24 17:10             ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).