]> code.delx.au - gnu-emacs/blobdiff - lisp/dired.el
Dired always read file system
[gnu-emacs] / lisp / dired.el
index d078478aaaff1c616dc5b2228c066059db2532f3..5d14291d787bede4536686c12ff546bf8d87e559 100644 (file)
@@ -255,6 +255,18 @@ new Dired buffers."
   :version "24.4"
   :group 'dired)
 
+(defcustom dired-always-read-filesystem nil
+  "Non-nil means revert buffers visiting files before searching them.
+ By default,  commands like `dired-mark-files-containing-regexp' will
+ search any buffers visiting the marked files without reverting them,
+ even if they were changed on disk.  When this option is non-nil, such
+ buffers are always reverted in a temporary buffer before searching
+ them: the search is performed on the temporary buffer, the original
+ buffer visiting the file is not modified."
+  :type 'boolean
+  :version "25.2"
+  :group 'dired)
+
 ;; Internal variables
 
 (defvar dired-marker-char ?*           ; the answer is 42
@@ -3359,7 +3371,8 @@ object files--just `.o' will mark more than you might think."
 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' is 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 +3392,7 @@ since it was last visited."
                (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))