all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Marcelo de Moraes Serpa'" <celoserpa@gmail.com>,
	"'Lennart Borgman'" <lennart.borgman@gmail.com>
Cc: help-gnu-emacs@gnu.org,
	'Kevin Rodgers' <kevin.d.rodgers@gmail.com>,
	'Thierry Volpiatto' <thierry.volpiatto@gmail.com>
Subject: RE: Saving a elisp data structure into string and evaluating itback into objects
Date: Wed, 7 Oct 2009 10:41:05 -0700	[thread overview]
Message-ID: <0836EDD8E49943738E063EFE7FE312A5@us.oracle.com> (raw)
In-Reply-To: <1e5bcefd0910070923w6af29d6eja4aa8a16fb3b5db8@mail.gmail.com>

1. There have been several examples of libraries that save and then restore
various sets of Lisp objects, typically in order to restore the state of an
Emacs session, or at least part of it. Some have already been mentioned here.

FWIW, I use Savehist, to restore both history variables and other variables that
I choose (via option `savehist-additional-variables'):
http://www.emacswiki.org/emacs/SaveHist

But it too doesn't help with Emacs objects whose print form is not
Lisp-readable.

(I also have my own code that serializes completion alists, in such a way that
it records and restores markers. But the serialization format I use is
particular to my code.)


2. AFAIK, there is no general serialize/deserialize feature, as such, in Emacs
Lisp. That is, there are no predefined functions that do just that: (1) You
provide a set of objects and a file name to a `serialize' function, and it
writes the objects to the file in a way that captures their current state. (2)
You call a `deserialize' function to read the file (e.g. using the Lisp reader)
and thus re-create the objects in the state in which they were saved.


3. It might be worthwhile looking at this thread:
http://lists.gnu.org/archive/html/emacs-devel/2009-09/msg00846.html

The thread is too short, IMO (it drew no real interest, for some reason), and it
got side-tracked by a discussion of licensing. But the idea is simple:

Thierry Volpiatto noticed that, at least for recent Emacs versions,
byte-compiling serializes Emacs objects in a fairly general way, so reading
(loading) a byte-compiled (*.elc) file then restores the objects as they were.

You can use this feature as is. Or you (or Emacs development) could use it to
define `serialize' and `deserialize' functions for general use.

Thierry pointed out the following URL to me in connection with this. It mentions
using `#.' in Common Lisp, whereas for Emacs Lisp it is `eval-when-compile' that
does the trick.
http://www.cs.cmu.edu/Groups/AI/html/faqs/lang/lisp/part5/faq-doc-5.html

HTH.





  reply	other threads:[~2009-10-07 17:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-06 23:08 Saving a elisp data structure into string and evaluating it back into objects Marcelo de Moraes Serpa
2009-10-07 12:57 ` Kevin Rodgers
2009-10-07 15:09   ` Marcelo de Moraes Serpa
2009-10-07 15:33     ` Lennart Borgman
2009-10-07 16:23       ` Marcelo de Moraes Serpa
2009-10-07 17:41         ` Drew Adams [this message]
2009-10-07 18:22           ` Saving a elisp data structure into string and evaluating itback " Marcelo de Moraes Serpa
2009-10-08 22:51         ` Saving a elisp data structure into string and evaluating it back " Lennart Borgman

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=0836EDD8E49943738E063EFE7FE312A5@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=celoserpa@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=kevin.d.rodgers@gmail.com \
    --cc=lennart.borgman@gmail.com \
    --cc=thierry.volpiatto@gmail.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.