From: Dmitry Gutov <dgutov@yandex.ru>
To: 23484@debbugs.gnu.org
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 [thread overview]
Message-ID: <86d1owl682.fsf@yandex.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xref-undo-fix-attempt.diff --]
[-- Type: text/x-diff, Size: 2597 bytes --]
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"))))
[-- Attachment #3: Type: text/plain, Size: 274 bytes --]
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
next reply other threads:[~2016-05-08 19:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-08 19:06 Dmitry Gutov [this message]
2016-05-08 20:19 ` bug#23484: 25.1.50; undo doesn't work properly in xref-query-replace-in-results Juri Linkov
2016-05-08 20:26 ` Dmitry Gutov
2016-05-09 20:01 ` Juri Linkov
2016-05-09 20:10 ` Dmitry Gutov
2016-05-09 20:19 ` Dmitry Gutov
2016-05-10 21:34 ` Juri Linkov
2016-05-10 22:03 ` Dmitry Gutov
2016-05-11 20:48 ` Juri Linkov
2016-05-11 21:11 ` Dmitry Gutov
2016-05-12 20:57 ` Juri Linkov
2016-05-12 22:01 ` Dmitry Gutov
2016-05-14 20:34 ` Juri Linkov
2016-05-14 21:13 ` Dmitry Gutov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86d1owl682.fsf@yandex.ru \
--to=dgutov@yandex.ru \
--cc=23484@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 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).