|
From: | Robin Dunn |
Subject: | Re: save/restore frame positions |
Date: | Tue, 16 May 2006 15:12:35 -0700 |
User-agent: | Thunderbird 1.5.0.2 (X11/20060420) |
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...")) )
[Prev in Thread] | Current Thread | [Next in Thread] |