[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: re-defvar a variable without reloading emacs
From: |
ken |
Subject: |
Re: re-defvar a variable without reloading emacs |
Date: |
Sat, 13 Jun 2009 19:48:57 -0400 |
User-agent: |
Thunderbird 2.0.0.0 (X11/20070326) |
Drew,
Excellent answer... 400% better than an expert's... it reminds us that
the meaning of "guru" is "teacher".
But much thanks to all who replied.
On 06/13/2009 11:19 AM Drew Adams wrote:
>>> 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.
>
>
>