aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-20 23:31:59 -0500
committerCraig Jennings <c@cjennings.net>2026-07-20 23:31:59 -0500
commit2350d34ceb68aac74b87a518467a71476a204d5e (patch)
tree395c273262336fce2a7f46dc0b6cd8be1ff30cbf
parent3ea207c1c7588fbc122a766e5d8381815cd44711 (diff)
downloaddotemacs-2350d34ceb68aac74b87a518467a71476a204d5e.tar.gz
dotemacs-2350d34ceb68aac74b87a518467a71476a204d5e.zip
fix(org-roam): declare capture-templates special for immediate insert
Without the defvar, the byte-compiled let-binding in cj/org-roam-node-insert-immediate is a dead lexical binding and :immediate-finish never reaches org-roam-node-insert, so the immediate insert opened a capture buffer.
-rw-r--r--modules/org-roam-config.el4
-rw-r--r--tests/test-org-roam-config-format.el8
2 files changed, 12 insertions, 0 deletions
diff --git a/modules/org-roam-config.el b/modules/org-roam-config.el
index 867f2d99..e8d003e0 100644
--- a/modules/org-roam-config.el
+++ b/modules/org-roam-config.el
@@ -30,6 +30,10 @@
;; Declared special so the `let'-binding in `cj/org-roam-copy-todo-to-today'
;; compiles as a dynamic bind, not a dead lexical local -- otherwise the custom
;; capture template never reaches org-roam-dailies (the foreign-special-var trap).
+;; Declared special so cj/org-roam-node-insert-immediate's let-binding is
+;; dynamic under lexical-binding; without it the byte-compiled let is a dead
+;; lexical binding and :immediate-finish never reaches org-roam-node-insert.
+(defvar org-roam-capture-templates)
(defvar org-roam-dailies-capture-templates)
;; External variables, declared special so byte-compilation doesn't treat them
diff --git a/tests/test-org-roam-config-format.el b/tests/test-org-roam-config-format.el
index e9378b7a..caafe563 100644
--- a/tests/test-org-roam-config-format.el
+++ b/tests/test-org-roam-config-format.el
@@ -147,5 +147,13 @@ Returns the formatted file content."
(let ((result (test-format "Title" "id" "* Content")))
(should (string-match-p "#\\+FILETAGS: Topic\n\n\\* Content" result))))
+(ert-deftest test-org-roam-config-capture-templates-declared-special ()
+ "Normal: org-roam-capture-templates is declared special in the module.
+cj/org-roam-node-insert-immediate let-binds it; without the defvar the
+byte-compiled let is a dead lexical binding and :immediate-finish never
+reaches org-roam-node-insert -- the \"immediate\" insert opens a capture
+buffer."
+ (should (special-variable-p 'org-roam-capture-templates)))
+
(provide 'test-org-roam-config-format)
;;; test-org-roam-config-format.el ends here