diff options
| author | Tino Calancha | 2016-07-11 14:34:49 +0900 |
|---|---|---|
| committer | Tino Calancha | 2016-07-11 14:34:49 +0900 |
| commit | df7774be39af76d3072a0278ef815a47bf50dfe9 (patch) | |
| tree | f722a0fa5197618c29b1bee0b33ab875f97f188a | |
| parent | bfeda891a51178dd0032800ea4aef013c62bbe10 (diff) | |
| download | emacs-df7774be39af76d3072a0278ef815a47bf50dfe9.tar.gz emacs-df7774be39af76d3072a0278ef815a47bf50dfe9.zip | |
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.
* test/lisp/dired-tests.el (dired-test-bug22694): Add test.
;* etc/NEWS: Add entry for this change.
| -rw-r--r-- | doc/emacs/dired.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/dired.el | 17 | ||||
| -rw-r--r-- | test/lisp/dired-tests.el | 19 |
4 files changed, 48 insertions, 5 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 486e92a40bb..2cda51a82fa 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi | |||
| @@ -550,13 +550,16 @@ Mark (with @samp{*}) all files whose @emph{contents} contain a match for | |||
| 550 | the regular expression @var{regexp} | 550 | the regular expression @var{regexp} |
| 551 | (@code{dired-mark-files-containing-regexp}). This command is like | 551 | (@code{dired-mark-files-containing-regexp}). This command is like |
| 552 | @kbd{% m}, except that it searches the file contents instead of the file | 552 | @kbd{% m}, except that it searches the file contents instead of the file |
| 553 | name. Note that if a file is visited in an Emacs buffer, this command | 553 | name. Note that if a file is visited in an Emacs buffer, |
| 554 | will look in the buffer without revisiting the file, so the results | 554 | and @code{dired-always-read-filesystem} is @code{nil} (the default), this |
| 555 | command will look in the buffer without revisiting the file, so the results | ||
| 555 | might be inconsistent with the file on disk if its contents has changed | 556 | might be inconsistent with the file on disk if its contents has changed |
| 556 | since it was last visited. If you don't want this, you may wish | 557 | since it was last visited. If you don't want this, you may wish |
| 557 | reverting the files you have visited in your buffers, or turning on | 558 | reverting the files you have visited in your buffers, or turning on |
| 558 | the @code{auto-revert} mode in those buffers, before invoking this | 559 | the @code{auto-revert} mode in those buffers, before invoking this |
| 559 | command. @xref{Reverting}. | 560 | command. @xref{Reverting}. If you prefer that this command always revisit |
| 561 | the file, without having to revert the file or enable @code{auto-revert} | ||
| 562 | mode, you might want to set @code{dired-always-read-filesystem} to non-@code{nil}. | ||
| 560 | 563 | ||
| 561 | @item C-/ | 564 | @item C-/ |
| 562 | @itemx C-x u | 565 | @itemx C-x u |
| @@ -243,6 +243,14 @@ whose content matches a regexp; bound to '% g'. | |||
| 243 | ** Dired | 243 | ** Dired |
| 244 | 244 | ||
| 245 | +++ | 245 | +++ |
| 246 | *** A New option 'dired-always-read-filesystem' default to nil. | ||
| 247 | If non-nil, buffers visiting files are reverted before search them; | ||
| 248 | for instance, in 'dired-mark-files-containing-regexp' a non-nil value | ||
| 249 | of this option means the file is revisited in a temporary buffer; | ||
| 250 | this temporary buffer is the actual buffer searched: the original buffer | ||
| 251 | visiting the file is not modified. | ||
| 252 | |||
| 253 | +++ | ||
| 246 | *** In wdired, when editing files to contain slash characters, | 254 | *** In wdired, when editing files to contain slash characters, |
| 247 | the resulting directories are automatically created. Whether to do | 255 | the resulting directories are automatically created. Whether to do |
| 248 | this is controlled by the 'wdired-create-parent-directories' variable. | 256 | this is controlled by the 'wdired-create-parent-directories' variable. |
diff --git a/lisp/dired.el b/lisp/dired.el index d078478aaaf..5d14291d787 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -255,6 +255,18 @@ new Dired buffers." | |||
| 255 | :version "24.4" | 255 | :version "24.4" |
| 256 | :group 'dired) | 256 | :group 'dired) |
| 257 | 257 | ||
| 258 | (defcustom dired-always-read-filesystem nil | ||
| 259 | "Non-nil means revert buffers visiting files before searching them. | ||
| 260 | By default, commands like `dired-mark-files-containing-regexp' will | ||
| 261 | search any buffers visiting the marked files without reverting them, | ||
| 262 | even if they were changed on disk. When this option is non-nil, such | ||
| 263 | buffers are always reverted in a temporary buffer before searching | ||
| 264 | them: the search is performed on the temporary buffer, the original | ||
| 265 | buffer visiting the file is not modified." | ||
| 266 | :type 'boolean | ||
| 267 | :version "25.2" | ||
| 268 | :group 'dired) | ||
| 269 | |||
| 258 | ;; Internal variables | 270 | ;; Internal variables |
| 259 | 271 | ||
| 260 | (defvar dired-marker-char ?* ; the answer is 42 | 272 | (defvar dired-marker-char ?* ; the answer is 42 |
| @@ -3359,7 +3371,8 @@ object files--just `.o' will mark more than you might think." | |||
| 3359 | A prefix argument means to unmark them instead. | 3371 | A prefix argument means to unmark them instead. |
| 3360 | `.' and `..' are never marked. | 3372 | `.' and `..' are never marked. |
| 3361 | 3373 | ||
| 3362 | Note that if a file is visited in an Emacs buffer, this command will | 3374 | Note that if a file is visited in an Emacs buffer, and |
| 3375 | `dired-always-read-filesystem' is nil, this command will | ||
| 3363 | look in the buffer without revisiting the file, so the results might | 3376 | look in the buffer without revisiting the file, so the results might |
| 3364 | be inconsistent with the file on disk if its contents has changed | 3377 | be inconsistent with the file on disk if its contents has changed |
| 3365 | since it was last visited." | 3378 | since it was last visited." |
| @@ -3379,7 +3392,7 @@ since it was last visited." | |||
| 3379 | (message "Checking %s" fn) | 3392 | (message "Checking %s" fn) |
| 3380 | ;; For now we do it inside emacs | 3393 | ;; For now we do it inside emacs |
| 3381 | ;; Grep might be better if there are a lot of files | 3394 | ;; Grep might be better if there are a lot of files |
| 3382 | (if prebuf | 3395 | (if (and prebuf (not dired-always-read-filesystem)) |
| 3383 | (with-current-buffer prebuf | 3396 | (with-current-buffer prebuf |
| 3384 | (save-excursion | 3397 | (save-excursion |
| 3385 | (goto-char (point-min)) | 3398 | (goto-char (point-min)) |
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el index 3efe2599138..d66a9caedd3 100644 --- a/test/lisp/dired-tests.el +++ b/test/lisp/dired-tests.el | |||
| @@ -31,5 +31,24 @@ | |||
| 31 | (symbol-function | 31 | (symbol-function |
| 32 | 'dired-jump)))) | 32 | 'dired-jump)))) |
| 33 | 33 | ||
| 34 | (ert-deftest dired-test-bug22694 () | ||
| 35 | "Test for http://debbugs.gnu.org/22694 ." | ||
| 36 | (let* ((dir (expand-file-name "bug22694" default-directory)) | ||
| 37 | (file "test") | ||
| 38 | (full-name (expand-file-name file dir)) | ||
| 39 | (regexp "bar") | ||
| 40 | (dired-always-read-filesystem t)) | ||
| 41 | (make-directory dir) | ||
| 42 | (with-temp-file full-name (insert "foo")) | ||
| 43 | (find-file-noselect full-name) | ||
| 44 | (dired dir) | ||
| 45 | (with-temp-file full-name (insert "bar")) | ||
| 46 | (dired-mark-files-containing-regexp regexp) | ||
| 47 | (unwind-protect | ||
| 48 | (should (equal (dired-get-marked-files nil nil nil 'distinguish-1-mark) | ||
| 49 | `(t ,full-name))) | ||
| 50 | ;; Clean up | ||
| 51 | (delete-directory dir 'recursive)))) | ||
| 52 | |||
| 34 | (provide 'dired-tests) | 53 | (provide 'dired-tests) |
| 35 | ;; dired-tests.el ends here | 54 | ;; dired-tests.el ends here |