Function: org-roam-complete-link-at-point

org-roam-complete-link-at-point is a byte-compiled function defined in org-roam-node.el.

Signature

(org-roam-complete-link-at-point)

Documentation

Complete inside link brackets to an existing Org-roam node.

Targets [[$title]] and [[roam:$title]] links. [[id:$id][$description]] links are not targeted to allow for changing link descriptions without changing the target node.

Source Code

;; Defined in ~/.emacs.d/elpa/org-roam-20260425.1623/org-roam-node.el
(defun org-roam-complete-link-at-point ()
  "Complete inside link brackets to an existing Org-roam node.
Targets [[$title]] and [[roam:$title]] links. [[id:$id][$description]]
links are not targeted to allow for changing link descriptions without
changing the target node."
  (when-let* ((_ (org-in-regexp org-roam-bracket-completion-re 1))
              (uri-start (match-beginning 1))
              (title-start (match-beginning 2))
              (end (match-end 2))
              ;; don’t try to complete if point is in the delimiting brackets
              (_ (<= title-start (point) end))
              (_ (not (org-in-src-block-p))))
    (list title-start end
          (org-roam--get-titles)
          :exit-function
          (lambda (str &rest _)
            "Replace title inserted by completion with ID and title."
            (delete-region uri-start (point))
            (insert "id:"
                    (org-roam-node-id (org-roam-node-from-title-or-alias
                                       (substring-no-properties str)))
                    "][" str)
            ;; Move point after closing brackets
            (forward-char 2)))))