GNU bug report logs -
#54025
27.2; dired-do-find-regexp skips occurences
Previous Next
Full log
Message #8 received at 54025 <at> debbugs.gnu.org (full text, mbox):
Hi!
On 16.02.2022 13:40, Петров Андрей wrote:
> 5. Go back to dired buffer and try searching for "aaa" again.
>
> Now*xref* does not contain 3.txt file although it has an occurence of
> "aaa".
>
> /home/andrey/3/1.txt
> 1: aaa
> /home/andrey/3/2.txt
> 1: aaa
>
> After saving 3.txt and repeating the search*xref* buffers shows all 3
> entries as expected.
>
> Please take a look into `xref-revert-buffer' (g) inside*xref* buffer
> also. It seems that it shows only occurences of the first file.
The reason this happens is because xref-matches-in-files uses the
contents of open buffers to verify the regexp matches, and to show the
(possibly syntax-highlighted) text in matches. The fact that such
buffers can be modified and unsaved is obviously a problem.
I suggest we simply add a check before doing a search, which will remind
you to save any such buffers. It will need to be added to
project-find-regexp as well, naturally. Something like the patch below.
What do you think?
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 41c45b4e51..c3b1b620bb 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3266,6 +3266,12 @@ dired-do-find-regexp
(require 'xref)
(defvar grep-find-ignored-files)
(declare-function rgrep-find-ignored-directories "grep" (dir))
+ (save-some-buffers)
+ (or (not (memq t (mapcar (lambda (buf)
+ (and (buffer-file-name buf)
+ (buffer-modified-p buf)))
+ (buffer-list))))
+ (user-error "Modified buffers exist; aborting"))
(let* ((marks (dired-get-marked-files nil nil nil nil t))
(ignores (nconc (mapcar
#'file-name-as-directory
This bug report was last modified 3 years and 114 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.