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

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

Saving a elisp data structure into string and evaluating it back into ob


From: Marcelo de Moraes Serpa
Subject: Saving a elisp data structure into string and evaluating it back into objects
Date: Tue, 6 Oct 2009 18:08:25 -0500

Hello list,

I'm trying to combine DeskTop, layout-restore.el and revive.el to create the ultimate persistence experience :)

Well, what I'm trying to do is, every time I exit emacs, the whole memory state (elisp object's tree) will be dumped to a file and reloaded when I restart emacs again.

Why am I trying to do this? Well, there are many settings in emacs that are volatile, many vars that are not saved. I know that emacs has the capability to save its vars into .emacs, but this depends on the mode and the var, no?

Anyway, the point is, I love how layout-restore.el works, and this is the main reason I'm trying to do this. I want to persist all the state created by layout-restore, meaning all the window layouts saved per buffer while I was working in an emacs session. When I exit and start emacs again, I want the very same layouts associated with the very same buffers.

I'm not an emacs/elisp guru, but I could find out that layout-restore saves its state into the layout-configuration-alist global var. This var is a list of buffer objects, here's a stringfied version of its contents (I saved a layout using layout-save-current and it filled the var with this data-structure):

"((#<buffer *scratch*> #<window-configuration> (#<buffer *scratch*> . \"*scratch*\") (#<buffer *Help*> . \"*Help*\")))"

So far so good. I can get the value of the var into a string, and I also have found out how to tell revive.el to also save the contents of this var: To add this var's symbol to the list in revive:save-variables-global, like this:

        (setq revive:save-variables-global
              '(layout-configuration-alist))

When I do M-x save-current-configuration, it does get the value of the var. The following is an excerpt from ~/.revive.el:

((layout-configuration-alist (#<buffer dot.emacs.el> #<window-configuration> (#<buffer dot.emacs.el> . "dot.emacs.el") (#<buffer *Help*> . "*Help*"))))

But, when I try to restore all this state by calling resume (M-x resume), it fails with the following message:

Invalid syntax "#".

Well, it is pretty obvious that the string is not representing the objects in a manner that can be revaluated. These are simple to_s (as in Ruby) representations and not full data structures that could be used to reconstruct the object in memory again.

My question is: How could I dump the contents of layout-configuration-alist it in a way that resume could eval and eval it back into first class elisp objects again?

Thanks,

Marcelo.



reply via email to

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