all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Save and load window states
@ 2011-12-20 16:00 Michael Bach
  2011-12-20 18:53 ` Drew Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Bach @ 2011-12-20 16:00 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: Save and load window states
@ 2011-12-21 15:29 martin rudalics
  2011-12-21 20:13 ` Michael Bach
  0 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2011-12-21 15:29 UTC (permalink / raw)
  To: phaebz; +Cc: help-gnu-emacs

 > 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 #"

This is a bug.  Please report it as Drew suggested.

 > or "End of file during parsing".

This is probably due to the fact that you called `my-load-frame' twice
in a row and you were already at the end of the buffer in the second
call so there was nothing more to read.

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

Partly, yes.

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

Please comment out the two code lines

                 (unless (window-parameter window 'clone-of)
                   ;; Make a clone-of parameter.
                   (setq list (cons (cons 'clone-of window) list)))

in the function `window--state-get-1' and recompile window.el (possibly
twice - I'm somewhat confused by Stefan's backquote syntax here).  These
lines are currently for internal use only, their absence should not harm
you.  If you still see problems, please tell me.

Thanks, martin



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-12-28 14:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-20 16:00 Save and load window states Michael Bach
2011-12-20 18:53 ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2011-12-21 15:29 martin rudalics
2011-12-21 20:13 ` Michael Bach
2011-12-21 21:20   ` martin rudalics
2011-12-23 11:02     ` Michael Bach
2011-12-23 11:13       ` martin rudalics
2011-12-23 12:24         ` Michael Bach
2011-12-23 13:46           ` martin rudalics
2011-12-28 14:10             ` Michael Bach

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.