make tags searchable

This commit is contained in:
Jethro Kuan
2021-04-01 19:25:30 +08:00
parent 49541298ba
commit 3d61a76ecb

View File

@ -490,7 +490,7 @@ nodes."
node)) node))
(defcustom org-roam-node-display-template (defcustom org-roam-node-display-template
"${tags:10} ${title:48}" "${title:48} ${tags:10}"
"Configures display formatting for Org-roam node." "Configures display formatting for Org-roam node."
:group 'org-roam :group 'org-roam
:type 'string) :type 'string)
@ -498,10 +498,8 @@ nodes."
(defun org-roam-node--format-entry (node width) (defun org-roam-node--format-entry (node width)
"Formats NODE for display in the results list. "Formats NODE for display in the results list.
WIDTH is the width of the results list." WIDTH is the width of the results list."
(let* ((format (let ((format (org-roam--process-display-format org-roam-node-display-template)))
(org-roam--process-display-format org-roam-node-display-template))) (s-format (car format)
(s-format
(car format)
(lambda (field) (lambda (field)
(let* ((field (split-string field ":")) (let* ((field (split-string field ":"))
(field-name (car field)) (field-name (car field))
@ -511,6 +509,9 @@ WIDTH is the width of the results list."
(when (and (equal field-name "tags") (when (and (equal field-name "tags")
field-value) field-value)
(setq field-value (string-join field-value " "))) (setq field-value (string-join field-value " ")))
(when (and (equal field-name "file")
field-value)
(setq field-value (file-relative-name field-value org-roam-directory)))
(if (not field-width) (if (not field-width)
field-value field-value
(setq field-width (string-to-number field-width)) (setq field-width (string-to-number field-width))
@ -582,8 +583,10 @@ is the `org-roam-node'."
:file file :file file
:title title :title title
:point pos :point pos
:tags (gethash id tags-table)))) :tags (gethash id tags-table)))
(cons (propertize alias (tag-str (string-join (mapcar (lambda (s) (concat "#" s))
(org-roam-node-tags node)) " ")))
(cons (propertize (concat tag-str " " alias)
'node node 'node node
'display (org-roam-node--format-entry node (1- (frame-width)))) node))))) 'display (org-roam-node--format-entry node (1- (frame-width)))) node)))))