Org-roam Template Expansion
Org-roam’s template definitions also extend org-capture’s template syntax, to allow prefilling of strings. We have seen a glimpse of this in Template Walkthrough.
Org-roam provides the ${foo} syntax for substituting variables with known strings. ${foo}’s substitution is performed as follows:
- If
foois a function,foois called with the current node as its argument. - Else if
org-roam-node-foois a function,foois called with the current node as its argument. Theorg-roam-node-prefix defines many of Org-roam’s node accessors such asorg-roam-node-titleandorg-roam-node-level. - Else look up
org-roam-capture--infoforfoo. This is an internal variable that is set before the capture process begins. - If none of the above applies, read a string using
completing-read.- Org-roam also provides the
${foo=default_val}syntax, where if a default value is provided, will be the initial value for thefookey during minibuffer completion.
- Org-roam also provides the
One can check the list of available keys for nodes by inspecting the org-roam-node struct. At the time of writing, it is:
emacs-lisp
(cl-defstruct (org-roam-node (:constructor org-roam-node-create)
(:copier nil))
"A heading or top level file with an assigned ID property."
file file-hash file-atime file-mtime
id level point todo priority scheduled deadline title properties olp
tags aliases refs)This makes ${file}, ${file-hash} etc. all valid substitutions.