mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
add org-roam-node-annotation-function
cc @nobiot
This commit is contained in:
36
org-roam.el
36
org-roam.el
@ -608,6 +608,10 @@ is the `org-roam-node'."
|
|||||||
(propertize alias 'invisible t))
|
(propertize alias 'invisible t))
|
||||||
node)))))
|
node)))))
|
||||||
|
|
||||||
|
(defcustom org-roam-node-annotation-function #'org-roam-node--annotation
|
||||||
|
"The function used to return annotations in the minibuffer for Org-roam nodes.
|
||||||
|
This function takes a single argument NODE, which is an `org-roam-node' construct.")
|
||||||
|
|
||||||
(defun org-roam-node-read (&optional initial-input filter-fn require-match)
|
(defun org-roam-node-read (&optional initial-input filter-fn require-match)
|
||||||
"Read and return an `org-roam-node'.
|
"Read and return an `org-roam-node'.
|
||||||
INITIAL-INPUT is the initial prompt value.
|
INITIAL-INPUT is the initial prompt value.
|
||||||
@ -615,26 +619,24 @@ FILTER-FN is a function applied to the completion list.
|
|||||||
If REQUIRE-MATCH, require returning a match."
|
If REQUIRE-MATCH, require returning a match."
|
||||||
(let* ((nodes (org-roam-node--completions))
|
(let* ((nodes (org-roam-node--completions))
|
||||||
(nodes (funcall (or filter-fn #'identity) nodes))
|
(nodes (funcall (or filter-fn #'identity) nodes))
|
||||||
(node (completing-read "Node: "
|
(node (completing-read
|
||||||
(lambda (string pred action)
|
"Node: "
|
||||||
(if (eq action 'metadata)
|
(lambda (string pred action)
|
||||||
'(metadata
|
(if (eq action 'metadata)
|
||||||
(annotation-function . org-roam-node--annotation)
|
'(metadata
|
||||||
(category . org-roam-node))
|
(annotation-function . (lambda (title)
|
||||||
(complete-with-action action nodes string pred)))
|
(funcall org-roam-node-annotation-function
|
||||||
nil require-match initial-input)))
|
(get-text-property 0 'node node-title))))
|
||||||
|
(category . org-roam-node))
|
||||||
|
(complete-with-action action nodes string pred)))
|
||||||
|
nil require-match initial-input)))
|
||||||
(or (cdr (assoc node nodes))
|
(or (cdr (assoc node nodes))
|
||||||
(org-roam-node-create :title node))))
|
(org-roam-node-create :title node))))
|
||||||
|
|
||||||
(defun org-roam-node--annotation (_node-title)
|
(defun org-roam-node--annotation (_node)
|
||||||
"?"
|
"Dummy function.
|
||||||
;; TODO: think about what to do with this
|
Returns empty string for annotations."
|
||||||
""
|
"")
|
||||||
;; (let* ((node (get-text-property 0 'node node-title))
|
|
||||||
;; (tags (org-roam-node-tags node)))
|
|
||||||
;; (when tags
|
|
||||||
;; (format " (%s)" (string-join tags ", "))))
|
|
||||||
)
|
|
||||||
|
|
||||||
(defun org-roam-preview-visit (file point &optional other-window)
|
(defun org-roam-preview-visit (file point &optional other-window)
|
||||||
"Visit FILE at POINT.
|
"Visit FILE at POINT.
|
||||||
|
Reference in New Issue
Block a user