Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Persistent Window Registers

122 views
Skip to first unread message

Volkan YAZICI

unread,
Jan 4, 2009, 11:10:04 AM1/4/09
to
Hi,

I'm using session.el[1] for persistence of configurations between
different emacs sessions. But I also want to assign persistent window
registers to some of my window configurations. For instance, I want
below configurations be persistent across different sessions:

- C-x r j 1 (*Group*)
- C-x r j 2 (#postgresql and #lisp buffers divided vertically)
- ...

How can I do that? (Actually, I don't want to hard-bind "C-x r j 1" to
*Group*. I just want my "C-x r w"ed configurations be remembered in
later sessions.)


Regards.

[1] http://emacs-session.sourceforge.net/

Volkan YAZICI

unread,
Jan 5, 2009, 5:17:58 AM1/5/09
to
On Jan 4, 6:10 pm, Volkan YAZICI <volkan.yaz...@gmail.com> wrote:
> I'm using session.el[1] for persistence of configurations between
> different emacs sessions. But I also want to assign persistent window
> registers to some of my window configurations.

I find out that "saving window configurations" is on the TODO list of
both session.el and desktop.el packages. When I check register.el of
emacs, I see that one can manually initialize `register-alist' as he/
she desires, but the components for #<window-configuration> and
#<marker at 1 in *Group*> are -- if I am not mistaken -- defined in C
code and I don't know a way to create one from elisp or serialize an
existing one and read it at the next session. Any ideas?


Regards.

Lennart Borgman

unread,
Jan 5, 2009, 5:50:52 AM1/5/09
to Volkan YAZICI, help-gn...@gnu.org

See winsav.el in nXhtml


Volkan YAZICI

unread,
Jan 7, 2009, 8:03:48 AM1/7/09
to
On Jan 5, 12:50 pm, "Lennart Borgman" <lennart.borg...@gmail.com>
wrote:
> See winsav.el in nXhtml

After spending some time, I found out that there is no easy way to
save window configurations. Instead, as nXhtml, people

1. Walk through available window configurations they are interested
in,

2. Copy attributes (buffer name, buffer start/end position, etc.) of
the walked windows,

And in later sessions, using saved window attributes

3. Open same buffers one by one in specific windows,

4. Then resize opened windows according to the saved attributes.

On Jan 4, 6:10 pm, Volkan YAZICI <volkan.yaz...@gmail.com> wrote:

> - C-x r j 1 (*Group*)
> - C-x r j 2 (#postgresql and #lisp buffers divided vertically)

To summarize, here is the solution I came up with:

(defun erc-register-window-configuration ()
"Register vertically split `#postgresql' and `#lisp' channel windows
into
configuration 2."
(let ((psql-buf (get-buffer "#postgresql"))
(lisp-buf (get-buffer "#lisp")))
(cond ((and psql-buf lisp-buf)
(switch-to-buffer psql-buf)
(delete-other-windows)
(recenter)
(select-window (split-window-horizontally))
(switch-to-buffer lisp-buf)
(recenter)
(window-configuration-to-register ?2))
(t (warn "Couldn't find buffers `#postgresql' and `#lisp'.")))))

(add-hook 'erc-join-hook 'erc-register-window-configuration)

(defun gnus-register-window-configuration ()
"Register a whole `*Group*' buffer window into configuration 1."
(let ((group-buf (get-buffer "*Group*")))
(when group-buf
(switch-to-buffer group-buf)
(delete-other-windows)
(beginning-of-buffer)
(window-configuration-to-register ?1))))

(add-hook 'gnus-started-hook 'gnus-register-window-configuration)


Regards.

Lennart Borgman

unread,
Jan 7, 2009, 5:26:39 PM1/7/09
to Volkan YAZICI, help-gn...@gnu.org
On Wed, Jan 7, 2009 at 2:03 PM, Volkan YAZICI <volkan...@gmail.com> wrote:
> On Jan 5, 12:50 pm, "Lennart Borgman" <lennart.borg...@gmail.com>
> wrote:
>> See winsav.el in nXhtml
>
> After spending some time, I found out that there is no easy way to
> save window configurations. Instead, as nXhtml, people


Hi Volkan,
I am not sure what you mean and it is a long time since I wrote
winsav.el. Are the things you need missing in winsav.el?

Volkan YAZICI

unread,
Jan 8, 2009, 1:48:11 AM1/8/09
to
On Jan 8, 12:26 am, "Lennart Borgman" <lennart.borg...@gmail.com>
wrote:

> I am not sure what you mean and it is a long time since I wrote
> winsav.el. Are the things you need missing in winsav.el?

No, actually I was looking for some internal hacks to easily serialize
#<window ...> objects. But instead, I saw that, people serialize the
environment variables forming that #<window ...> object and in later
sessions, using that variables they are creating same #<window ...>
objects from scratch.


Regards.

Volkan YAZICI

unread,
Jan 8, 2009, 2:50:08 AM1/8/09
to
On Jan 4, 6:10 pm, Volkan YAZICI <volkan.yaz...@gmail.com> wrote:

I just give it a quick & dirty start: http://www.emacswiki.org/emacs/SavingWindowConfigurations

0 new messages