diff options
-rw-r--r-- | CHANGELOG.org | 4 | ||||
-rw-r--r-- | lisp/seam-test.el | 5 | ||||
-rw-r--r-- | lisp/seam.el | 30 |
3 files changed, 27 insertions, 12 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index 1350e0e..b71f430 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -6,6 +6,10 @@ should have been all along. Make sure to update your =init.el= accordingly. +- Your =seam-title-formatter= function should now take three arguments + instead of two: the third arg (=draft-p=) will be non-nil if the + note is a draft. + **** Renamed functions - =seam-replace-string-in-notes= is now 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." |