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-loading an elisp file Date: Sat, 05 Mar 2011 11:46:09 -0500 Message-ID: <4D7268D1.9000800@mousecar.com> References: <87bp1ptwn6.fsf@kuiper.lan.informatimago.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: dough.gmane.org 1299343617 19962 80.91.229.12 (5 Mar 2011 16:46:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 5 Mar 2011 16:46:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Pascal J. Bourguignon" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 05 17:46:50 2011 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.69) (envelope-from ) id 1Pvucz-0007j3-Bn for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Mar 2011 17:46:49 +0100 Original-Received: from localhost ([127.0.0.1]:52392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pvucy-0004w1-V9 for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Mar 2011 11:46:49 -0500 Original-Received: from [140.186.70.92] (port=35379 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pvucb-0004vk-TX for help-gnu-emacs@gnu.org; Sat, 05 Mar 2011 11:46:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pvuca-00077N-CG for help-gnu-emacs@gnu.org; Sat, 05 Mar 2011 11:46:25 -0500 Original-Received: from mout.perfora.net ([74.208.4.195]:64294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pvuca-000774-6k for help-gnu-emacs@gnu.org; Sat, 05 Mar 2011 11:46:24 -0500 Original-Received: from dellap.mousecar.net (dsl093-011-016.cle1.dsl.speakeasy.net [66.93.11.16]) by mrelay.perfora.net (node=mrus4) with ESMTP (Nemesis) id 0Lz3f6-1Q0MYE2nwm-0145cj; Sat, 05 Mar 2011 11:46:22 -0500 User-Agent: Thunderbird 2.0.0.24 (X11/20101213) In-Reply-To: <87bp1ptwn6.fsf@kuiper.lan.informatimago.com> X-Enigmail-Version: 0.96.0 OpenPGP: id=5AD091E7 X-Provags-ID: V02:K0:vXlPRzqnyOvc7cytw304HTcRu9P3C3EtpfV8Ie5TIEs RpTc3+lE16bB6IBBnIo2MEL3C6KLmDLpE/Gyp2yFIcL6V9v1wW Y3sLB+VgaVHhRUwpiT+E1ohXLWxW8S2m1q98GLcQ0H5tFPIuG7 N/E1CsQjRQZy4wbkr9k9aTc3LTh0SOaZykjqVvoChTQk+3FzMK GH5EXkaix7oYEMWDmtaE+gjBjk7vvtSHpTUDdixc4I= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.195 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:79786 Archived-At: On 03/05/2011 10:27 AM Pascal J. Bourguignon wrote: > ken writes: > >> Is there a way, when reloading an elisp file, to have it examine (and >> reload new) values of variables? > > There's a reason it's done: if you've painfully customized a module, you > wouldn't want all your settings to be reset to default just because you > reload its sources. That's what I *am* doing-- *quite* and unnecessarily painfully customizing a module-- and I *do* want variables to be re-initialized. > > So defvar is defined to set the value of the variable only if the > variable is not already defined. Then the name of the function should be called "load-everything-except-variables". The "load" and "eval-current-buffer" functions should do what their names say. > > > In Common Lisp, there's also a defparameter macro that always sets the > value of the variable. But of course, you wouldn't do that for > customization variables, or for variables storing important state (eg. a > database). Are you saying I need to switch from elisp to common lisp or make a call to common lisp just to change the value of a variable? > > > So you may put: > > (defmacro defconstant (symbol initvalue &optional docstring) > `(defconst ,symbol ,initvalue ,docstring)) > > (defmacro defparameter (symbol &optional initvalue docstring) > `(progn > (defvar ,symbol nil ,docstring) > (setq ,symbol ,initvalue))) > > in your ~/.emacs and use defparameter instead of defvar in some cases. > But in general you don't want to. So I need to put all this code in my ~/.emacs (and then of course re-initialize ~/.emacs) whenever I need to re-initialize one variable? But then wouldn't I need to take this code back out and re-initialize ~/.emacs again when I don't want to change the value of a variable? I think it would be simpler and easier just to reboot all of emacs. But quitting-and-restarting emacs seems like a radical procedure just to re-initialize one variable. > > > What you may do, is to provide a reset command to reinitialize the state > of your module. I was hoping I wouldn't have to write that code myself... I was thinking that elisp should have a way to re-initialize a variable in a module. That was really the point of my original post.