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

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

Re: Question about defcustom and load-history


From: Mauro Aranda
Subject: Re: Question about defcustom and load-history
Date: Sun, 31 Mar 2019 09:50:15 -0300

>> In the falsy case, i.e., when the variable has an initial default value,
>> a `defvar' form is evaled resulting in one entry, and then the symbol is
>> pushed again to `current-load-list' from where it probably gets to
>> `load-history'.
>
> Indeed the manual handling of current-load-list should likely be moved
> to the true branch of the `if`.

Hello Tassilo and Stefan,

Thank you both for your answers.

After reading Tassilo explanation, I went on to have a look at
'custom.el' and found out that if a custom variable has
'custom-initialize-default' as the :initialize function, a 'defvar' is
evaled too.  So, those custom variables appear thrice in 'load-history'.

For example, loading 'ansi-color', you'll see
'ansi-color-faces-vector' and 'ansi-color-names-vector' triplicated.

This doesn't look intentional to me.  Should I file a bug report?

Best regards,
Mauro.

El dom., 31 mar. 2019 a las 5:05, Stefan Monnier (<address@hidden>)
escribió:

> > --8<---------------cut here---------------start------------->8---
> >   ;; Use defvar to set the docstring as well as the special-variable-p
> flag.
> >   ;; FIXME: We should reproduce more of `defvar's behavior, such as the
> warning
> >   ;; when the var is currently let-bound.
> >   (if (not (default-boundp symbol))
> >       ;; Don't use defvar to avoid setting a default-value when
> undesired.
> >       (when doc (put symbol 'variable-documentation doc))
> >     (eval `(defvar ,symbol nil ,@(when doc (list doc)))))
> >   (push symbol current-load-list)
> >   (run-hooks 'custom-define-hook)
> >   symbol)
> > --8<---------------cut here---------------end--------------->8---
> >
> > In the falsy case, i.e., when the variable has an initial default value,
> > a `defvar' form is evaled resulting in one entry, and then the symbol is
> > pushed again to `current-load-list' from where it probably gets to
> > `load-history'.
>
> Indeed the manual handling of current-load-list should likely be moved
> to the true branch of the `if`.
>
> > I wonder how you could have a non-default-bound custom variable anyway?
>
> By using appropriate :set and :get functions that store&fetch the value
> from elsewhere (e.g. another variable, a frame-parameter, a file, some
> symbol property, younameit).
>
> I can't seem to find a case where we do that, tho, so maybe we should
> declare such uses invalid.
>
>
>         Stefan
>
>
>


reply via email to

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