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

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

[elpa] externals/denote d14a421036 4/8: Only rename the file if it exist


From: ELPA Syncer
Subject: [elpa] externals/denote d14a421036 4/8: Only rename the file if it exists in denote-rename-file-and-buffer
Date: Fri, 17 May 2024 00:57:49 -0400 (EDT)

branch: externals/denote
commit d14a421036561cf6ae0505bbe1b80005290a690d
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>

    Only rename the file if it exists in denote-rename-file-and-buffer
---
 denote.el | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/denote.el b/denote.el
index df509b041b..455b4ab79f 100644
--- a/denote.el
+++ b/denote.el
@@ -2548,17 +2548,19 @@ variable `denote-directory'."
 (defun denote-rename-file-and-buffer (old-name new-name)
   "Rename file named OLD-NAME to NEW-NAME, updating buffer name."
   (unless (string= (expand-file-name old-name) (expand-file-name new-name))
-    (cond
-     ((derived-mode-p 'dired-mode)
-      (dired-rename-file old-name new-name nil))
-     ;; NOTE 2024-02-25: The `vc-rename-file' requires the file to be
-     ;; saved, but our convention is to not save the buffer after
-     ;; changing front matter unless we absolutely have to (allows
-     ;; users to do `diff-buffer-with-file', for example).
-     ((and denote-save-buffers (not (buffer-modified-p)) (vc-backend old-name))
-      (vc-rename-file old-name new-name))
-     (t
-      (rename-file old-name new-name nil)))
+    (when (and (denote--file-regular-writable-p old-name)
+               (file-writable-p new-name))
+      (cond
+       ((derived-mode-p 'dired-mode)
+        (dired-rename-file old-name new-name nil))
+       ;; NOTE 2024-02-25: The `vc-rename-file' requires the file to be
+       ;; saved, but our convention is to not save the buffer after
+       ;; changing front matter unless we absolutely have to (allows
+       ;; users to do `diff-buffer-with-file', for example).
+       ((and denote-save-buffers (not (buffer-modified-p)) (vc-backend 
old-name))
+        (vc-rename-file old-name new-name))
+       (t
+        (rename-file old-name new-name nil))))
     (when-let ((buffer (find-buffer-visiting old-name)))
       (with-current-buffer buffer
         (set-visited-file-name new-name nil t)))))



reply via email to

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