Take the 2-minute tour ×
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It's 100% free, no registration required.

Is there a (quick) way of resetting a variable to its default value (as defined in some .el file) after it has been modified? e.g. via commands in the .emacs file, without having to restart emacs.

Example: Set ispell-tex-skip-alists to the value as defined in `ispell.el' after modification.

share|improve this question
2  
Related: emacs.stackexchange.com/q/3022/50. (I've edited your title to not be a duplicate of it). –  Malabarba 7 hours ago

2 Answers 2

No. Non-custom variables need not even have a default value.

Except if you mean a global value as opposed to a buffer-local value. In the case of a variable that has buffer-local values, yes, you can use function default-value to obtain its default value, and you can then use setq to set any buffer-local value to that default value. (You can also use set-default-value to change the default value.)

share|improve this answer

It's possible if the variable was declared as a defcustom:

(eval (car (get 'ediff-split-window-function 'standard-value)))
;; => split-window-vertically

But ispell-tex-skip-alists was declared as defvar, so this isn't possible.

share|improve this answer
1  
Technically, you can visit the variable definition and reevaluate it entirely with elisp code. –  Malabarba 7 hours ago
    
True, but there's no introspection-style option. –  abo-abo 7 hours ago
    
The question explicitly asks about a non-custom variable. –  Drew 3 hours ago
2  
The question was edited two hours after I provided an answer. –  abo-abo 3 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.