* Saving the frame layout between frames
@ 2013-10-27 19:10 Alex Bennée
2013-10-27 19:50 ` Tim Visher
2013-10-28 0:54 ` Stefan Monnier
0 siblings, 2 replies; 7+ messages in thread
From: Alex Bennée @ 2013-10-27 19:10 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
Following on from my previous adventures with chromebook.el I'm now
trying to save the frame layout so when I create a new frame I can
restore the layout of the buffers and windows as they where.
I've been using:
(setq crmbk-previous-frame-config (current-window-configuration))
However when the new frame is created and I run:
(when crmbk-previous-frame-config
(set-window-configuration crmbk-previous-frame-config))
It's not working. If I run these commands from within a frame after
messing around with the configuration it works as expected so I assume
the breakage is caused by the fact the new frame context is incompatible
(indeed winner-mode doesn't seem to save window configuration between
frame instances).
So is there any way around this?
--
Alex Bennée
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the frame layout between frames
2013-10-27 19:10 Saving the frame layout between frames Alex Bennée
@ 2013-10-27 19:50 ` Tim Visher
2013-10-28 0:54 ` Stefan Monnier
1 sibling, 0 replies; 7+ messages in thread
From: Tim Visher @ 2013-10-27 19:50 UTC (permalink / raw)
To: Alex Bennée; +Cc: emacs
I'm not going to be too much help but winner-mode sounds like it does
most of what you're looking for so maybe look at how they do it?
http://www.emacswiki.org/emacs/WinnerMode
On Sun, Oct 27, 2013 at 3:10 PM, Alex Bennée <kernel-hacker@bennee.com> wrote:
> Hi,
>
> Following on from my previous adventures with chromebook.el I'm now
> trying to save the frame layout so when I create a new frame I can
> restore the layout of the buffers and windows as they where.
>
> I've been using:
>
> (setq crmbk-previous-frame-config (current-window-configuration))
>
> However when the new frame is created and I run:
>
> (when crmbk-previous-frame-config
> (set-window-configuration crmbk-previous-frame-config))
>
> It's not working. If I run these commands from within a frame after
> messing around with the configuration it works as expected so I assume
> the breakage is caused by the fact the new frame context is incompatible
> (indeed winner-mode doesn't seem to save window configuration between
> frame instances).
>
> So is there any way around this?
>
> --
> Alex Bennée
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the frame layout between frames
2013-10-27 19:10 Saving the frame layout between frames Alex Bennée
2013-10-27 19:50 ` Tim Visher
@ 2013-10-28 0:54 ` Stefan Monnier
2013-10-28 12:50 ` Alex Bennée
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-28 0:54 UTC (permalink / raw)
To: help-gnu-emacs
> (setq crmbk-previous-frame-config (current-window-configuration))
window-configurations can't be transferred between frames.
In recent Emacsen, a new data-structure was introduced which can be used
between frames, called `window-state'.
You can use window-state-get and then window-state-put.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the frame layout between frames
2013-10-28 0:54 ` Stefan Monnier
@ 2013-10-28 12:50 ` Alex Bennée
2013-10-28 14:20 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Alex Bennée @ 2013-10-28 12:50 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
In-reply-to: <jwvppqq8bho.fsf-monnier+gmane.emacs.help@gnu.org>
monnier@iro.umontreal.ca writes:
>> (setq crmbk-previous-frame-config (current-window-configuration))
>
> window-configurations can't be transferred between frames.
> In recent Emacsen, a new data-structure was introduced which can be used
> between frames, called `window-state'.
>
> You can use window-state-get and then window-state-put.
That almost works. I've certainly got a structure that I can use to
reset the frame configuration manually now. However if I call it in the
new frame handler:
(defun crmbk-new-frame-handler (frame)
"Do any appropriate set-up on new frame creation.
This is intended to be called during after-make-frame-functions"
(when (frame-parameter frame 'display)
(set-frame-parameter frame 'fullscreen 'fullboth)
(setq crmbk-current-frame frame)
(when crmbk-previous-frame-config
(window-state-put crmbk-previous-frame-config))
(crmbk-frame-mode t)))
The new frame hangs until I C-g at which point *Messages* reads:
window-state-put: Window #<window 1 on *scratch*> too small to accommodate state
Quit
Error in post-command-hook (winner-save-old-configurations): (error "Window is on a different frame")
Should I restore the frame configuration on a later hook?
--
Alex Bennée
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the frame layout between frames
2013-10-28 12:50 ` Alex Bennée
@ 2013-10-28 14:20 ` Stefan Monnier
2013-10-28 17:38 ` Alex Bennée
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-28 14:20 UTC (permalink / raw)
To: help-gnu-emacs
> (window-state-put crmbk-previous-frame-config))
You need to state where to put that config (that's what the `window'
arg is for). So try it with
(window-state-put crmbk-previous-frame-config
(frame-root-window frame))
> window-state-put: Window #<window 1 on *scratch*> too small to accommodate state
But I don't know enough about window-state to tell you if that will fix
this problem.
> Error in post-command-hook (winner-save-old-configurations): (error "Window is on a different frame")
That seems unrelated.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the frame layout between frames
2013-10-28 14:20 ` Stefan Monnier
@ 2013-10-28 17:38 ` Alex Bennée
0 siblings, 0 replies; 7+ messages in thread
From: Alex Bennée @ 2013-10-28 17:38 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
monnier@iro.umontreal.ca writes:
>> (window-state-put crmbk-previous-frame-config))
>
> You need to state where to put that config (that's what the `window'
> arg is for). So try it with
>
> (window-state-put crmbk-previous-frame-config
> (frame-root-window frame))
<snip>
That worked thanks. I thought (frame-root-window frame) was the default
as the doc says "Optional argument WINDOW must specify a live window and
defaults to the selected one." but I guess at the time I'm running it
isn't.
Anyway it's working now, thanks.
--
Alex Bennée
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the frame layout between frames
@ 2013-10-28 17:52 martin rudalics
0 siblings, 0 replies; 7+ messages in thread
From: martin rudalics @ 2013-10-28 17:52 UTC (permalink / raw)
To: kernel-hacker; +Cc: help-gnu-emacs
> (defun crmbk-new-frame-handler (frame)
> "Do any appropriate set-up on new frame creation.
> This is intended to be called during after-make-frame-functions"
> (when (frame-parameter frame 'display)
> (set-frame-parameter frame 'fullscreen 'fullboth)
> (setq crmbk-current-frame frame)
> (when crmbk-previous-frame-config
> (window-state-put crmbk-previous-frame-config))
I suppose what you want here is
(when crmbk-previous-frame-config
(window-state-put
crmbk-previous-frame-config (frame-root-window frame)))
Note that running `after-make-frame-functions' doesn't select the new
frame.
> (crmbk-frame-mode t)))
martin
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-10-28 17:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-27 19:10 Saving the frame layout between frames Alex Bennée
2013-10-27 19:50 ` Tim Visher
2013-10-28 0:54 ` Stefan Monnier
2013-10-28 12:50 ` Alex Bennée
2013-10-28 14:20 ` Stefan Monnier
2013-10-28 17:38 ` Alex Bennée
-- strict thread matches above, loose matches on Subject: below --
2013-10-28 17:52 martin rudalics
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).