From 5febe90b6b536ee07914717aa946d35346691975 Mon Sep 17 00:00:00 2001 From: Spencer Williams Date: Thu, 10 Jul 2025 13:39:38 -0400 Subject: Add draft arg to seam-create-note and update tests --- lisp/seam-test.el | 11 +++-------- lisp/seam.el | 12 +++++++----- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'lisp') diff --git a/lisp/seam-test.el b/lisp/seam-test.el index 6eb25d3..797ce2b 100644 --- a/lisp/seam-test.el +++ b/lisp/seam-test.el @@ -209,10 +209,8 @@ (seam-test-with-notes ((seam-title-formatter (lambda (title type draft-p) (format "[%s%s] %s" type (if draft-p " draft" "") title)))) - ((note "Note")) - (with-current-buffer note - (call-interactively 'seam-toggle-draft) - (buffer-name note)))))) + ((note "Note" nil nil t)) + (buffer-name note))))) (ert-deftest seam-test-link-update () "Test that renaming a note updates its HTML and that of notes which link to it." @@ -439,8 +437,6 @@ link to it." (seam-test-links-from-html "html/foo.html") (seam-test-list-files)))))) -;;; NOTE: This is the same test as `seam-test-set-draft', except that -;;; we toggle bar's draft status twice. (ert-deftest seam-test-unset-draft () "Test that toggling a note from draft to non-draft will export its HTML file and update linking HTML files such that they link to @@ -450,11 +446,10 @@ it." '(("bar.html") ("html/bar.html" "html/foo.html" "public/bar.org" "public/foo.org")) (seam-test-with-notes () ((foo "foo" "public") - (bar "bar" "public")) + (bar "bar" "public" nil t)) (with-current-buffer foo (seam-test-add-contents foo (seam-test-link-to-buffer bar))) (with-current-buffer bar - (call-interactively 'seam-toggle-draft) (call-interactively 'seam-toggle-draft)) (list (seam-test-links-from-html "html/foo.html") diff --git a/lisp/seam.el b/lisp/seam.el index 9c421c2..0dcf9d7 100644 --- a/lisp/seam.el +++ b/lisp/seam.el @@ -219,17 +219,19 @@ naming. Must be a function taking two arguments: TITLE and TYPE." (unless (member type (seam-get-all-note-type-names)) (error "`%s' is not a valid Seam note type" type))) -(defun seam-create-note (title &optional type select) +(cl-defun seam-create-note (title &optional type select (draft-p nil draft-supplied-p)) (unless type (setq type seam-default-note-type)) (seam-validate-note-type type) (seam-ensure-note-subdirectories-exist) (let* ((slug (seam-slugify title)) (draft-p - (if-let ((result (plist-member (cdr (assoc type (mapcar #'ensure-list seam-note-types))) - :create-as-draft))) - (cadr result) - seam-create-as-draft)) + (if draft-supplied-p + draft-p + (if-let ((result (plist-member (cdr (assoc type (mapcar #'ensure-list seam-note-types))) + :create-as-draft))) + (cadr result) + seam-create-as-draft))) (file (file-name-concat seam-note-directory type (concat (when draft-p "-") slug ".org")))) -- cgit v1.2.3