From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point Date: Fri, 17 Feb 2017 09:51:01 -0800 (PST) Message-ID: <1efbacdb-7d86-454d-b0e0-7a783c47b804@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1487353933 8051 195.159.176.226 (17 Feb 2017 17:52:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Feb 2017 17:52:13 +0000 (UTC) To: 25777@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 17 18:52:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cemhS-0001SA-8g for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Feb 2017 18:52:06 +0100 Original-Received: from localhost ([::1]:55081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cemhY-0001ku-56 for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Feb 2017 12:52:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cemhS-0001kL-4h for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:52:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cemhO-0000BW-7o for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:52:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cemhO-0000BS-42 for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:52:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cemhN-0007L0-Ty for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:52:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Feb 2017 17:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25777 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148735388028158 (code B ref -1); Fri, 17 Feb 2017 17:52:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Feb 2017 17:51:20 +0000 Original-Received: from localhost ([127.0.0.1]:43795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cemgi-0007K5-4T for submit@debbugs.gnu.org; Fri, 17 Feb 2017 12:51:20 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54918) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cemgg-0007Js-OZ for submit@debbugs.gnu.org; Fri, 17 Feb 2017 12:51:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cemga-0008C6-FC for submit@debbugs.gnu.org; Fri, 17 Feb 2017 12:51:13 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:35071) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cemga-0008Bt-BD for submit@debbugs.gnu.org; Fri, 17 Feb 2017 12:51:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cemgZ-0001TL-3j for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:51:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cemgV-00088q-6h for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:51:11 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:23749) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cemgU-00087q-TX for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2017 12:51:07 -0500 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1HHp4Xn008775 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 Feb 2017 17:51:04 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v1HHp3jK008795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 Feb 2017 17:51:03 GMT Original-Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v1HHp2ud026013 for ; Fri, 17 Feb 2017 17:51:03 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129457 Archived-At: 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=092017-02-17 09:37:56.938748300 -0800 +++ rect-2017-02-17-patched.el=092017-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))))))) =20 (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=3D-O2 -static -g3''