Skip to content

Commit

Permalink
(feat): add :info key to org-roam-node-{capture/insert} (org-roam#1741)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jeremyf and jethrokuan authored Aug 9, 2021
1 parent b24d874 commit 39b2388
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions org-roam-capture.el
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,19 @@ TEMPLATES is a list of org-roam templates."
(org-capture goto keys)))

;;;###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.
This uses the templates defined at `org-roam-capture-templates'.
Arguments GOTO and KEYS see `org-capture'.
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.
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")
(let ((node (org-roam-node-read nil filter-fn)))
(org-roam-capture- :goto goto
:info info
:keys keys
:templates templates
:node node
Expand Down
6 changes: 4 additions & 2 deletions org-roam-node.el
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,13 @@ COMPLETION-A and COMPLETION-B are items in the form of (node-title org-roam-node
;;;; Linkage
;;;;; [id:] link
;;;###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.
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.
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)
(unwind-protect
;; Group functions together to avoid inconsistent state on quit
Expand All @@ -558,6 +559,7 @@ The TEMPLATES, if provided, override the list of capture templates (see
description)))
(org-roam-capture-
:node node
:info info
:templates templates
:props (append
(when (and beg end)
Expand Down

0 comments on commit 39b2388

Please sign in to comment.