bug#36618: 26.2; Misnamed `*-hooks' variables

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#36618: 26.2; Misnamed `*-hooks' variables

Drew Adams
The following variable names end in `-hooks', instead of `-hook' or
`-functions' (there may be more - just noticed these in one of my
sessions):

bookmark-exit-hooks                    (OBS)
delay-mode-hooks                       (Bool)
delayed-mode-hooks                     XXX
ediff-before-session-group-setup-hooks XXX
find-file-hooks                        (OBS)
find-file-not-found-hooks              (OBS)
inhibit-modification-hooks             (Bool)
inhibit-point-motion-hooks             (Bool)
inhibit-startup-hooks                  (Bool)
local-write-file-hooks                 (OBS)
mail-yank-hooks                        (OBS)
recentf-used-hooks                     XXX
unload-feature-special-hooks           (aliased)
write-contents-hooks                   (OBS)
write-file-hooks                       (OBS)

Those marked "OBS" are declared to be obsolete.  Nothing need be done
now for those.

I suggest that `unload-feature-special-hooks', which is already aliased
to `load-hist-hook-functions', be made obsolete.

The ones marked "Bool" are not hooks.  They are Boolean values
indicating whether some behavior associated with particular hooks takes
place - e.g., whether mode hooks should be delayed.  I suggest that
these be renamed to indicate this.  We could, for example, follow the
convention (still encouraged by RMS) of adding the suffix `-flag'.

The ones marked "XXX" are also not hooks.  They're lists of hooks.  I
suggest they be re-suffixed `-functions' and the old names declared
obsolete.

[A code comment for `ediff-before-session-group-setup-hooks' says this:
 ;FIXME: Bad name (should be -hook or -functions) and never run??]

There's some ambiguity in the use of suffix `-functions'.  (elisp)
`Standard Hooks' says that it _usually_ means an abnormal hook.  But it
seems that sometimes it means just a list of hooks that some code will
do something with (not necessarily invoke them as abnormal hooks).

If we wanted to use a different suffix, to distinguish actual abnormal
hooks from such other lists of hooks (normal and abnormal) then those
marked "XXX" here fall into the latter group.


In GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
 of 2019-04-13
Repository revision: fd1b34bfba8f3f6298df47c8e10b61530426f749
Windowing system distributor `Microsoft Corp.', version 10.0.17134
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''



Reply | Threaded
Open this post in threaded view
|

bug#36618: 26.2; Misnamed `*-hooks' variables

Lars Ingebrigtsen
Drew Adams <[hidden email]> writes:

> The following variable names end in `-hooks', instead of `-hook' or
> `-functions' (there may be more - just noticed these in one of my
> sessions):
>
> bookmark-exit-hooks                    (OBS)

As you say, there's nothing to be done about obsolete -hooks variables.

> delay-mode-hooks                       (Bool)

These bool variables have logical names -- they say whether to do
something or other about the hooks, so I don't think they should change
names.

> delayed-mode-hooks                     XXX

That's not really a -hook variable, but list of hook variables to run,
so it's fine:

(defvar-local delayed-mode-hooks nil
  "List of delayed mode hooks waiting to be run.")

> ediff-before-session-group-setup-hooks XXX

This is a variable that's never used, apparently?  I'll just mark it as
obsolete.

> recentf-used-hooks                     XXX

It's a list of hooks, not a hook, so has a correct name.

> unload-feature-special-hooks           (aliased)

Same.

Nothing to be done for the rest; closing.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#36618: 26.2; Misnamed `*-hooks' variables

Drew Adams
> > The following variable names end in `-hooks', instead of `-hook' or
> > `-functions' (there may be more - just noticed these in one of my
> > sessions):
> >
> > bookmark-exit-hooks                    (OBS)
>
> As you say, there's nothing to be done about obsolete -hooks variables.
>
> > delay-mode-hooks                       (Bool)
>
> These bool variables have logical names -- they say whether to do
> something or other about the hooks, so I don't think they should change
> names.
>
> > delayed-mode-hooks                     XXX
>
> That's not really a -hook variable, but list of hook variables to run,
> so it's fine:
>
> (defvar-local delayed-mode-hooks nil
>   "List of delayed mode hooks waiting to be run.")
>
> > ediff-before-session-group-setup-hooks XXX
>
> This is a variable that's never used, apparently?  I'll just mark it as
> obsolete.
>
> > recentf-used-hooks                     XXX
>
> It's a list of hooks, not a hook, so has a correct name.
>
> > unload-feature-special-hooks           (aliased)
>
> Same.
>
> Nothing to be done for the rest; closing.

IOW, "won't fix".

Lists of hooks are not hooks.  Boolean variables that
control behavior of hooks are not hooks.

A user looking for hooks will fall upon these misleading
names of non-hooks using completion (e.g. substring).

We can help her or mislead her.  Currently we throw noise
in her face.  Not much noise - there are only a few such
anomalies cited here.



Reply | Threaded
Open this post in threaded view
|

bug#36618: 26.2; Misnamed `*-hooks' variables

Eli Zaretskii
> Date: Sat, 13 Jul 2019 10:23:23 -0700 (PDT)
> From: Drew Adams <[hidden email]>
> Cc: [hidden email]
>
> A user looking for hooks will fall upon these misleading
> names of non-hooks using completion (e.g. substring).

Not necessarily: we have a section in the ELisp manual that lists all
the standard hooks.