Function: org-roam-node-read

org-roam-node-read is a byte-compiled function defined in org-roam-node.el.

Signature

(org-roam-node-read &optional INITIAL-INPUT FILTER-FN SORT-FN REQUIRE-MATCH PROMPT)

Documentation

Read and return an org-roam-node.

INITIAL-INPUT is the initial minibuffer prompt value. 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. SORT-FN is a function to sort nodes. See org-roam-node-read-sort-by-file-mtime for an example sort function. If REQUIRE-MATCH, the minibuffer prompt will require a match. PROMPT is a string to show at the beginning of the mini-buffer, defaulting to "Node: "

Source Code

;; Defined in ~/.emacs.d/elpa/org-roam-20260224.1637/org-roam-node.el
;;;; Completing-read interface
(defun org-roam-node-read (&optional initial-input filter-fn sort-fn require-match prompt)
  "Read and return an `org-roam-node'.
INITIAL-INPUT is the initial minibuffer prompt value.
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.
SORT-FN is a function to sort nodes. See `org-roam-node-read-sort-by-file-mtime'
for an example sort function.
If REQUIRE-MATCH, the minibuffer prompt will require a match.
PROMPT is a string to show at the beginning of the mini-buffer,
defaulting to \"Node: \""
  (let* ((nodes (org-roam-node-read--completions filter-fn sort-fn))
         (prompt (or prompt "Node: "))
         (node (completing-read
                prompt
                (lambda (string pred action)
                  (if (eq action 'metadata)
                      `(metadata
                        ;; Preserve sorting in the completion UI if a sort-fn is used
                        ,@(when sort-fn
                            '((display-sort-function . identity)
                              (cycle-sort-function . identity)))
                        (annotation-function
                         . ,(lambda (title)
                              (funcall org-roam-node-annotation-function
                                       (get-text-property 0 'node title))))
                        (category . org-roam-node))
                    (complete-with-action action nodes string pred)))
                nil require-match initial-input 'org-roam-node-history)))
    (or (cdr (assoc node nodes))
        (org-roam-node-create :title node))))