unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: "Петров Андрей" <an.petrov@pay-lab.ru>, "Eli Zaretskii" <eliz@gnu.org>
Cc: "54025@debbugs.gnu.org" <54025@debbugs.gnu.org>
Subject: bug#54025: 27.2; dired-do-find-regexp skips occurences
Date: Thu, 24 Feb 2022 04:50:35 +0200	[thread overview]
Message-ID: <da8f4b09-d27a-3522-b4c5-333214345fcd@yandex.ru> (raw)
In-Reply-To: <0239f68191344ab49b23ddc96c7bd6e9@pay-lab.ru>

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	other threads:[~2022-02-24  2:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 11:40 bug#54025: 27.2; dired-do-find-regexp skips occurences Петров Андрей
2022-02-21  0:35 ` Dmitry Gutov
2022-02-21  3:33   ` Eli Zaretskii
2022-02-21  7:00     ` Петров Андрей
2022-02-21 23:58       ` Dmitry Gutov
2022-02-23  2:38       ` Dmitry Gutov
2022-02-23  7:01         ` Петров Андрей
2022-02-24  2:50           ` Dmitry Gutov [this message]
2022-02-24  7:25             ` Петров Андрей
2022-02-25  1:38               ` Dmitry Gutov
2022-02-25  8:13                 ` Michael Albinus
2022-02-25 13:47                   ` Dmitry Gutov
2022-02-25 15:05                     ` Michael Albinus
2022-02-26  0:28                       ` Dmitry Gutov
2022-02-26 11:56                         ` Michael Albinus
2022-02-26 14:54                           ` Петров Андрей
2022-02-27  2:50                             ` Dmitry Gutov
2022-02-27 12:50                               ` Петров Андрей

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=da8f4b09-d27a-3522-b4c5-333214345fcd@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=54025@debbugs.gnu.org \
    --cc=an.petrov@pay-lab.ru \
    --cc=eliz@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).