help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Hooks in minor modes


From: Stefan Monnier
Subject: Re: Hooks in minor modes
Date: Fri, 30 Apr 2021 01:17:21 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> That would mean that simply calling
>
>   (require 'my-minor-mode)
>
> would not automatically activate the functionality provided by
> 'my-minor-mode',

Of course not.

> unless the user specifically calls another function called
> 'activate-my-minor-mode'.

Don't `require`, just call the function *instead*.
BTW, the activation function is the minor mode function, so to
activate a global minor mode, just add the following in your .emacs:

    (my-minor-mode 1)

or alternatively activate it via Custom.
No need for a separate `activate-my-minor-mode`.

> Quite suitable for new users because they can simply call just
> the following two commands.
>
>   (require 'my-minor-mode)
>   (activate-my-minor-mode)

No, just

    (my-minor-mode 1)

If the package is properly installed (e.g. via `M-x package-install`),
the function should be marked as autoloaded (if not, send a bug report
to the package maintainer), so you don't need to `require` before
calling the function.


        Stefan




reply via email to

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