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

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

Save and load window states


From: Michael Bach
Subject: Save and load window states
Date: Tue, 20 Dec 2011 17:00:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

I am trying to get saving and loading window states to work.  I am using
the new `window-state-get' and `window-state-put' functions from emacs
24:

--8<---------------cut here---------------start------------->8---
(defun my-save-frame ()
  (interactive)
  (let ((buf (find-file-noselect (concat *emacs-path* ".emacs-layout"))))
    (set-buffer buf)
    (erase-buffer)
    (print (window-state-get) buf)
    (save-buffer)
    (kill-buffer)))

(defun my-load-frame ()
  (interactive)
  (let ((buf (find-file-noselect (concat *emacs-path* ".em1acs-layout"))))
    (set-buffer buf)
    (window-state-put (read buf))))
--8<---------------cut here---------------end--------------->8---

Saving works this way.  The file has the same contents shown in the
*Messages* buffer when doing a manual `window-state-get'.  On loading, I
get either "Invalid read syntax #" or "End of file during parsing".  In
the documentation of the `window-state-get' function it says:

"The return value can be used as argument for `window-state-put' to put
the state recorded here into an arbitrary window.  The value can be also
stored on disk and read back in a new session."

I am thinking that this has something to do with how emacs reads and
evaluates objects.

Can someone give me a hint on how to make it work?

Best Regards,
Michael Bach



reply via email to

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