Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org-roam-tags-completion treats most org-tags-alist keywords as tags #2477

Open
lyndhurst opened this issue Oct 11, 2024 · 0 comments
Open
Labels
2. tags Issues about org tags

Comments

@lyndhurst
Copy link

Description

org-roam-tags-completion fetches tags from org-tags-alist when building the tags list. The problem is that most :keywords used by Tags hierarchy syntax are added to the completion list.

It seems the function author foresaw this edge case, but only handled the :newline keyword (see my attempt at adding the rest of those keywords at the bottom of this post).

Steps to Reproduce

  1. Add hierarchical tags to org-tags-alist like in the manual's example
(setq org-tag-alist '((:startgrouptag)
                      ("GTD")
                      (:grouptags)
                      ("Control")
                      ("Persp")
                      (:endgrouptag)
                      (:startgrouptag)
                      ("Control")
                      (:grouptags)
                      ("Context")
                      ("Task")
                      (:endgrouptag)))
  1. Call org-roam-tags-add

Expected Results

Keywords such as :grouptags should not appear in the tags completion list.

Actual Results

Keywords such as :grouptags do appear in the tags completion list.

Working proposition

(defun +org-roam-tag-completions ()
  "Return list of tags for completions within Org-roam."
  (let ((roam-tags (mapcar #'car (org-roam-db-query [:select :distinct [tag] :from tags])))
        (org-tags (cl-loop for tagg in org-tag-alist
                           nconc (pcase tagg
                                   ('(:newline)
                                    nil)
                                   ('(:grouptags)
                                    nil)
                                   ('(:startgrouptag)
                                    nil)
                                   ('(:endgrouptag)
                                    nil)
                                   (`(:startgroup . ,_)
                                    nil)
                                   (`(:endgroup . ,_)
                                    nil)
                                   (`(,tag . ,_)
                                    (list tag))
                                   (_ nil)))))
    (seq-uniq (append roam-tags org-tags))))
@Delapouite Delapouite added the 2. tags Issues about org tags label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. tags Issues about org tags
Projects
None yet
Development

No branches or pull requests

2 participants