Subject: bug#13780: 24.2; Making find-file-hook customizable seems to cause troublle

From: Stefan Kangas <[email-masked]>
Date: Tue, 24 Nov 2020 18:18:58 -0800

Eli Zaretskii <[email-masked]> writes:

>> Stefan Monnier <[email-masked]> writes:
>>
>> >>> So until Custom ...blabla... I think it's better to use defcustom for
>> >>> hooks very sparingly, i.e. only for those hook we can reasonably
>> >>> expect will only be modified by the user's customization.
>> >> So do you think the existing customization ability for find-file-hook
>> >> should be removed? Or at least some kind of warning attached?
>> >
>> > Yes,
>>
>> So how about the attached?
>
> That's a backward-incompatible change, isn't it?  Now a user who types
> "M-x set-variable RET" will not be able to set this variable, it can
> only be set via "M-:".  Do we have a serious enough reason for that?

It will be a backward-incompatible change, yes.

The reasons are the ones given in the discussion of this bug.
I think they make sense, FWIW:

Reuben Thomas <[email-masked]> writes:

> I just spent a while trying to work out why a third-party mode I had
> just installed was not automatically added to my find-file-hook, even
> though the mode's file calls add-hook when it is loaded, and I took care
> to ensure the mode was autoloaded. I discovered that the problem was
> that the mode was loaded by my customization file, custom.el, but later,
> the same file overwrote find-file-hook, because I had customized
> find-file-hook.
>
> I found that the reason for the customization was to get flymake-mode
> automatically activated; I've filed a separate issue about this
> (#13779). After removing the customization, my find-file-hook was set up
> correctly (except for flymake-mode).
>
> The real problem here is that find-file-hook is clearly meant to be
> customizable (there is even a check box for auto-indent in its
> customization dialog), yet customizing it seems to cause a race
> condition where depending in what order files are autoloaded, hooks may
> fail to be added properly to find-file-hook.

Stefan Monnier <[email-masked]> writes:

>>> So until Custom is fixed to actually properly handle customisation of
>>> hooks (e.g. by storing "add functions foo, bar, and baz" rather than
>>> "ignore current value and just set it to (foo bar baz)").
>> This sentence seems to be missing its main clause…
>
> That's not just an appearance.  Its main clause is:
>
>    So until Custom ...blabla... I think it's better to use defcustom for
>    hooks very sparingly, i.e. only for those hook we can reasonably
>    expect will only be modified by the user's customization.