[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: |
Michael Heerdegen |
Subject: |
Re: Is it a good idea to use `add-hook' and `remove-hook' in a minor mode? |
Date: |
Thu, 22 May 2025 12:52:08 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.
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).
Michael.