Skip to content

Extending the Capture System

Org-roam applies some patching over Org’s capture system to smooth out the user experience, and sometimes it is desirable to use Org-roam’s capturing system instead. The exposed function to be used in extensions is org-roam-capture-:

Function: org-roam-capture- &key goto keys node info props templates

Main entry point. GOTO and KEYS correspond to ‘org-capture’ arguments. INFO is a plist for filling up Org-roam’s capture templates. NODE is an ‘org-roam-node’ construct containing information about the node. PROPS is a plist containing additional Org-roam properties for each template. TEMPLATES is a list of org-roam templates.

An example of an extension using org-roam-capture- is org-roam-dailies itself:

emacs-lisp
(defun org-roam-dailies--capture (time &optional goto)
  "Capture an entry in a daily-note for TIME, creating it if necessary.

When GOTO is non-nil, go the note without creating an entry."
  (org-roam-capture- :goto (when goto '(4))
                     :node (org-roam-node-create)
                     :templates org-roam-dailies-capture-templates
                     :props (list :override-default-time time))
  (when goto (run-hooks 'org-roam-dailies-find-file-hook)))