[Top][All Lists]

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

Re: minor-mode hook not run

From: Stefan Monnier
Subject: Re: minor-mode hook not run
Date: Thu, 22 Mar 2018 09:52:00 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>>>      (add-hook 'foo-mode-hook 'foo-load-abc nil t)
>> Adding elements to one's own hook here definitely deserve a "bug ugly
>> hack" comment explaining why you'd want to do it that way.
> Hmm, not sure if I understand that part.

I'm saying that adding to <FOO>-mode-hook from within the body of
<FOO>-mode is weird.

Instead of

    (define-minor-mode foo-mode
      (add-hook 'foo-mode-hook #'blabla nil t)

why not do the more natural:

    (define-minor-mode foo-mode

The "big ugly hack" comment should explain why the `add-hook` version
is needed.

> Purpose is a generic key for related commands:
> For example to start a REPL, haskell-mode calls
> ‘haskell-interactive-switch’, python.el calls ‘run-python’,
> python-mode.el ‘py-shell’ etc.
> Instead of remembering different keys and change them maybe at several
> locations, a unified command ‘gk-repl’ is provided, whose key-binding
> should DTRT in all modes.

I don't see how this explains why you need to go through foo-mode-hook
rather than calling the function directly.


reply via email to

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