aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/seam-test.el15
-rw-r--r--lisp/seam.el8
2 files changed, 21 insertions, 2 deletions
diff --git a/lisp/seam-test.el b/lisp/seam-test.el
index 0abad2b..fc4e2d4 100644
--- 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
index 0dcf9d7..62d7737 100644
--- 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."