Subject: bug#54399: 27.2; Problems with (let ((custom-variable ...)) (autoload-function ...))

From: Michael Heerdegen <[email-masked]>
Date: Fri, 18 Mar 2022 01:22:37 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Ignacio Casso <[email-masked]> writes:
>
> > Calling an autoload function under the following circumstances does not
> > always work as expected:
> >
> >   - the function uses a variable defined with defcustom in the same file
> >     as the function.
> >
> >   - the function is called inside a let form that binds that same
> >     variable.
>
> I don't think this is supported?  And it's not just with user options --
> normal variables will end up being unbound if you do this (unless this
> has been changed since I looked at this a decade ago).  And I think it's
> documented, too?  Or am I misremembering?  Anybody?

Hmm - I don't know much about the background, but wasn't
`set-default-toplevel-value' invented to make just that work?  See
commit

a104f656c8 Make defvar affect the default binding outside of any let.
Stefan Monnier <[email-masked]> Fri Aug 2 17:16:33 2013 -0400

AFAIU this bug report is a request to (1) correct some docstrings and
(2) use `set-default-toplevel-value' instead of `set-default' at more
places in custom.el to assign values, where appropriate.

Michael.