bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#54025: 27.2; dired-do-find-regexp skips occurences


From: Петров Андрей
Subject: bug#54025: 27.2; dired-do-find-regexp skips occurences
Date: Thu, 24 Feb 2022 07:25:35 +0000

Dmitry,
I tested your patch. As for me, it works the best way!


С уважением,
Андрей Петров,
программист ООО Инпас-Софт.


________________________________________
От: DG <raaahh@gmail.com> от имени Dmitry Gutov <dgutov@yandex.ru>
Отправлено: 24 февраля 2022 г. 7:50:35
Кому: Петров Андрей; Eli Zaretskii
Копия: 54025@debbugs.gnu.org
Тема: Re: bug#54025: 27.2; dired-do-find-regexp skips occurences

On 23.02.2022 09:01, Петров Андрей wrote:
> It seems that processing unmodified (or not open) files with grep and 
> modified ones with searching in buffers would be a well-balanced approach 
> saving both memory and possible network traffic (or SSD rewrite cycles) but 
> this is rather feature to make in the future then a hot fix )).

This, together with the previous discussion, gave me an idea.

Do you personally want to be prompted to save the buffers? If not, we
could just do the "with appropriate logging" part. More than that, when
the buffer is unsaved, we can just process the text returned by grep in
a temp buffer (which is what we do for all non-visited files anyway).

So, how about just the change below? Or should we add the prompting to
save as well?

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index aa98aa89f1..96fb835d0f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -2010,10 +2010,16 @@ xref--collect-matches-1

  (defun xref--find-file-buffer (file)
    (unless (equal (car xref--last-file-buffer) file)
-    (setq xref--last-file-buffer
-          ;; `find-buffer-visiting' is considerably slower,
-          ;; especially on remote files.
-          (cons file (get-file-buffer file))))
+    ;; `find-buffer-visiting' is considerably slower,
+    ;; especially on remote files.
+    (let ((buf (get-file-buffer file)))
+      (when (and buf
+                 (or
+                  (buffer-modified-p buf)
+                  (not (verify-visited-file-modtime (current-buffer)))))
+        ;; We can't use buffers whose contents diverge from disk
(bug#54025).
+        (setq buf nil))
+      (setq xref--last-file-buffer (cons file buf))))
    (cdr xref--last-file-buffer))

  (provide 'xref)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]