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

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

bug#22694: 25.0.91; dired-mark-files-containing-regexp read file disk


From: Tino Calancha
Subject: bug#22694: 25.0.91; dired-mark-files-containing-regexp read file disk
Date: Mon, 27 Jun 2016 00:32:18 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)



On Wed, 20 Apr 2016, Eli Zaretskii wrote:

I guess we could have an option to switch to the behavior you would
like to see, but such an option, if we introduce it, IMO should not be
specific to this command, it should affect all the Dired commands
which might produce different results when buffers are not
auto-reverted.

I have only found another Dired command which might require the new option:
`dired-do-query-replace-regexp'.
But it seems unnecessary because this command already alert the user
if the file has being modified 'externally':

./emacs -Q -eval '(progn (with-temp-file "/tmp/foo" (insert "foobar")) (find-file 
"/tmp/foo") (dired "/tmp"))'
% g \`foobar$ RET
M-! echo foo > foo
M-x dired-do-query-replace-regexp RET \`foobar$ RET bar RET
;; File foo changed on disk.  Reread from disk? (yes or no)

;;;
So i propose a patch which:
1) Adds a new option `dired-always-read-filesystem' (default value nil).
2) Use it just in `dired-mark-files-containing-regexp'.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

From e6449456c023e86511cd09dbcacefba471c5f1d5 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Mon, 27 Jun 2016 00:10:57 +0900
Subject: [PATCH] Dired always read file system

* dired.el (dired-always-read-filesystem): Add new option.
(dired-mark-files-containing-regexp): Use it (Bug#22694).
* doc/emacs/dired.texi: Mention it in the manual.
; * etc/NEWS: Add entry for this change.
---
 doc/emacs/dired.texi |  7 +++++--
 etc/NEWS             |  3 +++
 lisp/dired.el        | 14 ++++++++++++--
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 486e92a..763c1f5 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -550,13 +550,16 @@ Marks vs Flags
 the regular expression @var{regexp}
 (@code{dired-mark-files-containing-regexp}).  This command is like
 @kbd{% m}, except that it searches the file contents instead of the file
-name.  Note that if a file is visited in an Emacs buffer, this command
+name.  Note that if a file is visited in an Emacs buffer,
+and @code{dired-always-read-filesystem} evaluates @code{nil}, this command
 will look in the buffer without revisiting the file, so the results
 might be inconsistent with the file on disk if its contents has changed
 since it was last visited.  If you don't want this, you may wish
 reverting the files you have visited in your buffers, or turning on
 the @code{auto-revert} mode in those buffers, before invoking this
-command.  @xref{Reverting}.
+command. @xref{Reverting}. If you prefer that this command always revisit
+the file, without having to revert the file or enable @code{auto-revert}
+mode, you might want to set @code{dired-always-read-filesystem} to non-@code{nil}.

 @item C-/
 @itemx C-x u
diff --git a/etc/NEWS b/etc/NEWS
index b3a044d..6683199 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -198,6 +198,9 @@ questions, with a handy way to display help texts.
 ** Dired

 +++
+*** New option 'dired-always-read-filesystem'.
+
++++
 *** In wdired, when editing files to contain slash characters,
 the resulting directories are automatically created.  Whether to do
 this is controlled by the 'wdired-create-parent-directories' variable.
diff --git a/lisp/dired.el b/lisp/dired.el
index 38979b5..7eb6216 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -255,6 +255,15 @@ dired-hide-details-hide-information-lines
   :version "24.4"
   :group 'dired)

+(defcustom dired-always-read-filesystem nil
+  "Non-nil means commands like `dired-mark-files-containing-regexp' which
+may use a buffer visiting the file or read the file on disk, always
+read the file system.  Otherwise, if do exist a buffer visiting the file,
+then use that buffer."
+  :type 'boolean
+  :version "25.2"
+  :group 'dired)
+
 ;; Internal variables

 (defvar dired-marker-char ?*           ; the answer is 42
@@ -3359,7 +3368,8 @@ dired-mark-files-containing-regexp
 A prefix argument means to unmark them instead.
 `.' and `..' are never marked.

-Note that if a file is visited in an Emacs buffer, this command will
+Note that if a file is visited in an Emacs buffer, and
+`dired-always-read-filesystem' evaluates nil, this command will
 look in the buffer without revisiting the file, so the results might
 be inconsistent with the file on disk if its contents has changed
 since it was last visited."
@@ -3379,7 +3389,7 @@ dired-mark-files-containing-regexp
                (message "Checking %s" fn)
                ;; For now we do it inside emacs
                ;; Grep might be better if there are a lot of files
-               (if prebuf
+               (if (and prebuf (not dired-always-read-filesystem))
                    (with-current-buffer prebuf
                      (save-excursion
                        (goto-char (point-min))
--
2.8.1


In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6)
Repository revision: 8419f0d166cf5107062ff74f120c591f3fce35d9






reply via email to

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