help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: re-defvar a variable without reloading emacs


From: Drew Adams
Subject: RE: re-defvar a variable without reloading emacs
Date: Sat, 13 Jun 2009 08:19:57 -0700

> > I've got a defvar'd variable in my .emacs which I want to 
> > redefine.  But rerunning (defvar somevar "someval") doesn't work... 
> > according to the docs, this is the correct behavior.  So is there
> > some way to redefine this variable without reloading the whole of emacs?
> 
> Use setq.

It depends what is meant:

1. If you mean that you have already evaluated (e.g. loaded) the code
(defvar somevar "someval"), and you have now edited that code to
(defvar somevar "newval"), and you want to evaluate that
interactively, see node `Evaluating Emacs Lisp Expressions' in the
Emacs manual. It says you can put the cursor somewhere on the
expression and hit `C-M-x', to do what you want.

2. If you mean that you have want to be able to evaluate (e.g. load)
the code (defvar somevar "someval") and then evaluate (load) some
other code that redefines `somevar', then use (setq somevar "newval")
as that other code.

`setq' always assigns a value. `defvar' assigns a value only the
first time it is evaluated, normally, but `C-M-x' overrides this,
making it assign a value again.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]