From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#23484: 25.1.50; undo doesn't work properly in xref-query-replace-in-results Date: Sun, 08 May 2016 22:06:37 +0300 Message-ID: <86d1owl682.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1462734449 10914 80.91.229.3 (8 May 2016 19:07:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 May 2016 19:07:29 +0000 (UTC) To: 23484@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 08 21:07:17 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1azU2s-0003C0-Kh for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 May 2016 21:07:14 +0200 Original-Received: from localhost ([::1]:37791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azU2o-0006hI-FD for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 May 2016 15:07:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azU2k-0006bC-E5 for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:07:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azU2g-00007q-0q for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:07:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azU2f-00007i-TU for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:07:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1azU2f-0007S0-PL for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 May 2016 19:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23484 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146273441528624 (code B ref -1); Sun, 08 May 2016 19:07:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 May 2016 19:06:55 +0000 Original-Received: from localhost ([127.0.0.1]:43468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1azU2Y-0007Rc-Rs for submit@debbugs.gnu.org; Sun, 08 May 2016 15:06:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1azU2W-0007RN-Qu for submit@debbugs.gnu.org; Sun, 08 May 2016 15:06:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azU2Q-0008SE-3Z for submit@debbugs.gnu.org; Sun, 08 May 2016 15:06:47 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:45978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azU2Q-0008S8-0a for submit@debbugs.gnu.org; Sun, 08 May 2016 15:06:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azU2O-000660-Ed for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:06:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azU2K-0008Qb-Uf for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:06:44 -0400 Original-Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:34766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azU2K-0008QH-Kg for bug-gnu-emacs@gnu.org; Sun, 08 May 2016 15:06:40 -0400 Original-Received: by mail-wm0-x22d.google.com with SMTP id v200so17419591wmv.1 for ; Sun, 08 May 2016 12:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version; bh=+NGjFnMEGj4b3t/uleMsFzH6rK9z9g7PM7XCkxFUMiU=; b=gesyhHngFAmhxxVKigxLfeDqajp1B8cjTRqdVgcDn4bBpJp2xWMRUBSvjyCyhA1gPZ CDOuPsqEoXOIIIExMJZaCnaXHJ6XAnfm0+FC6qckrLK7TcAQsTS9cER+P4famdVFTbcn 4g7zVQqAAHg4bYDalOOztJSFDpTL8UVtikbGw1jVZd3DTKVt1u30sJ+HT3Bzo4K3c3N+ d6cOs1Tg7PHRs3mqeKzXeuJnbGj96g4qyL4SRoHDqdTQBmPKLg7gAN4Jmsp9G0ENtdoa SFlBdB+OU6j8FupqBb7BiVEwmhgyMBBz8ppP7ImBlUEy3nkeEgc1zJEb+AtrgB57uDU+ A2bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version; bh=+NGjFnMEGj4b3t/uleMsFzH6rK9z9g7PM7XCkxFUMiU=; b=UOIhjWY5+2HWRkSnPzYJSqS5jJwJoNGGXjFEXDaNMXSYKGStnJ5BEJZstlivKJ+i1o TJA5vOc58LEaQhWE5fi8uC+26j4qh4GP2bRS3lAzIjaov94PtdbWucqEEOh+G1K6BZ92 CV3KKl0MMFgsq188fhbOgmlrfj+lTlPq/1LY1sCdd9u/N0kOTQdTTtu4Yps4TMsOCuws A4YJy7y0a5DRnrCogpznb9dQLCIJUGLwOwbvfNdIwOJ6Vx/6AxqUMsORs38QlE51ILfF hGuHjvEwbd2GL6O7mzYcluAPXN7OKboiDnfYParl+PgAPrchmQIRpJgg3uyZYwIkKe2E hDJg== X-Gm-Message-State: AOPr4FUHBDrLO7aQKBFWiMszziCFRQzFNp1ls3XrvhQGFVHB+vttYkRM6Bf1IW5soqeMXw== X-Received: by 10.28.156.86 with SMTP id f83mr6964126wme.45.1462734399787; Sun, 08 May 2016 12:06:39 -0700 (PDT) Original-Received: from axl ([185.105.175.24]) by smtp.gmail.com with ESMTPSA id az2sm26904594wjc.6.2016.05.08.12.06.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 May 2016 12:06:39 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:117994 Archived-At: --=-=-= Content-Type: text/plain 1. Do a search that has several matches in one buffer, e.g. using dired-do-find-regexp. 2. Press `r' in the *xref* buffer, to initiate replacement. Input `.*' and `abcd', for instance. This value of FROM is important. 3. Replace a couple then undo that (press y, y, u, u). 4. Try agreeing with the subsequent prompts. The replacements performed then will be wrong. I've tried to come up with a patch but stopped short of really delving into the code of perform-replace. Which seems really necessary at this point. Attaching what I already have. The big problem is that perform-replace does not consistently use replace-re-search-function. With the new undo code, it's became worse. After you press `u', it seems to switch to moving around the saved match data stack and using a plain looking-at, without checking with isearch-filter-predicate. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=xref-undo-fix-attempt.diff diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index f651dc9..5686cc9 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -552,6 +552,7 @@ xref--buf-pairs-iterator (end (move-marker (make-marker) (+ beg (xref-match-length item)) (marker-buffer beg)))) + (set-marker-insertion-type end t) (let ((pair (cons beg end))) (push pair all-pairs) ;; Perform sanity check first. @@ -593,7 +594,7 @@ xref--outdated-p (defun xref--query-replace-1 (from to iter) (let* ((query-replace-lazy-highlight nil) (continue t) - did-it-once buf-pairs pairs + did-it-once buf-pairs current-beg current-end ;; Counteract the "do the next match now" hack in ;; `perform-replace'. And still, it'll report that those @@ -605,23 +606,24 @@ xref--query-replace-1 (<= end current-end)))) (replace-re-search-function (lambda (from &optional _bound noerror) - (let (found pair) - (while (and (not found) pairs) - (setq pair (pop pairs) - current-beg (car pair) - current-end (cdr pair)) - (goto-char current-beg) - (when (re-search-forward from current-end noerror) - (setq found t))) - found)))) + (let ((tmp-pairs (cdr buf-pairs)) pair) + (while (and (not pair) tmp-pairs) + (setq current-beg (caar tmp-pairs) + current-end (cdar tmp-pairs)) + (unless (< current-beg (point)) + (goto-char current-beg) + (when (re-search-forward from current-end noerror) + (setq pair (car tmp-pairs)))) + (setq tmp-pairs (cdr tmp-pairs))) + pair)))) (while (and continue (setq buf-pairs (funcall iter :next))) (if did-it-once ;; Reuse the same window for subsequent buffers. (switch-to-buffer (car buf-pairs)) (xref--with-dedicated-window - (pop-to-buffer (car buf-pairs))) + (pop-to-buffer (car buf-pairs)) + (goto-char (point-min))) (setq did-it-once t)) - (setq pairs (cdr buf-pairs)) (setq continue (perform-replace from to t t nil nil multi-query-replace-map))) (unless did-it-once (user-error "No suitable matches here")))) --=-=-= Content-Type: text/plain In GNU Emacs 25.1.50.5 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9) of 2016-05-08 built on axl Repository revision: 2eb6817ba971184cc109f8530f4b3b38f65650ea Windowing system distributor 'The X.Org Foundation', version 11.0.11803000 System Description: Ubuntu 16.04 LTS --=-=-=--