[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about defcustom and load-history
From: |
Tassilo Horn |
Subject: |
Re: Question about defcustom and load-history |
Date: |
Sun, 31 Mar 2019 09:13:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Mauro Aranda <maurooaranda@gmail.com> writes:
Hi Mauro,
> I noticed that for files that define customizable variables, there's a
> duplicate entry for each one of them. However, symbols defined with
> 'defvar'
> appear only once. Does anybody know why is that?
I'm not sure but I'd suspect this code in the end of
`custom-declare-variable'.
--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'.
I wonder how you could have a non-default-bound custom variable anyway?
Maybe using something like
(defvar foo)
(defcustom foo nil ...)
?
Anyway, I have no clue if your observation is itensional or
accidentally...
Bye,
Tassilo