seam

Personal wiki toolkit for Emacs
Log | Files | Refs | LICENSE

commit caca4dce67ba849325d258caf105cc2f98873440
parent 96917b4701014066197c42bfb248e4362401cf2b
Author: Spencer Williams <spnw@plexwave.org>
Date:   Thu, 10 Jul 2025 14:02:03 -0400

Fix draft note titles showing up in backlinks

Diffstat:
Mlisp/seam-test.el | 15+++++++++++++++
Mlisp/seam.el | 8++++++--
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/seam-test.el b/lisp/seam-test.el @@ -366,6 +366,21 @@ backlink." (insert-file-contents "html/bar.html") (buffer-string)))))) +(ert-deftest seam-test-backlinks-draft () + "Test that linking to a note from a draft note does not create a +backlink." + (should + (equal + "" + (seam-test-with-notes ((seam-export-template-string "{{backlinks}}")) + ((foo "foo" "public" nil t) + (bar "bar" "public")) + (with-current-buffer foo + (seam-test-add-contents foo (seam-test-link-to-buffer bar))) + (with-temp-buffer + (insert-file-contents "html/bar.html") + (buffer-string)))))) + (ert-deftest seam-test-set-type-private () "Test that setting a public note to private will delete its HTML file and update linking HTML files such that they no longer link to it." diff --git a/lisp/seam.el b/lisp/seam.el @@ -315,8 +315,12 @@ completion prompt is given to choose the type." (defun seam-get-links-to-file (file) "Return filename of each note which links to FILE." - (remove (expand-file-name file) - (seam-note-files-containing-string (format "[[seam:%s]" (file-name-base file))))) + (cl-loop for file in (remove (expand-file-name file) + (seam-note-files-containing-string + (format "[[seam:%s]" (file-name-base file)))) + when (or seam-export--include-drafts + (not (seam-draft-p file))) + collect file)) (cl-defun seam-get-links-from-buffer (&optional (buffer (current-buffer))) "Return filename of each existing note which is linked to from BUFFER."