From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: re-defvar a variable without reloading emacs Date: Sat, 13 Jun 2009 19:48:57 -0400 Message-ID: <4A343AE9.5040102@mousecar.com> References: <4A33A0BF.6030701@mousecar.com> Reply-To: gebser@mousecar.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1244936973 18313 80.91.229.12 (13 Jun 2009 23:49:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Jun 2009 23:49:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 14 01:49:31 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MFcyZ-0000vI-3o for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Jun 2009 01:49:31 +0200 Original-Received: from localhost ([127.0.0.1]:47580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MFcyY-0004px-KF for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Jun 2009 19:49:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MFcyE-0004pk-Qe for help-gnu-emacs@gnu.org; Sat, 13 Jun 2009 19:49:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MFcyC-0004pY-7A for help-gnu-emacs@gnu.org; Sat, 13 Jun 2009 19:49:09 -0400 Original-Received: from [199.232.76.173] (port=45079 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MFcyC-0004pV-2Y for help-gnu-emacs@gnu.org; Sat, 13 Jun 2009 19:49:08 -0400 Original-Received: from mout.perfora.net ([74.208.4.194]:49702) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MFcyB-0000f2-OU for help-gnu-emacs@gnu.org; Sat, 13 Jun 2009 19:49:07 -0400 Original-Received: from [192.168.0.26] (dsl093-011-017.cle1.dsl.speakeasy.net [66.93.11.17]) by mrelay.perfora.net (node=mrus1) with ESMTP (Nemesis) id 0MKpCa-1MFcy817iH-000cnp; Sat, 13 Jun 2009 19:49:06 -0400 User-Agent: Thunderbird 2.0.0.0 (X11/20070326) In-Reply-To: X-Enigmail-Version: 0.95.7 OpenPGP: id=5AD091E7 X-Provags-ID: V01U2FsdGVkX185TwGQt1R0rGHC69EmkRwgNj+/zS8RoXeUCFb QFwmxmc6aJM3hzPxrw/TAwZSjgE9Z6BAGR7aAsCYI62fHRGP1/ 1CeWL4iZRkimAga2V0A4eKCqQNjlH4I X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65272 Archived-At: 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. > > >