[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Checking in Lisp if a given symbol has its original value
From: |
Drew Adams |
Subject: |
RE: Checking in Lisp if a given symbol has its original value |
Date: |
Tue, 31 Mar 2020 08:36:49 -0700 (PDT) |
> What’s the canonical way of checking if a given symbol has its
> original value, as reported by ‘describe-variable’?
> I’ve come up with:
> (defun standard-value-p (symbol)
> "Return non-nil if SYMBOL has its original value."
> (equal (eval (car (get symbol 'standard-value)))
> symbol))
That's only for user options, aka customizable variables,
aka variables defined with defcustom. See the Elisp
manual, node Standard Properties.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Properties.html
There's no way to check other variables, in general.
For any given variable whose creation you control or
monitor, you can of course record its initial value
in some way.
You can also use function `add-variable-watcher' to
monitor changes to a variable's value. But again, you
would want to do this from the outset, when it is
created. See the Elisp manual, node Watching Variables.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Watching-Variables.html