all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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.