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: Stefan Monnier
Subject: Re: Question about defcustom and load-history
Date: Sun, 31 Mar 2019 04:03:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> --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]