]> git.eshelyaron.com Git - emacs.git/commitdiff
(dired-auto-revert-buffer): New defcustom.
authorJuri Linkov <juri@jurta.org>
Fri, 4 Dec 2009 21:45:29 +0000 (21:45 +0000)
committerJuri Linkov <juri@jurta.org>
Fri, 4 Dec 2009 21:45:29 +0000 (21:45 +0000)
(dired-internal-noselect): Use it.

etc/NEWS
lisp/ChangeLog
lisp/dired.el

index d398640aa4e489b0f1eaf34d64e0c11526d13e38..a9f684a9f25b973efdef57851e1abdae69e65f28 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -201,6 +201,11 @@ effective for buffers that have no associated file.  If you want to
 exempt buffers that do correspond to files, customize the value of
 `desktop-files-not-to-save' instead.
 
+** Dired
+
+*** The new variable `dired-auto-revert-buffer' allows to revert
+dired buffers automatically on revisiting.
+
 ** DocView
 
 *** When `doc-view-continuous' is non-nil, scrolling a line
index 732c204f82b4808e4e87aa28caa8f4f5977c6d1d..bef37d72e58a24af3fc8d497ba89f62ce1c568aa 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-04  Juri Linkov  <juri@jurta.org>
+
+       * dired.el (dired-auto-revert-buffer): New defcustom.
+       (dired-internal-noselect): Use it.
+
 2009-12-04  Juri Linkov  <juri@jurta.org>
 
        Change roles of modes and functions in image-mode.el (Bug#5062).
index f1407c8d80d41d30ffe2e3b1b9e7a6b644ca7a7b..c34ff4ec3f7610a0184477d7afee19ecd0dd37d5 100644 (file)
@@ -752,6 +752,24 @@ for a remote directory.  This feature is used by Auto Revert Mode."
         buffer-read-only
         (dired-directory-changed-p dirname))))
 
+;;;###autoload
+(defcustom dired-auto-revert-buffer nil
+  "Automatically revert dired buffer on revisiting.
+If t, revisiting an existing dired buffer automatically reverts it.
+If its value is a function, call this function with the directory
+name as single argument and revert the buffer if it returns non-nil.
+Otherwise, a message offering to revert the changed dired buffer
+is displayed.
+Note that this is not the same as `auto-revert-mode' that
+periodically reverts at specified time intervals."
+  :type '(choice
+          (const :tag "Don't revert" nil)
+          (const :tag "Always revert visited dired buffer" t)
+          (const :tag "Revert changed dired buffer" dired-directory-changed-p)
+          (function :tag "Predicate function"))
+  :group 'dired
+  :version "23.2")
+
 (defun dired-internal-noselect (dir-or-list &optional switches mode)
   ;; If there is an existing dired buffer for DIRNAME, just leave
   ;; buffer as it is (don't even call dired-revert).
@@ -779,6 +797,14 @@ for a remote directory.  This feature is used by Auto Revert Mode."
               (setq dired-directory dir-or-list)
               ;; this calls dired-revert
               (dired-sort-other switches))
+             ;; Always revert regardless of whether it has changed or not.
+             ((eq dired-auto-revert-buffer t)
+              (revert-buffer))
+             ;; Revert when predicate function returns non-nil.
+             ((functionp dired-auto-revert-buffer)
+              (when (funcall dired-auto-revert-buffer dirname)
+                (revert-buffer)
+                (message "Changed directory automatically updated")))
              ;; If directory has changed on disk, offer to revert.
              ((when (dired-directory-changed-p dirname)
                 (message "%s"