[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is it a good idea to use `add-hook' and `remove-hook' in a minor mod
From: |
mbork |
Subject: |
Re: Is it a good idea to use `add-hook' and `remove-hook' in a minor mode? |
Date: |
Thu, 22 May 2025 19:04:59 +0200 |
On 2025-05-22, at 12:52, Michael Heerdegen via Users list for the GNU Emacs
text editor <help-gnu-emacs@gnu.org> wrote:
> mbork@mbork.pl writes:
>
>> Hi all,
>>
>> I'd like to define a minor mode which enables me to use ElDoc to show
>> some information about the thing at point. Is it a good practice to use
>> `add-hook' and `remove-hook' in its definition to add/remove my function
>> to/from `eldoc-documentation-functions'? AFAIU, hooks are usually to be
>> used by the user and not modified by a mode.
>
> For such things it's ok - normal practice.
Thanks!
> Instead of removing your function when the mode is turned off you can
> also make your function test whether the mode is on or off, and keep it
> always installed. Sometimes this is even necessary to handle different
> buffers with different states (of the mode).
Thanks again - I did not think about it. I'll probably not use this
approach in my current project, but I agree, this is something worth
keeping in mind.
Best,
--
Marcin Borkowski
https://mbork.pl
https://crimsonelevendelightpetrichor.net/