all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 25777@debbugs.gnu.org
Subject: bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point
Date: Fri, 17 Feb 2017 09:51:01 -0800 (PST)	[thread overview]
Message-ID: <1efbacdb-7d86-454d-b0e0-7a783c47b804@default> (raw)

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''





             reply	other threads:[~2017-02-17 17:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 17:51 Drew Adams [this message]
2017-02-19 17:38 ` bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1efbacdb-7d86-454d-b0e0-7a783c47b804@default \
    --to=drew.adams@oracle.com \
    --cc=25777@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.