all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kiwon Um <um.kiwon@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: help-gnu-emacs@gnu.org
Subject: Re: session management with desktop and window configuration
Date: Thu, 31 Dec 2009 22:21:33 +0900	[thread overview]
Message-ID: <m3zl4zth2a.fsf@gmail.com> (raw)
In-Reply-To: <4B3C8BAB.7000607@gmx.at> (martin rudalics's message of "Thu, 31 Dec 2009 12:31:55 +0100")

martin rudalics <rudalics@gmx.at> writes:

>> I'm now using desktop.el for managing sessions. When I do desktop-
>> read, it restore all files opened before well. Then, I'm wondering if
>> there is any way to restore window configuration as well in easy way.
>> Firstly, I tried to add some functions to the desktop hooks as
>> follows:
>>   (add-hook 'desktop-save-hook '(window-configuration-to-register ?0))
>>   (add-hook 'desktop-after-read-hook '(jump-to-register ?0))
>> However, it didn't work at all.
>>
>> The register-base window configuration save/restore are perfect to
>> what I want. But I don't know how to integrate it with desktop. Please
>> give me help.
>
> You can't do this with desktop at the moment.  The basic problem is that
> we currently cannot read window configurations from a file - a window
> configuration can only be saved in memory and retrieved from there.
> This obviously means that when you exit Emacs your saved window
> configurations are lost forever.  In this context note also that you
> can't cleanly restore a window configuration in one and the same session
> if you have deleted its frame in the meantime.
>
> Basically you should be able to write a configuration to a file as a
> sequence of `split-window' functions (and some interspersed window
> resizings) and execute these commands when you restart Emacs.  But you
> might end up getting only an approximation of the earlier configuration
> partly due to the quite unpredictable behavior of the current window
> resizing code which can, for example, deliberately delete windows when
> they become too small.
>
> I'm currently contemplating functions that write window configurations
> to a file and read them from there.  This way I can circumvent the
> window splitting mechanism and directly construct a window-tree from the
> information on the file.  This should solve the problem for you.
>
> Meanwhile you could try out ECB which does something similar to what you
> want.
>
> martin

Thanks for your reply. So, I wrote some functions using revive.el:

(require 'revive)
(defun kiwon/save-window-configuration ()
  (write-region (concat "(restore-window-configuration '"
                        (prin1-to-string (current-window-configuration-printable))
                        ")")
                nil ".emacs.restore-window.el"))
(defun kiwon/restore-window-configuration ()
  (when (file-exists-p ".emacs.restore-window.el")
    (load-file ".emacs.restore-window.el")))

(add-hook 'desktop-save-hook 'kiwon/save-window-configuration)
(add-hook 'desktop-after-read-hook 'kiwon/restore-window-configuration)

It seems to be enough to what I wanted. :)




  reply	other threads:[~2009-12-31 13:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-31 11:31 session management with desktop and window configuration martin rudalics
2009-12-31 13:21 ` Kiwon Um [this message]
2009-12-31 13:33   ` Lennart Borgman
2009-12-31 16:16     ` Richard Riley
2009-12-31 16:22       ` Lennart Borgman
2009-12-31 16:32         ` Richard Riley
2009-12-31 17:33           ` Vicente Hernando Ara
2010-01-01  1:25             ` Lennart Borgman
2009-12-31 17:32     ` martin rudalics
2010-01-01  1:27       ` Lennart Borgman
2010-01-01 14:55         ` martin rudalics
2010-01-01 15:04           ` Lennart Borgman
2010-01-01 15:18             ` martin rudalics
2009-12-31 17:31   ` martin rudalics
2010-01-01  1:29     ` Lennart Borgman
     [not found] <mailman.476.1262259127.18930.help-gnu-emacs@gnu.org>
2010-01-07  0:48 ` David Combs
  -- strict thread matches above, loose matches on Subject: below --
2009-12-31 10:08 Kiwon Um

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=m3zl4zth2a.fsf@gmail.com \
    --to=um.kiwon@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rudalics@gmx.at \
    /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.