aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorSpencer Williams <spnw@plexwave.org>2025-07-06 17:39:52 -0400
committerSpencer Williams <spnw@plexwave.org>2025-07-06 17:42:41 -0400
commit92b8d2a10c52fbaef681fea6b97a7dd20f642a8f (patch)
treea555019eb1b852abd84df5debb5254af22937961 /lisp
parent62387d60e68a0c6c92395eaff6b81beb88c34a50 (diff)
Improve file rename code
Diffstat (limited to 'lisp')
-rw-r--r--lisp/seam.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/seam.el b/lisp/seam.el
index 46a9824..193e8e5 100644
--- a/lisp/seam.el
+++ b/lisp/seam.el
@@ -301,6 +301,13 @@ completion prompt is given to choose the type."
(delete-file html)
(message "Deleted %s" html)))))
+(defun seam--rename-file (old new interactive)
+ (rename-file old new)
+ (when interactive
+ (set-visited-file-name new nil t)
+ (seam-set-buffer-name))
+ (seam-post-save-or-rename old new))
+
(defun seam-post-save-or-rename (old new &optional previous-links-from-file slug-or-title-changed)
(unless (string= old new)
(seam-update-links old new)
@@ -367,13 +374,12 @@ completion prompt is given to choose the type."
(seam-set-buffer-name)
t)))))
-(defun seam--set-note-type (file new-type)
+(defun seam--set-note-type (file new-type interactive)
(let ((old-type (seam-get-note-type file))
(new-file (seam-make-file-name (file-name-base file) new-type)))
(if (string= new-type old-type)
file
- (rename-file file new-file)
- (seam-post-save-or-rename file new-file)
+ (seam--rename-file file new-file interactive)
new-file)))
;;;###autoload
@@ -393,10 +399,7 @@ from 1). Otherwise a completion prompt is given for the desired type."
(remove old-type seam-note-types))
old-type)
t)))
- (let ((new-file (seam--set-note-type file new-type)))
- (when interactive
- (set-visited-file-name new-file nil t)
- (seam-set-buffer-name))))
+ (seam--set-note-type file new-type interactive))
(defun seam-update-links (old new)
(let ((old-slug (file-name-base old))