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

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

Persistent buffer local variables?


From: Elena
Subject: Persistent buffer local variables?
Date: Wed, 08 Dec 2010 15:18:37 -0000
User-agent: G2/1.0

Hello,

I need to attach a some values to a buffer for later use. I have tried
using buffer local variables, but it seems they are forgotten as soon
as I switch major mode. How could I work around that? Here is my test
code:


(defvar my-var nil)
(make-variable-buffer-local 'my-var)

(defun my-set-var ()
        (interactive)
        (switch-to-buffer (get-buffer-create "*test*"))
        (setq my-var "test")
        ;; (text-mode) ;; If I uncomment this line, variable is forgotten.
)

(defun my-show-var ()
        (interactive)
        (message "my-var is: %s" my-var))

Thanks.


reply via email to

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