unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* buffer-local variables and state information
@ 2011-09-11 16:25 Le Wang
  2011-09-11 20:05 ` Štěpán Němec
  0 siblings, 1 reply; 2+ messages in thread
From: Le Wang @ 2011-09-11 16:25 UTC (permalink / raw)
  To: GNU Emacs List

Is it considered generally acceptable to store state information, for
example, from a minor-mode in a buffer-local variable?  This seemed
like a clean way of doing it, because when the buffer gets killed, the
variables go away, and the GC will clean up at some later stage.

However, recently, I discovered that changing major-modes would
actually kill all buffer-local variables, which would leave my
minor-mode in an invalid state.  So I've been doing it wrong?

-- 
Le



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: buffer-local variables and state information
  2011-09-11 16:25 buffer-local variables and state information Le Wang
@ 2011-09-11 20:05 ` Štěpán Němec
  0 siblings, 0 replies; 2+ messages in thread
From: Štěpán Němec @ 2011-09-11 20:05 UTC (permalink / raw)
  To: Le Wang; +Cc: GNU Emacs List

On Sun, 11 Sep 2011 18:25:26 +0200
Le Wang wrote:

> Is it considered generally acceptable to store state information, for
> example, from a minor-mode in a buffer-local variable?

Yes.

> However, recently, I discovered that changing major-modes would
> actually kill all buffer-local variables, which would leave my
> minor-mode in an invalid state.  So I've been doing it wrong?

Not necessarily.

If the variable in question should persist across major mode changes,
you can set its `permanent-local' property, e.g.

  (put 'variable 'permanent-local t)

That will make it exempt from the buffer-local variable slaughter.

-- 
Štěpán



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-11 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-11 16:25 buffer-local variables and state information Le Wang
2011-09-11 20:05 ` Štěpán Němec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).