2

In ~/.emacs I have the following:

(setq org-agenda-files (quote ("~/Documents/organize/org-mode/")))

In ~/D/o/o/ there are multiple files and I can cycle through them using C-,.

While adding content to a file, I can C-c C-q TAB, enter the first few characters and hit TAB again to autocomplete a tag. But this works ONLY for the tags in the current file. It ignores tags present in other agenda files.

How do I make tags available across agenda files?

2 Answers 2

2

Try setting the variable org-complete-tags-always-offer-all-agenda-tags to t (but maybe set it locally for capture buffers only). The doc strings says

"If non-nil, always offer completion for all tags of all agenda files. Instead of customizing this variable directly, you might want to set it locally for capture buffers, because there no list of tags in that file can be created dynamically (there are none).

(add-hook \='org-capture-mode-hook (lambda () (setq-local org-complete-tags-always-offer-all-agenda-tags t)))"

1
  • I seem to be runnnig out of luck here or may be, I did not grasp the answer correctly. Disadvantages of being new to Emacs. I added (setq-local org-complete-tags-always-offer-all-agenda-tags t) to ~/.emacs And hoped for the best. But no. It did not offer auto-completion for tags in other agenda files. Changing setq-local to setq also did not have any impact. Am I doing something wrong?
    – deshmukh
    Oct 26, 2017 at 4:35
3

I don't know if there's a way to make the completion list populate itself from other files, but one way is to define the "common" tags you want in an org-mode file of its own, then include that in the others.

e.g. a file called "tags.org":

#+TAGS: firsttag(f) secondtag(s)
#+TAGS: anothertag(a) evenmore(e)

The include that org file from your others, e.g. "myfile.org":

#+SETUPFILE: "tags.org"

* Heading
Normal org-mode contents.

The has an advantage (you keep the list of suggested tags smaller, documented and more consistent across your separate org-mode files), but the disadvantage that it won't "learn" those common tags unless you add them to that common tags file.

5
  • Thanks. That is an interesting and useful idea. But still I think if only Org Mode could source tags from ALL agenda files,it would be more elegant.
    – deshmukh
    Oct 25, 2017 at 15:08
  • 1
    You can customize org-tag-persistent-alist by hand. You could also write a function that gets all the tags from your agenda files and adds them to that list. You can also set org-tag-alist with the ones that you use most often and set fast-tag selection for them. See Setting tags for details.
    – NickD
    Oct 25, 2017 at 19:11
  • @deshmukh: why are you singling out agenda files here? Tags are useful for non-agenda org files (I have half a dozen agenda files and hundreds of non-agenda org files), so having a mechanism to get all the tags from agenda files is not particularly useful. But it could easily be done by writing the function I suggested in my previous comment.
    – NickD
    Oct 25, 2017 at 19:15
  • I guess people disagree with me about the usefulness of having such a mechanism for agenda files, because in looking at the code I found a variable that seems to enable exactly this behaviour :-) Added that info as as an answer, but I have not tried it out.
    – NickD
    Oct 25, 2017 at 23:21
  • @Nick I was singling out agenda files because agenda looks at every file defined as agenda file to produce the agenda. If it can look at TODO, etc. it should also look at the tags or even other properties, etc. IMHO.
    – deshmukh
    Oct 26, 2017 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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