1

Is it possible to set a minor mode only when viewing org-mode files with a certain tag? If so, how could I achieve this?

3
  • 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:? Commented Mar 15, 2022 at 3:56
  • 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. Commented Mar 15, 2022 at 3:59
  • 2
    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.
    – NickD
    Commented Mar 15, 2022 at 4:02

0

Your Answer

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

Browse other questions tagged or ask your own question.