aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorSpencer Williams <spnw@plexwave.org>2025-07-06 20:20:15 -0400
committerSpencer Williams <spnw@plexwave.org>2025-07-06 21:47:34 -0400
commit3389d7454e7e4ca743f0a19516552a79825170f9 (patch)
treeed847d07051396f0555b8d82d9992680942855ef /lisp
parent10319bee92d0be2ad417b1635bc36c0a45a1b0a4 (diff)
Add draft support to title formatter
Diffstat (limited to 'lisp')
-rw-r--r--lisp/seam-test.el5
-rw-r--r--lisp/seam.el30
2 files changed, 23 insertions, 12 deletions
diff --git a/lisp/seam-test.el b/lisp/seam-test.el
index 9ab1b22..3f8c4e5 100644
--- a/lisp/seam-test.el
+++ b/lisp/seam-test.el
@@ -44,7 +44,7 @@
(default-directory seam-test-directory)
(seam-note-types '("private" "public"))
(seam-default-note-type "private")
- (seam-title-formatter (lambda (title _type) title))
+ (seam-title-formatter (lambda (title _type _draft-p) title))
(seam-export-template-file nil)
(seam-export-template-string seam-export-default-template-string)
(seam-export-internal-link-class nil)
@@ -206,7 +206,8 @@
(equal
"[private] Note"
(seam-test-with-notes ((seam-title-formatter
- (lambda (title type) (format "[%s] %s" type title))))
+ (lambda (title type _draft-p)
+ (format "[%s] %s" type title))))
((note "Note"))
(buffer-name note)))))
diff --git a/lisp/seam.el b/lisp/seam.el
index bc3a55a..124a9b7 100644
--- a/lisp/seam.el
+++ b/lisp/seam.el
@@ -57,9 +57,13 @@
:group 'seam
:type '(repeat string))
-(defun seam-format-title-default (title type)
- "Default Seam title formatter. Formats like this: \"TITLE (TYPE)\"."
- (format "%s %s" title (propertize (format "(%s)" type) 'face 'font-lock-comment-face)))
+(defun seam-format-title-default (title type draft-p)
+ "Default Seam title formatter. Formats like this: \"TITLE (TYPE[ draft])\"."
+ (format "%s %s"
+ title
+ (propertize
+ (format "(%s%s)" type (if draft-p " draft" ""))
+ 'face 'font-lock-comment-face)))
(defcustom seam-title-formatter
#'seam-format-title-default
@@ -189,8 +193,8 @@ naming. Must be a function taking two arguments: TITLE and TYPE."
(org-element-property :SEAM_SLUG (org-element-at-point))))))
(seam-slugify (seam-get-title-from-buffer buffer))))
-(defun seam-format-title (title type)
- (funcall seam-title-formatter title type))
+(defun seam-format-title (title type draft-p)
+ (funcall seam-title-formatter title type draft-p))
(defun seam-validate-note-type (type)
(unless (member type seam-note-types)
@@ -224,7 +228,11 @@ naming. Must be a function taking two arguments: TITLE and TYPE."
:test #'equal)
(and self (list self)))))
(let ((files (cl-loop for (title . file) in notes
- collect (cons (seam-format-title title (seam-get-note-type file)) file))))
+ collect (cons (seam-format-title
+ title
+ (seam-get-note-type file)
+ (seam-draft-p file))
+ file))))
(let ((completion (string-trim (funcall seam-completing-read-function prompt (mapcar #'car files)))))
(or (assoc completion files)
(cons completion nil)))))))
@@ -534,10 +542,12 @@ Otherwise, it's nil."
(cl-defun seam-set-buffer-name (&optional (buffer (current-buffer)))
(when-let ((title (seam-get-title-from-buffer)))
- (with-current-buffer buffer
- (rename-buffer
- (seam-format-title title
- (seam-get-note-type (buffer-file-name buffer)))))))
+ (let ((file (buffer-file-name buffer)))
+ (with-current-buffer buffer
+ (rename-buffer
+ (seam-format-title title
+ (seam-get-note-type file)
+ (seam-draft-p file)))))))
(defun seam-setup-buffer ()
"Setup hooks when loading a Seam file."