This is usually not possible (Emacs does not remember the original value), but there are some exceptions.
defcustom variables
Variables defined using defcustom and changed using the configuration system receive the initial value, the saved value, and the configured, but not yet saved value as properties:
(defcustom foo 0 "testing") (custom-set-variables '(foo 1)) (setq foo 2) (customize-mark-as-set 'foo) (setq foo 3) (car (get 'foo 'standard-value)) ;; evaluates to 0 (car (get 'foo 'saved-value)) ;; evaluates to 1 (car (get 'foo 'customized-value)) ;; evaluates to 2 foo ;; evaluates to 3
See the section Defining configuration variables in the elisp manual, in particular the discussion of the documentation for the custom-reevaluate-setting function above.
buffer-local variables
Buffered local variables have a default value (global) and a local buffer value, which may differ from the global value. You can use the default-value function to get the default-value :
(setq indent-tabs-mode nil) (default-value 'indent-tabs-mode) ;; evaluates to t
However, you can change the default value, and Emacs will not remember the original default value:
(set-default 'indent-tabs-mode nil) (default-value 'indent-tabs-mode) ;; evaluates to nil
For more information, see Introduction to Buffer-Local Variables in the elisp manual.
source share