mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
(node) add optional NOCASE parameter to org-roam-node-from-title-or-alias (#2403)
* (node) add NOCASE parameter to org-roam-node-from-title-or-alias * fixed docstring of org-roam-node-from-title-or-alias.
This commit is contained in:
@ -256,18 +256,22 @@ Return nil if a node with ID does not exist."
|
|||||||
id)) 0)
|
id)) 0)
|
||||||
(org-roam-populate (org-roam-node-create :id id))))
|
(org-roam-populate (org-roam-node-create :id id))))
|
||||||
|
|
||||||
(defun org-roam-node-from-title-or-alias (s)
|
(defun org-roam-node-from-title-or-alias (s &optional nocase)
|
||||||
"Return an `org-roam-node' for the node with title or alias S.
|
"Return an `org-roam-node' for the node with title or alias S.
|
||||||
Return nil if the node does not exist.
|
Return nil if the node does not exist.
|
||||||
Throw an error if multiple choices exist."
|
Throw an error if multiple choices exist.
|
||||||
|
|
||||||
|
If NOCASE is non-nil, the query is case insensitive. It is case sensitive otherwise."
|
||||||
(let ((matches (seq-uniq
|
(let ((matches (seq-uniq
|
||||||
(append
|
(append
|
||||||
(org-roam-db-query [:select [id] :from nodes
|
(org-roam-db-query (vconcat [:select [id] :from nodes
|
||||||
:where (= title $s1)]
|
:where (= title $s1)]
|
||||||
s)
|
(if nocase [ :collate NOCASE ]))
|
||||||
(org-roam-db-query [:select [node-id] :from aliases
|
s)
|
||||||
:where (= alias $s1)]
|
(org-roam-db-query (vconcat [:select [node-id] :from aliases
|
||||||
s)))))
|
:where (= alias $s1)]
|
||||||
|
(if nocase [ :collate NOCASE ]))
|
||||||
|
s)))))
|
||||||
(cond
|
(cond
|
||||||
((seq-empty-p matches)
|
((seq-empty-p matches)
|
||||||
nil)
|
nil)
|
||||||
|
Reference in New Issue
Block a user