[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: |
Pyromania |
Subject: |
Re: Is it a good idea to use `add-hook' and `remove-hook' in a minor mode? |
Date: |
Sun, 25 May 2025 03:21:26 +0330 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.1 (x86_64-pc-linux-gnu) |
On Thu, May 22 2025, mbork@mbork.pl wrote:
> 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.
Well, most Emacsites already know how to change hook variables.
I think, a minor mode which manipulates other minor/major modes’ hooks
may sound intrusive. However, ‘eldoc-documentation-functions’ is not
a normal hook, right? In its doc-string, it is said:
“Finally, major modes should modify this hook locally, for
example:
(add-hook 'eldoc-documentation-functions #'foo-mode-eldoc nil t)
so that the global value (i.e. the default value of the hook) is taken
into account if the major mode specific function does not return
any documentation.”
So, it can be manipulated, by other than users.
> Otoh, giving the user a minor mode seems more user-friendly than just
> telling them to manually add a function to a hook. Wdyt?
Like function A which will add function B to the buffer-local value of
‘eldoc-documentation-functions’, and putting the A in a major mode’s
hook?
--
English is not my native/mother language. While I can read and
understand English fluently, I have problems expressing my thoughts
in it. Please, bear with me. Sincerely, Pyromania.
PGP fingerprint = 2B24 291E 0637 4D2E 0D14 9EFC D7B3 10D4 5C9D 5892
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments