Support 0 width entries in org-roam-node-display-template
#1775
Description
Brief Abstract
I'd like you to be able to hide entries in org-roam-node-display-template
by setting their width to 0. This allows us to still search based on them but prevents them taking up screen space.
Long Description
Before org-roam-v2 used to attach the tags of a node to the formatted entry with the display none property so that even if the tags weren't in org-roam-node-display-template
you could still search with them in completing-read. Recent changes seem to have invalidated this feature so I'd like org-roam to support it directly.
Here's is what my configuration for org-roam display-template currently is.
(use-package org-roam
:custom
(org-roam-node-display-template "${title}")
(org-roam-node-annotation-function #'org-roam-annotate-tag+)
:commands (org-roam-annotate-tag+)
:config
(defun org-roam-annotate-tag+ (node)
(let ((tags (org-roam-node-read--tags-to-str (org-roam-node-tags node))))
(unless (string-empty-p tags)
(concat
" "
(propertize " " 'display `(space :align-to (- right ,(+ 1 (length tags)))))
tags)))))
Because I already display tags using org-roam annotation function I don't want to have switch to using the template instead so I'd rather just attach the tags after the node title I.E. (setq org-roam-node-display-template "${title} ${tags:0}")
Proposed Implementation (if any)
diff -u --label /home/mohkale/.cache/emacs/straight/repos/org-roam/org-roam-node.el --label \#\<buffer\ org-roam-node.el\> /home/mohkale/.cache/emacs/straight/repos/org-roam/org-roam-node.el /tmp/buffer-content-nffqoX
--- /home/mohkale/.cache/emacs/straight/repos/org-roam/org-roam-node.el
+++ #<buffer org-roam-node.el>
@@ -485,7 +485,7 @@
(setq field-width (string-to-number field-width))
(let ((display-string (truncate-string-to-width
field-value
- (if (> field-width 0)
+ (if (>= field-width 0)
field-width
(- width (cdr fmt)))
0 ?\s)))
Please check the following:
- No similar feature requests