From 3f10699d75dafa7266340b8eb0a2e0fb12b6540a Mon Sep 17 00:00:00 2001 From: Spencer Williams Date: Sun, 6 Jul 2025 20:01:25 -0400 Subject: Use helper to retrieve slugs from filenames --- lisp/seam-export.el | 2 +- lisp/seam.el | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/lisp/seam-export.el b/lisp/seam-export.el index 71a7921..b5d7046 100644 --- a/lisp/seam-export.el +++ b/lisp/seam-export.el @@ -239,7 +239,7 @@ notes)." (defun seam-export--note-to-html (note-file html-directory) (seam-ensure-directory-exists html-directory) (let ((html-file (file-name-concat html-directory - (concat (file-name-base note-file) ".html"))) + (concat (seam-get-slug-from-file-name note-file) ".html"))) (modified (file-attribute-modification-time (file-attributes note-file)))) (with-temp-buffer diff --git a/lisp/seam.el b/lisp/seam.el index 2824fc7..a5b0b0d 100644 --- a/lisp/seam.el +++ b/lisp/seam.el @@ -172,6 +172,9 @@ naming. Must be a function taking two arguments: TITLE and TYPE." (insert-file-contents file) (seam-get-title-from-buffer))) +(defun seam-get-slug-from-file-name (file) + (string-remove-prefix "-" (file-name-base file))) + (cl-defun seam-get-slug-from-buffer (&optional (buffer (current-buffer))) (or (with-current-buffer buffer (save-mark-and-excursion @@ -295,11 +298,12 @@ completion prompt is given to choose the type." (seam-get-links-from-buffer))) (defun seam-delete-html-files-for-note (note-file) - (dolist (dir (seam-html-directories)) - (let ((html (file-name-concat dir (concat (file-name-base note-file) ".html")))) - (when (file-exists-p html) - (delete-file html) - (message "Deleted %s" html))))) + (let ((html-nd (concat (seam-get-slug-from-file-name note-file) ".html"))) + (dolist (dir (seam-html-directories)) + (let ((html (file-name-concat dir html-nd))) + (when (file-exists-p html) + (delete-file html) + (message "Deleted %s" html)))))) (defun seam--rename-file (old new interactive) (rename-file old new) -- cgit v1.2.3