branch: externals/denote
commit f770346729e18a0fda368fd6084b631c48a24dd0
Merge: aa7bf58234 d47ef97062
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Merge branch 'main' of git.sr.ht:~protesilaos/denote
---
 README.org |  9 ++++++---
 denote.el  | 23 +++++++++++++++--------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/README.org b/README.org
index c8ee41da42..63b4a37409 100644
--- a/README.org
+++ b/README.org
@@ -4087,9 +4087,12 @@ might change them without further notice.
 
 #+findex: denote-update-dired-buffers
 + Function ~denote-update-dired-buffers~ :: Update Dired buffers of
-  variable ~denote-directory~.  Note that the ~denote-directory~
-  accepts a directory-local value for what we internally refer to as
-  "silos" ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate 
directories for notes]]).
+  variable ~denote-directory~. Also revert the current Dired buffer
+  even if it is not inside the ~denote-directory~. Note that the
+  ~denote-directory~ accepts a directory-local value for what we
+  internally refer to as "silos" 
([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directories for 
notes]]).
+  [ Refined as part of {{{development-version}}} to also revert the
+    current Dired buffer. ]
 
 #+vindex: denote-file-types
 + Variable ~denote-file-types~ :: Alist of ~denote-file-type~ and
diff --git a/denote.el b/denote.el
index 518e74e95c..2360c02d8e 100644
--- a/denote.el
+++ b/denote.el
@@ -2245,15 +2245,22 @@ the file type is assumed to be the first of 
`denote-file-types'."
    denote-id-format
    (file-attribute-modification-time (file-attributes file))))
 
+(defun denote--revert-dired (buf)
+  "Revert BUF if appropriate.
+Do it if BUF is in Dired mode and is either part of the variable
+`denote-directory' or the `current-buffer'."
+  (let ((current (current-buffer)))
+    (with-current-buffer buf
+      (when (and (eq major-mode 'dired-mode)
+                 (or (denote--dir-in-denote-directory-p default-directory)
+                     (eq current buf)))
+        (revert-buffer)))))
+
 (defun denote-update-dired-buffers ()
-  "Update Dired buffers of variable `denote-directory'."
-  (mapc
-   (lambda (buf)
-     (with-current-buffer buf
-       (when (and (eq major-mode 'dired-mode)
-                  (denote--dir-in-denote-directory-p default-directory))
-         (revert-buffer))))
-   (buffer-list)))
+  "Update Dired buffers of variable `denote-directory'.
+Also revert the current Dired buffer even if it is not inside the
+variable `denote-directory'."
+  (mapc #'denote--revert-dired (buffer-list)))
 
 (defun denote--rename-buffer (old-name new-name)
   "Rename OLD-NAME buffer to NEW-NAME, when appropriate."

Reply via email to