all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ken <gebser@mousecar.com>
To: "Pascal J. Bourguignon" <pjb@informatimago.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: re-loading an elisp file
Date: Sat, 05 Mar 2011 11:46:09 -0500	[thread overview]
Message-ID: <4D7268D1.9000800@mousecar.com> (raw)
In-Reply-To: <87bp1ptwn6.fsf@kuiper.lan.informatimago.com>

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	other threads:[~2011-03-05 16:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.6.1299338195.13665.help-gnu-emacs@gnu.org>
2011-03-05 15:27 ` re-loading an elisp file Pascal J. Bourguignon
2011-03-05 16:46   ` ken [this message]
     [not found]   ` <mailman.18.1299343589.13665.help-gnu-emacs@gnu.org>
2011-03-05 17:41     ` Johan Bockgård
2011-03-05 23:09       ` ken
2011-03-05 22:17     ` Tim X
2011-03-05 23:21       ` PJ Weisberg
     [not found]       ` <mailman.3.1299367324.22865.help-gnu-emacs@gnu.org>
2011-03-06  0:05         ` Tim X
2011-03-06  5:32         ` rusi
2011-03-06  8:36           ` Le Wang
2011-03-08  1:18             ` Kevin Rodgers
     [not found]             ` <mailman.0.1299547100.4111.help-gnu-emacs@gnu.org>
2011-03-08  1:57               ` rusi
2011-03-08  2:01                 ` rusi
2011-03-24 18:02       ` David Combs
2011-03-25  6:39         ` Tim X
2011-03-25  6:51           ` David Kastrup
2011-03-25  8:45             ` Jambunathan K
2011-03-25 22:23             ` Tim X
     [not found]             ` <mailman.2.1301064125.24725.help-gnu-emacs@gnu.org>
2011-03-25 23:01               ` Tim X
2011-03-26  4:25                 ` Jambunathan K
     [not found]                 ` <mailman.0.1301164236.2084.help-gnu-emacs@gnu.org>
2011-03-26 22:49                   ` Tim X
2011-03-05 15:16 ken
2011-03-05 15:54 ` Drew Adams
2011-03-05 17:13   ` ken
2011-03-05 18:06     ` Drew Adams
2011-03-05 18:11     ` Drew Adams
2011-03-05 23:36       ` ken
2011-03-06  2:08         ` PJ Weisberg
     [not found]         ` <mailman.22.1299377327.22865.help-gnu-emacs@gnu.org>
2011-03-24 18:31           ` David Combs
2011-03-24 18:57             ` Drew Adams
     [not found]     ` <mailman.4.1299348453.24947.help-gnu-emacs@gnu.org>
2011-03-24 18:24       ` David Combs
2011-03-24 19:09         ` Drew Adams
     [not found]   ` <mailman.0.1299345251.24947.help-gnu-emacs@gnu.org>
2011-03-05 22:25     ` Tim X

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D7268D1.9000800@mousecar.com \
    --to=gebser@mousecar.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pjb@informatimago.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.