help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add-hook without need for intermediate functions


From: Platon Pronko
Subject: Re: add-hook without need for intermediate functions
Date: Sun, 11 Jun 2023 09:37:04 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2

However note that this won't work for your use-case (from previous thread) - 
hook is called both when mode is turned on, and when it is turned off. So in 
your code snippet foo-minor-mode will be turned on when emacs-lisp-mode is 
turned off, which is probably not something you would want. - Platon Pronko

What would one do then, remove the hook at some point.  Would you show me an 
example on how to handle the situation
properly.


Here's an example I've sent in one of previous emails:

(defun tematika--toggle-outline-mode ()
  (if tematika-minor-mode
      (outline-minor-mode)
    (outline-minor-mode -1)))
(add-hook 'tematika-minor-mode-hook 'tematika--toggle-outline-mode)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]