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: steve-humphreys
Subject: Re: Hooks in minor modes
Date: Fri, 30 Apr 2021 06:12:19 +0200

That would mean that simply calling

  (require 'my-minor-mode)

would not automatically activate the functionality provided by
'my-minor-mode', unless the user specifically calls another
function called 'activate-my-minor-mode'.

'my-minor-mode' is a top-level mode that calls other elisp files
for accessing a range of functionalities (e.g. other minor-modes
for various programming languages and additional utilities for
colour highlighting, traversing text, auto-completion and so on).

Quite suitable for new users because they can simply call just
the following two commands.

  (require 'my-minor-mode)
  (activate-my-minor-mode)



> Sent: Friday, April 30, 2021 at 3:31 PM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Hooks in minor modes
>
> > Is it acceptable to set mode hooks in a minor mode so that the minor
> > mode is available by default, rather than requiring the user to include
> >
> >   (add-hook 'texinfo-mode-hook 'my-minor-mode))
>
> Depends when you do that and it likely depends whom you ask.
>
> The convention that we strongly encourage to follow is that *loading* an
> ELisp file should not noticeably change Emacs's behavior (among other
> things, because files may be loaded without the user's explicit
> request).  So doing such an `add-hook` at the top-level of your file
> would probably not be considered as acceptable from that point of view
> (unless activating `my-minor-mode` by default has no visible effect,
> which is definitely possible but unusual).
>
>
>         Stefan
>
>
>



reply via email to

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