aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-12 10:00:36 -0500
committerCraig Jennings <c@cjennings.net>2026-06-12 10:00:36 -0500
commit1894dd4f1be82b3aad87d9bc4d90db8b11b25f01 (patch)
treeb9c282bc461d750678370bba545ec569e911f558
parent4975fcbdbedbada8a7ea9851f1110bc2f31aa4ef (diff)
downloaddotemacs-1894dd4f1be82b3aad87d9bc4d90db8b11b25f01.tar.gz
dotemacs-1894dd4f1be82b3aad87d9bc4d90db8b11b25f01.zip
fix(org-roam): put dailies #+FILETAGS and #+TITLE on separate lines
The "d" dailies head ran FILETAGS and TITLE together with no newline, so every C-c n d daily was malformed: Org never parsed #+TITLE and the FILETAGS value swallowed the rest of the line. Extracted the head into the cj/--org-roam-dailies-head defconst so it is unit-testable (the value was unreachable inside the use-package :custom form) and gave it real newlines. Two ERT tests assert the FILETAGS/TITLE line separation and the trailing newline.
-rw-r--r--modules/org-roam-config.el10
-rw-r--r--tests/test-org-roam-config-dailies-head.el29
2 files changed, 37 insertions, 2 deletions
diff --git a/modules/org-roam-config.el b/modules/org-roam-config.el
index fdd9e1fc5..218f37d68 100644
--- a/modules/org-roam-config.el
+++ b/modules/org-roam-config.el
@@ -29,6 +29,12 @@
;; ---------------------------------- Org Roam ---------------------------------
+(defconst cj/--org-roam-dailies-head
+ "#+FILETAGS: Journal\n#+TITLE: %<%Y-%m-%d>\n"
+ "Head inserted into a new org-roam daily file.
+FILETAGS and TITLE must sit on separate lines so Org parses the
+#+TITLE keyword (see `org-roam-dailies-capture-templates').")
+
(use-package org-roam
:defer 1
:commands (org-roam-node-find org-roam-node-insert org-roam-db-autosync-mode)
@@ -37,9 +43,9 @@
(org-roam-dailies-directory journals-dir)
(org-roam-completion-everywhere t)
(org-roam-dailies-capture-templates
- '(("d" "default" entry "* %<%I:%M:%S %p %Z> %?"
+ `(("d" "default" entry "* %<%I:%M:%S %p %Z> %?"
:if-new (file+head "%<%Y-%m-%d>.org"
- "#+FILETAGS: Journal #+TITLE: %<%Y-%m-%d>"))))
+ ,cj/--org-roam-dailies-head))))
(org-roam-capture-templates
`(("d" "default" plain "%?"
diff --git a/tests/test-org-roam-config-dailies-head.el b/tests/test-org-roam-config-dailies-head.el
new file mode 100644
index 000000000..631f017c3
--- /dev/null
+++ b/tests/test-org-roam-config-dailies-head.el
@@ -0,0 +1,29 @@
+;;; test-org-roam-config-dailies-head.el --- Tests for the dailies template head -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; `cj/--org-roam-dailies-head' is the head inserted into a new org-roam
+;; daily file. #+FILETAGS and #+TITLE must sit on separate lines, or Org
+;; never parses the #+TITLE keyword and the FILETAGS value swallows the
+;; rest of the line.
+
+;;; Code:
+
+(require 'ert)
+(require 'testutil-general)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'org-roam-config)
+
+(ert-deftest test-org-roam-config-dailies-head-separates-filetags-and-title ()
+ "Boundary: #+FILETAGS and #+TITLE sit on separate lines."
+ (should (string-match-p "#\\+FILETAGS: Journal\n#\\+TITLE:"
+ cj/--org-roam-dailies-head))
+ ;; And never run together on one line.
+ (should-not (string-match-p "Journal #\\+TITLE:" cj/--org-roam-dailies-head)))
+
+(ert-deftest test-org-roam-config-dailies-head-ends-with-newline ()
+ "Boundary: the head ends with a newline so the capture body starts clean."
+ (should (string-suffix-p "\n" cj/--org-roam-dailies-head)))
+
+(provide 'test-org-roam-config-dailies-head)
+;;; test-org-roam-config-dailies-head.el ends here