unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* save/restore frame positions
@ 2006-05-06 22:36 Robin Dunn
  2006-05-07  2:25 ` Drew Adams
  2006-05-17 22:04 ` Johan Bockgård
  0 siblings, 2 replies; 9+ messages in thread
From: Robin Dunn @ 2006-05-06 22:36 UTC (permalink / raw)


Often when I start emacs I find myself creating several frames and 
sizing/positioning them in a certain way.  Is there any elisp modules 
out there that will let me save the current state (size and position at 
least) of all the frames and then restore that state later?  I've tried 
a few modules several months ago that sound like they could do things 
like this, but they either just dealt with the current frame, or just 
plain didn't work.  I already use the desktop module to save/restore the 
state of the buffers for my various projects, so it would be nice to 
also be able to do the frames too.

Robin

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

* RE: save/restore frame positions
  2006-05-06 22:36 Robin Dunn
@ 2006-05-07  2:25 ` Drew Adams
  2006-05-07  2:41   ` Drew Adams
  2006-05-17 22:04 ` Johan Bockgård
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2006-05-07  2:25 UTC (permalink / raw)


    Often when I start emacs I find myself creating several frames and
    sizing/positioning them in a certain way.  Is there any elisp modules
    out there that will let me save the current state (size and position at
    least) of all the frames and then restore that state later?  I've tried
    a few modules several months ago that sound like they could do things
    like this, but they either just dealt with the current frame, or just
    plain didn't work.  I already use the desktop module to
    save/restore the
    state of the buffers for my various projects, so it would be nice to
    also be able to do the frames too.

Yes, you can define a frame configuration that you can return to later. You
can save a (window or) frame configuration in a register and then restore it
later. `C-x r f R' saves the current state of all frames in register R. See
Emacs manual, node RegConfig.

Library `doremi-frm.el' (which requires a few other libraries) provides an
easy way to use frame configurations interactively. You can have a ring of
frame configurations, and then use command `doremi-frame-configs' to cycle
among them.

`doremi-frm.el' automatically pushes each change you make to a frame (using
DoReMi commands) to a ring of frame configs. For example, if you use
`doremi-frame-height' to incrementally change the height of a frame, then
the change is recorded in the frame-config ring.

In general, `doremi-frm.el' is not about frame configs; this is a side
feature. It is about making incremental changes to frames interactively:
color, size, position, font, faces, whatever. You do this using either a
mouse wheel or the arrow keys (press & hold to increase/decrease a frame
parameter until you get what you like).

After making a change that you like, you can copy it to your
`default-frame-alist' (or another frame alist) using DoReMi commands, and
then you can save the `default-frame-alist' change persistently using
Customize.

Here's the doc on DoReMi, which describes DoReMi frame commands and provides
links to download the libraries:
http://www.emacswiki.org/cgi-bin/wiki/DoReMi.

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

* RE: save/restore frame positions
  2006-05-07  2:25 ` Drew Adams
@ 2006-05-07  2:41   ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2006-05-07  2:41 UTC (permalink / raw)


    Here's the doc on DoReMi, which describes DoReMi frame commands
    and provides links to download the libraries:
    http://www.emacswiki.org/cgi-bin/wiki/DoReMi.

Here's a more direct link to the frame-config cycling doc:
http://www.emacswiki.org/cgi-bin/wiki/DoReMi#FrameConfigCycling

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

* Re: save/restore frame positions
       [not found] <mailman.1525.1146968778.9609.help-gnu-emacs@gnu.org>
@ 2006-05-16 22:12 ` Robin Dunn
  2006-05-16 22:51   ` Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Robin Dunn @ 2006-05-16 22:12 UTC (permalink / raw)


Drew Adams wrote:

> Library `doremi-frm.el' (which requires a few other libraries) provides an
> easy way to use frame configurations interactively. You can have a ring of
> frame configurations, and then use command `doremi-frame-configs' to cycle
> among them.
> 
> `doremi-frm.el' automatically pushes each change you make to a frame (using
> DoReMi commands) to a ring of frame configs. For example, if you use
> `doremi-frame-height' to incrementally change the height of a frame, then
> the change is recorded in the frame-config ring.
> 
> In general, `doremi-frm.el' is not about frame configs; this is a side
> feature. It is about making incremental changes to frames interactively:
> color, size, position, font, faces, whatever. You do this using either a
> mouse wheel or the arrow keys (press & hold to increase/decrease a frame
> parameter until you get what you like).
> 
> After making a change that you like, you can copy it to your
> `default-frame-alist' (or another frame alist) using DoReMi commands, and
> then you can save the `default-frame-alist' change persistently using
> Customize.

Thanks, but I think this isn't quite what I am looking for.  I don't see 
how to save the size/positions of multiple frames, and then, after 
restarting emacs, to recreate, size and position a new set of frames to 
match the old saved config.

I had a bit of time over the weekend and so I bit the bullet and dug in 
to elisp enough to hack something together myself.  It's butt-ugly but 
it works.  It loops through the current frames and then writes a elisp 
function into the *scratch* buffer that will recreate the frames and set 
their size and position.  Then I can just copy that function to my 
.emacs file and M-x it when I startup.  If I want to have multiple 
layout-configs I can just change the name of the defun and have several 
of them in my .emacs file.


(defun my-save-frame-info ()
   "Save info about current emacs frames"
   (interactive)
   (let ((cbuf (current-buffer)))
     (switch-to-buffer "*scratch*")
     (goto-char (point-max))
     (insert "(defun my-make-frames ()\n  \"\"\n")
     (insert "  (interactive)\n")
     (insert "  ; delete all current frames except 1\n")
     (insert "  (while (> (length (frame-list)) 1)\n")
     (insert "    (delete-frame (nth 0 (frame-list))))\n")
     (insert "  ; size and position the remaining frame\n")
     (let ((frm (car (frame-list))))
       (insert "  (let ((frm (car (frame-list))))\n")
       (insert (format "    (set-frame-position frm %d %d)\n"
		      (frame-parameter frm 'left)
		      (frame-parameter frm 'top)))
       (insert (format "    (set-frame-size     frm %d %d))\n"
		      (frame-width frm)
		      (frame-height frm))))		
     (insert "  ; make additional frames and position them\n")
     (dolist (frm (cdr (frame-list)))
       (insert "  (let ((frm (make-frame)))\n")
       (insert (format "    (set-frame-position frm %d %d)\n"
		      (frame-parameter frm 'left)
		      (frame-parameter frm 'top)))

       (insert (format "    (set-frame-size     frm %d %d))\n"
		      (frame-width frm)
		      (frame-height frm))))
     (insert ")\n")
     (switch-to-buffer cbuf)
     (message "Look at the end of the *scratch* buffer..."))
)

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

* RE: save/restore frame positions
  2006-05-16 22:12 ` Robin Dunn
@ 2006-05-16 22:51   ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2006-05-16 22:51 UTC (permalink / raw)


A frame configuration saves the sizes and positions (and more) of all
frames. It is not, however, persistent. What you want to do is save a frame
configuration across Emacs sessions. That is the only code you would need to
write.

I believe, however, that there are already libraries that do that.
desktop.el is one that comes to mind, but I have never used it - someone
else can confirm or correct this.

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

* Re: save/restore frame positions
       [not found] <mailman.1924.1147819917.9609.help-gnu-emacs@gnu.org>
@ 2006-05-17 14:45 ` Robin Dunn
  2006-05-17 15:50   ` Drew Adams
  2006-05-17 19:37   ` Kevin Rodgers
  0 siblings, 2 replies; 9+ messages in thread
From: Robin Dunn @ 2006-05-17 14:45 UTC (permalink / raw)


Drew Adams wrote:
> A frame configuration saves the sizes and positions (and more) of all
> frames. It is not, however, persistent. What you want to do is save a frame
> configuration across Emacs sessions. That is the only code you would need to
> write.
> 
> I believe, however, that there are already libraries that do that.
> desktop.el is one that comes to mind, but I have never used it - someone
> else can confirm or correct this.

I also use desktop.el, and have for several years.  It is primarily 
focused on saving the list of buffers with their files, directories, 
point and mark and various buffer-local variables.  If it can save frame 
configs I haven't seen how to do it, but perhaps that would make a good 
extension...  If I have some more time to spend on this perhaps I will 
give it a try.

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

* RE: save/restore frame positions
  2006-05-17 14:45 ` save/restore frame positions Robin Dunn
@ 2006-05-17 15:50   ` Drew Adams
  2006-05-17 19:37   ` Kevin Rodgers
  1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2006-05-17 15:50 UTC (permalink / raw)


    > A frame configuration saves the sizes and positions (and more) of all
    > frames. It is not, however, persistent. What you want to do
    > is save a frame configuration across Emacs sessions. That is the only
    > code you would need to write.
    >
    > I believe, however, that there are already libraries that do that.
    > desktop.el is one that comes to mind, but I have never used
    > it - someone else can confirm or correct this.

    I also use desktop.el, and have for several years.  It is primarily
    focused on saving the list of buffers with their files, directories,
    point and mark and various buffer-local variables.  If it can
    save frame configs I haven't seen how to do it, but perhaps that
    would make a good extension...  If I have some more time to spend
    on this perhaps I will give it a try.

Sorry about misleading you. I don't use desktop, and I thought it restored
frames too (they are part of the "desktop", no?).

If you do extend desktop.el to do that, think about making that an option,
as some people might want to turn it off.

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

* Re: save/restore frame positions
  2006-05-17 14:45 ` save/restore frame positions Robin Dunn
  2006-05-17 15:50   ` Drew Adams
@ 2006-05-17 19:37   ` Kevin Rodgers
  1 sibling, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2006-05-17 19:37 UTC (permalink / raw)


Robin Dunn wrote:
 > Drew Adams wrote:
 >> A frame configuration saves the sizes and positions (and more) of all
 >> frames. It is not, however, persistent. What you want to do is save a
 >> frame configuration across Emacs sessions. That is the only code you
 >> would need to write.
 >>
 >> I believe, however, that there are already libraries that do that.
 >> desktop.el is one that comes to mind, but I have never used it - someone
 >> else can confirm or correct this.
 >
 > I also use desktop.el, and have for several years.  It is primarily
 > focused on saving the list of buffers with their files, directories,
 > point and mark and various buffer-local variables.  If it can save frame
 > configs I haven't seen how to do it, but perhaps that would make a good
 > extension...  If I have some more time to spend on this perhaps I will
 > give it a try.

The RegConfig node (titled "Saving Window Configurations in Registers")
of the Emacs manual suggests saving and restoring frame configurations
via a register.  And desktop-globals-to-save includes register-alist by
default.

So if you make sure you save the frame configuration in a register
before exiting, you should be able to restore it after desktop-read has
reset the global variables:

(add-hook 'desktop-save-hook
	  (lambda ()
	    (frame-configuration-to-register ?f)))

(add-hook 'desktop-after-read-hook
	  (lambda ()
	    (jump-to-register ?f)))

Does that work?

-- 
Kevin

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

* Re: save/restore frame positions
  2006-05-06 22:36 Robin Dunn
  2006-05-07  2:25 ` Drew Adams
@ 2006-05-17 22:04 ` Johan Bockgård
  1 sibling, 0 replies; 9+ messages in thread
From: Johan Bockgård @ 2006-05-17 22:04 UTC (permalink / raw)



http://www.emacswiki.org/cgi-bin/wiki/SessionManagement
-- 
Johan Bockgård

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

end of thread, other threads:[~2006-05-17 22:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1924.1147819917.9609.help-gnu-emacs@gnu.org>
2006-05-17 14:45 ` save/restore frame positions Robin Dunn
2006-05-17 15:50   ` Drew Adams
2006-05-17 19:37   ` Kevin Rodgers
     [not found] <mailman.1525.1146968778.9609.help-gnu-emacs@gnu.org>
2006-05-16 22:12 ` Robin Dunn
2006-05-16 22:51   ` Drew Adams
2006-05-06 22:36 Robin Dunn
2006-05-07  2:25 ` Drew Adams
2006-05-07  2:41   ` Drew Adams
2006-05-17 22:04 ` Johan Bockgård

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).