0

org-tag-alist will list tags exactly as they are defined in the .emacs or init file, e.g.

((:startgroup . nil) ("@computer" . ?c) ("@phone" . ?p) ("@home" . ?h) (:endgroup . nil))

Is there a variable that "cleans" this format so that the tags are easily accessible as a list?

("@computer" "@phone" "@home")

This is similar to how org-done-keywords will parse (though it'll only take the done keywords) the much messier org-todo-keywords (which is a list of sequences).

  • How about using the function org-global-tags-completion-table? See also the function org-get-buffer-tags. – lawlist Sep 26 '16 at 17:28
  • Those seem to be close, but there seems to be extra stuff for inherited tags, .e.g ((#("parent" 0 2 (inherited t))) ("@phone") ...). I'd guess one would still have to write a function to parse the tags from this format as a list? – wiuah Sep 26 '16 at 17:45
  • Also, a bit offtopic, but what does the # mean in front of the list for the inherited tag? Is it equivalent to the same list without the hash sign? – wiuah Sep 26 '16 at 17:47
  • I got the two functions from what org-tags-view uses as it relates to potential tag completions, and I suspect there are some additional functions already in existence that further parse the results from the functions mentioned in the first comment. Once you find them, that should save you the trouble of writing your own function. I don't have any inherited tags in my setup, so I couldn't answer that question without guessing about things like arrays and text properties -- sorry. – lawlist Sep 26 '16 at 17:52
1

I couldn't find anything else in org-agenda.el or org.el that stored the tags in the way I wanted, but it turned out it was relatively easy to write the function to do so.

The #(...) format was apparently just a text property, so the function was as simple as (as long as you don't mind the property still there in the list)...

(defun org-get-all-tags-list ()
    (interactive)        
    (mapcar 'car (org-global-tags-completion-table)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.