Subject: Re: bug#59384: 29.0.50; Visiting files in Emacs Git pops up "unsafe variable" prompt

From: Stefan Monnier <[email-masked]>
Date: Sat, 19 Nov 2022 17:38:35 -0500

>> From: Juri Linkov <[email-masked]>
>> Cc: [email-masked]
>> Date: Sat, 19 Nov 2022 20:49:50 +0200
>> 
>> >       vc-git-annotate-switches : "-w"
>> >       bug-reference-url-format : "https://debbugs.gnu.org/%s"
>> >       diff-add-log-use-relative-names : t
>> >     * vc-prepare-patches-separately : nil
>> >       c-file-style : "GNU"
>> >       c-noise-macro-names : ("INLINE" "NO_INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED" "UNINIT" "CALLBACK" "ALIGN_STACK")
>> >       electric-quote-comment : nil
>> >       electric-quote-string : nil
>> >       indent-tabs-mode : t
>> >       mode : bug-reference-prog
>> >
>> > The problem here AFAIU is that vc-prepare-patches-separately and its
>> > 'safep' property is not known to Emacs until vc.el is loaded.
>> >
>> > One way of fixing this would be to autoload the defcustom of this
>> > variable, but AFAIR this is sometimes frowned upon?
>> 
>> Is there a standard solution already worked out for existing
>> variables like `vc-git-annotate-switches'?
>
> Maybe it is, but if so, I'm not aware of it.
>
> Stefan, any advice?

AFAIK the standard solution is one of:

- try to arrange for the relevant package to be loaded before
  hack-local-variables does its thing.  That often works for
  major-mode dependent variables, where we try and load the
  major mode early enough.  For the above case I can't see a good way to
  use this approach.

- autoload the (put '<VAR> 'safe-local-variable ...)

Autoloading the `defcustom` is a *bad* idea.

        Stefan