unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Robin Dunn <robin@alldunn.com>
Subject: Re: save/restore frame positions
Date: Tue, 16 May 2006 15:12:35 -0700	[thread overview]
Message-ID: <126kjinjst5ul02@corp.supernews.com> (raw)
In-Reply-To: <mailman.1525.1146968778.9609.help-gnu-emacs@gnu.org>

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

       reply	other threads:[~2006-05-16 22:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1525.1146968778.9609.help-gnu-emacs@gnu.org>
2006-05-16 22:12 ` Robin Dunn [this message]
2006-05-16 22:51   ` save/restore frame positions Drew Adams
     [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
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

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=126kjinjst5ul02@corp.supernews.com \
    --to=robin@alldunn.com \
    /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.
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).