(feat): add :info key to org-roam-node-{capture/insert} (#1741)

In adding this parameter, the external facing methods expose another
point of parameterization for the inner org-roam-capture- method.

This is most useful for the org-roam-node-insert method which has a
complicated inner logic; By adding the :info &key parameter, we
reduce the likelyhood of needing to duplicate that inner logic.

Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
Jeremy Friesen
2021-08-09 03:09:10 -04:00
committed by GitHub
parent b24d874f26
commit 39b2388768
2 changed files with 8 additions and 4 deletions

View File

@ -403,17 +403,19 @@ TEMPLATES is a list of org-roam templates."
(org-capture goto keys))) (org-capture goto keys)))
;;;###autoload ;;;###autoload
(cl-defun org-roam-capture (&optional goto keys &key filter-fn templates) (cl-defun org-roam-capture (&optional goto keys &key filter-fn templates info)
"Launches an `org-capture' process for a new or existing node. "Launches an `org-capture' process for a new or existing node.
This uses the templates defined at `org-roam-capture-templates'. This uses the templates defined at `org-roam-capture-templates'.
Arguments GOTO and KEYS see `org-capture'. Arguments GOTO and KEYS see `org-capture'.
FILTER-FN is a function to filter out nodes: it takes an `org-roam-node', FILTER-FN is a function to filter out nodes: it takes an `org-roam-node',
and when nil is returned the node will be filtered out. and when nil is returned the node will be filtered out.
The TEMPLATES, if provided, override the list of capture templates (see The TEMPLATES, if provided, override the list of capture templates (see
`org-roam-capture-'.)" `org-roam-capture-'.)
The INFO, if provided, is passed along to the underlying `org-roam-capture-'."
(interactive "P") (interactive "P")
(let ((node (org-roam-node-read nil filter-fn))) (let ((node (org-roam-node-read nil filter-fn)))
(org-roam-capture- :goto goto (org-roam-capture- :goto goto
:info info
:keys keys :keys keys
:templates templates :templates templates
:node node :node node

View File

@ -528,12 +528,13 @@ COMPLETION-A and COMPLETION-B are items in the form of (node-title org-roam-node
;;;; Linkage ;;;; Linkage
;;;;; [id:] link ;;;;; [id:] link
;;;###autoload ;;;###autoload
(cl-defun org-roam-node-insert (&optional filter-fn &key templates) (cl-defun org-roam-node-insert (&optional filter-fn &key templates info)
"Find an Org-roam node and insert (where the point is) an \"id:\" link to it. "Find an Org-roam node and insert (where the point is) an \"id:\" link to it.
FILTER-FN is a function to filter out nodes: it takes an `org-roam-node', FILTER-FN is a function to filter out nodes: it takes an `org-roam-node',
and when nil is returned the node will be filtered out. and when nil is returned the node will be filtered out.
The TEMPLATES, if provided, override the list of capture templates (see The TEMPLATES, if provided, override the list of capture templates (see
`org-roam-capture-'.)" `org-roam-capture-'.)
The INFO, if provided, is passed to the underlying `org-roam-capture-'."
(interactive) (interactive)
(unwind-protect (unwind-protect
;; Group functions together to avoid inconsistent state on quit ;; Group functions together to avoid inconsistent state on quit
@ -558,6 +559,7 @@ The TEMPLATES, if provided, override the list of capture templates (see
description))) description)))
(org-roam-capture- (org-roam-capture-
:node node :node node
:info info
:templates templates :templates templates
:props (append :props (append
(when (and beg end) (when (and beg end)