From f144941dfbe9b695b89a71089bb20d896f920efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20L=C3=B3pez=20Rivera?= <47611105+alopezrivera@users.noreply.github.com> Date: Wed, 25 May 2022 20:57:17 +0200 Subject: [PATCH] (fix)capture: respect blank lines in capture templates (#2203) --- org-roam-capture.el | 2 +- tests/test-org-roam-capture.el | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/org-roam-capture.el b/org-roam-capture.el index 8abb0d3..4f8e59b 100644 --- a/org-roam-capture.el +++ b/org-roam-capture.el @@ -788,7 +788,7 @@ When ENSURE-NEWLINE, always ensure there's a newline behind." ;; template does not start with any whitespace, and only ends with a single newline ;; ;; Instead, we restore the whitespace in the original template. - (setq template (replace-regexp-in-string "\n$" "" (org-capture-fill-template template))) + (setq template (replace-regexp-in-string "[\n]*\\'" "" (org-capture-fill-template template))) (when (and ensure-newline (string-equal template-whitespace-content "")) (setq template-whitespace-content "\n")) diff --git a/tests/test-org-roam-capture.el b/tests/test-org-roam-capture.el index ef20605..f35681c 100644 --- a/tests/test-org-roam-capture.el +++ b/tests/test-org-roam-capture.el @@ -48,6 +48,11 @@ (org-roam-capture--fill-template "foo\n\t\n") :to-equal "foo\n\t\n")) + (it "fills template without deleting newlines in its body" + (expect + (org-roam-capture--fill-template "foo\n\n\nbar\n\n") + :to-equal "foo\n\n\nbar\n\n")) + (it "expands templates when it's a function" (expect (org-roam-capture--fill-template (lambda () "foo"))