Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
When you say the file has a certain tag, do you mean it contains at least one headline with a particular tag, or that the tag was specified with #FILETAGS:?
Also, it doesn’t precisely answer your question, but you can manage file-specific minor modes using file variables: see the very bottom of this documentation, which will also mention hooks which is probably the way to go if you want to implement the logic you’ve described.
You add to org-mode-hook a function that checks the file for the tag and, if it finds it, enables the minor mode: (defun check-tag-enable-minor-mode () (when (check-tag "foo") (foo-minor-mode 1))) and (add-hook 'org-mode-hook #'check-tag-enable-minor-mode). You still have to write the check-tag function and fix what minor mode you want to enable.
#FILETAGS:
?org-mode-hook
a function that checks the file for the tag and, if it finds it, enables the minor mode:(defun check-tag-enable-minor-mode () (when (check-tag "foo") (foo-minor-mode 1)))
and(add-hook 'org-mode-hook #'check-tag-enable-minor-mode)
. You still have to write thecheck-tag
function and fix what minor mode you want to enable.