From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Bach Newsgroups: gmane.emacs.help Subject: Save and load window states Date: Tue, 20 Dec 2011 17:00:26 +0100 Message-ID: <4ef0b02d.0d0a0e0a.60bc.080d@mx.google.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1324403989 26463 80.91.229.12 (20 Dec 2011 17:59:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 20 Dec 2011 17:59:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 20 18:59:44 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rd3ya-000812-CZ for geh-help-gnu-emacs@m.gmane.org; Tue, 20 Dec 2011 18:59:44 +0100 Original-Received: from localhost ([::1]:52553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rd3yZ-0008FW-Uo for geh-help-gnu-emacs@m.gmane.org; Tue, 20 Dec 2011 12:59:43 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:34136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rd23U-00039V-MX for help-gnu-emacs@gnu.org; Tue, 20 Dec 2011 10:56:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rd23M-0000DS-AO for help-gnu-emacs@gnu.org; Tue, 20 Dec 2011 10:56:40 -0500 Original-Received: from mail-ee0-f41.google.com ([74.125.83.41]:38607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rd23M-0000DA-5s for help-gnu-emacs@gnu.org; Tue, 20 Dec 2011 10:56:32 -0500 Original-Received: by eekc41 with SMTP id c41so6860901eek.0 for ; Tue, 20 Dec 2011 07:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=7xQMlmmqK8L9fpdj5jv003saYdyswHmrUMscLLQz/Yc=; b=VGftlbvukPWqTDw/DDz0S5qTjFOnMbiMNzEIKzVp+L3/5cURQyrvRicz+Au8S4fywK Hosbtl1UKkFsWEFX/rveSO35duX7ZQMBEtbu+Jx/di6kuP+qRk2K32DvqUYRGspPqA0V 2fusvI6Pv/eCKQzaiusp/WawYEgcsKMI+ffuA= Original-Received: by 10.14.125.132 with SMTP id z4mr1176598eeh.82.1324396590408; Tue, 20 Dec 2011 07:56:30 -0800 (PST) Original-Received: from voschtro (chello084112087167.3.11.univie.teleweb.at. [84.112.87.167]) by mx.google.com with ESMTPS id 13sm8346864eeu.1.2011.12.20.07.56.29 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 07:56:29 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.41 X-Mailman-Approved-At: Tue, 20 Dec 2011 12:59:38 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83230 Archived-At: 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