[Top][All Lists]

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

Re: re-loading an elisp file

From: Pascal J. Bourguignon
Subject: Re: re-loading an elisp file
Date: Sat, 05 Mar 2011 16:27:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

ken <address@hidden> 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.

So defvar is defined to set the value of the variable only if the
variable is not already defined.

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

So you may put:

(defmacro defconstant (symbol initvalue &optional docstring)
  `(defconst ,symbol ,initvalue ,docstring))

(defmacro defparameter (symbol &optional initvalue docstring)
     (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.

What you may do, is to provide a reset command to reinitialize the state
of your module.

__Pascal Bourguignon__           
A bad day in () is better than a good day in {}.

reply via email to

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