bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ignacio Casso
Subject: bug#54399: 27.2; Problems with (let ((custom-variable ...)) (autoload-function ...))
Date: Fri, 18 Mar 2022 10:38:45 +0100
User-agent: mu4e 1.6.10; emacs 29.0.50

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Michael Heerdegen <michael_heerdegen@web.de> writes:
>
>> 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 <monnier@iro.umontreal.ca> Fri Aug 2 17:16:33 2013 -0400
>
> Ah, newfangled code.  😀
>
>> 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.
>
> Right.

I think custom.el already uses `set-default-toplevel-value' where
appropriate by default. So my request is (1) to correct the docstrings
in custom.el to reflect so, so that users know to use it instead of
`set-default', and (2) Add some warnings somewhere, although I'm not
sure where.

I personally can not think of a single case in which someone would want
to use `set-default' instead of `set-default-toplevel-value'. If I
understand them correctly, they both do the same outside a let binding,
and I don't see why someone would want the `set-default' behavior inside
the let binding. In fact, I guess most people assume that `set-default'
behaves like `set-default-toplevel-value' (I did at least).

So I would at least talk about this in the docstrings of `set-default',
and also `default-value' and `default-boundp' which suffer the same
problem. In fact, now that I see it, the docstring of the later is just
wrong. The others just don't mention let bindings and only talk about
buffer-local bindings, but that one explicitly says that the function
can be used to know if a variable has a non-void value outside of a
let-binding, and with dynamic binding that doesn't work (see snippet
below).

  (setq lexical-binding nil)
  (let ((another-fresh-var 1))
    (default-boundp 'another-fresh-var)) ;; I expect nil, it returns t





reply via email to

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