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

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

Re: re-loading an elisp file


From: ken
Subject: Re: re-loading an elisp file
Date: Sat, 05 Mar 2011 11:46:09 -0500
User-agent: Thunderbird 2.0.0.24 (X11/20101213)

On 03/05/2011 10:27 AM Pascal J. Bourguignon wrote:
> ken <gebser@mousecar.com> 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.





reply via email to

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