all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <f92capac@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Tino Calancha <f92capac@gmail.com>, 22694@debbugs.gnu.org
Subject: bug#22694: 25.0.91; dired-mark-files-containing-regexp read file disk
Date: Mon, 27 Jun 2016 00:32:18 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1606270031030.25377@calancha-pc> (raw)
In-Reply-To: <83lh487036.fsf@gnu.org>



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	other threads:[~2016-06-26 15:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 12:47 bug#22694: 25.0.91; dired-mark-files-containing-regexp read file disk Tino Calancha
2016-02-16 16:05 ` Eli Zaretskii
2016-02-17 14:07   ` Tino Calancha
2016-02-24  9:31 ` Tino Calancha
2016-04-10  7:02 ` Tino Calancha
2016-04-20 14:55   ` Eli Zaretskii
2016-04-20 15:31     ` Tino Calancha
2016-04-20 15:48       ` Eli Zaretskii
2016-06-26 15:32         ` Tino Calancha [this message]
2016-07-09 11:07           ` Eli Zaretskii
2016-07-11  5:48             ` Tino Calancha
2016-07-11  5:49 ` bug#22694: (no subject) Tino Calancha

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1606270031030.25377@calancha-pc \
    --to=f92capac@gmail.com \
    --cc=22694@debbugs.gnu.org \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.