0

Reading the org manual about setting global/per-file tags, I wonder if it is possible to use org-tag-persistent-alist AND per-file dynamic tags.

When using org-set-tags-command, I’d like to select from a list comprising both:

  1. the list of predefined tags in org-tag-persistent-alist
  2. the list of all the tags that are already in use in the current buffer (some of which might not be in the persistent alist). I don’t want to pre-define these tags using a #+TAGS keyword at file-level. I want the actual tags attached to some headline in the buffer.

The manual says:

If you have globally defined your preferred set of tags using the variable org-tag-alist, but would like to use a dynamic tag list in a specific file, add an empty ‘TAGS’ keyword to that file

And then it says:

If you have a preferred set of tags that you would like to use in every file, in addition to those defined on a per-file basis by ‘TAGS’ keyword, then you may specify a list of tags with the variable org-tag-persistent-alist.

I tried to combine both behaviors by putting an empty ’#+TAGS:’ keyword at the top of my file. But this still only gives me the tags in org-tag-persistent-alist. What would be the best way to add to this list, for completion, the tags already used in the buffer?

2
  • I don't think it's possible with the current code: see the code that calculates the completion table and note (l.12191) that or: org-current-tag-alist at that point is equal to org-tag-persistent-alist, so since that is non-nil, the call to org-get-buffer-tags is skipped. You'd need to rewrite the code.
    – NickD
    Nov 17 at 4:54
  • Thanks @NickD. You're right, looking at the code I'm now rather pessimistic. It would be overkill to override org-set-tags-command just for this. Perhaps what I'll do then is write a function that gets triggered on every save, to puts the result of (org-get-buffer-tags) in the #+TAGS: keyword. From there, the local buffer tags are added to the persistent ones, which is what I need.
    – Victor
    Nov 17 at 16:34

Your Answer

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

Browse other questions tagged or ask your own question.