I have a minor mode called tematika-minor-mode. When I turn it on, I want to enable outline-minor-mode automatically. And turn it off when tematika-minor-mode is disabled.

  • Your question seems to be what I rewrote the title to be. If so, get rid of all of your code and just ask the question. Or if that's not your question, and you have a specific question about some part of your code, then show that part and ask that specific question. And if you have both questions then post them separately. Thx.
    – Drew
    Jun 8, 2023 at 16:22
  • Yes, it is about the title you wrote.
    – Dilna
    Jun 8, 2023 at 17:16
  • Then please remove all of the rest that is extraneous. If you have some specific question about some code, post that as a separate question. Thx.
    – Drew
    Jun 8, 2023 at 21:18
  • Your own question Activating a minor mode for outline-minor-mode for elisp files encapsulates this question. In the Answer, foo-mode and outline-minor-mode are both minor modes, and one mode is made to track the other in the exact way you're asking for here. (The difference between that question and this is only the interaction with emacs-lisp-mode which you don't need here.)
    – phils
    Jun 8, 2023 at 22:47
  • Looking at your edit history for this new question, it started out with a modified and buggy adaptation of the code from the earlier Answer, so I suggest that you review that Answer and your custom code together and make sure you have that part correct.
    – phils
    Jun 8, 2023 at 23:22

1 Answer 1


I'm assuming that tematika-minor-mode is a buffer-local minor mode, not a global minor mode.

Adapting my answer from your earlier related question: https://emacs.stackexchange.com/a/77495/454 you can do the following. The difference is that this time we're adding to the global value of the minor mode hook (because you don't care what kind of buffer the minor mode is being enabled in), whereas in the earlier question we were restricting the cases where we triggered the behaviour by using the buffer-local value of the minor mode hook (because you only wanted it if the minor mode was enabled in an elisp buffer).

(add-hook 'tematika-minor-mode-hook 'my-outline-toggle-with-tematika-minor-mode)

(defun my-outline-toggle-with-tematika-minor-mode ()
  "Toggle `outline-minor-mode' with `tematika-minor-mode' buffer-locally."
  (outline-minor-mode (if tematika-minor-mode 1 0)))

Or if tematika-minor-mode is your own custom code, you could simply update the mode definition:

(define-minor-mode tematika-minor-mode
  (if tematika-minor-mode
        (outline-minor-mode 1))
    (outline-minor-mode 0)))

  • T like the second version as it avoids the hook. I find using hooks somewhat complicated.
    – Dilna
    Jun 9, 2023 at 11:54
  • If you're writing custom code for your own use and you don't need to use a hook, then there's probably very little reason to consider doing so. Hooks are extremely useful, but for the most part they are for interacting with code written by other people.
    – phils
    Jun 9, 2023 at 12:21

Your Answer

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

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