emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 83d53afae4 245/355: Improve dired revert-buffer


From: ELPA Syncer
Subject: [elpa] externals/denote 83d53afae4 245/355: Improve dired revert-buffer post rename
Date: Sun, 26 Jun 2022 23:58:29 -0400 (EDT)

branch: externals/denote
commit 83d53afae44eed1f1ac029ab19bf16d1b325ef03
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Improve dired revert-buffer post rename
---
 denote-dired.el | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/denote-dired.el b/denote-dired.el
index 93625ff570..bf3de7f544 100644
--- a/denote-dired.el
+++ b/denote-dired.el
@@ -142,7 +142,8 @@ old name followed by the new one."
   :group 'denote-dired)
 
 (defcustom denote-dired-post-rename-functions
-  (list #'denote-dired-rewrite-front-matter)
+  (list #'denote-dired-update-dired-buffers
+        #'denote-dired-rewrite-front-matter)
   "List of functions called after `denote-dired-rename-file'.
 Each function must accept three arguments: FILE, TITLE, and
 KEYWORDS.  The first is the full path to the file provided as a
@@ -227,10 +228,20 @@ attachments that the user adds to their notes."
                      (propertize old-name 'face 'error)
                      (propertize (file-name-nondirectory new-name) 'face 
'success)))
         (rename-file old-name new-name nil)
-        (when (derived-mode-p 'dired-mode)
-          (revert-buffer))
         (run-hook-with-args 'denote-dired-post-rename-functions new-name title 
keywords)))))
 
+(defun denote-dired-update-dired-buffers (&rest _)
+  "Update Dired buffers of variable `denote-directory'.
+Can run after `denote-dired-post-rename-functions', though it
+ignores all its arguments."
+  (mapc
+   (lambda (buf)
+     (with-current-buffer buf
+       (when (and (eq major-mode 'dired-mode)
+                  (string-match-p (expand-file-name default-directory) 
(denote-directory)))
+         (revert-buffer))))
+   (buffer-list)))
+
 (defun denote-dired--file-meta-header (title date keywords id filetype)
   "Front matter for renamed notes.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]