[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: |
Sat, 10 Jun 2023 16:20:48 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 |
On 2023-06-09 23:48, uzibalqa wrote:
I have seen that since Emacs 24.1 one does not need the intermediate
'turn-on-foo-mode'
style functions when using hooks.
Does this apply to all modes, including minor modes ?
And thusly one can write
(add-hook 'emacs-lisp-mode-hook #'foo-minor-mode)
foo-minor-mode is just a function, so it is called when hook executes. Any other modes
that are turned on via a single function call will also "work".
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.
--
Best regards,
Platon Pronko
PGP 2A62D77A7A2CB94E
Re: add-hook without need for intermediate functions,
Platon Pronko <=