From df985862d49e5cebd8541fb98fb48f7d6d7e5e50 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 17 Jan 2013 15:03:32 -0800 Subject: [PATCH 1/2] replace wg-restore-position with wg-restore-frame-position and wg-restore-frame-size, both disabled by default --- workgroups.el | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/workgroups.el b/workgroups.el index 4dccd65..e1ef1b2 100644 --- a/workgroups.el +++ b/workgroups.el @@ -151,8 +151,13 @@ Also used when a window's buffer can't be restored." :type 'string :group 'workgroups) -(defcustom wg-restore-position nil - "Non-nil means restore frame position on workgroup restore." +(defcustom wg-restore-frame-size nil + "Non-nil means restore frame size, in graphical emacs, on workgroup restore." + :type 'boolean + :group 'workgroups) + +(defcustom wg-restore-frame-position nil + "Non-nil means restore frame position, in graphical emacs, on workgroup restore." :type 'boolean :group 'workgroups) @@ -876,6 +881,21 @@ WCONFIG's height." "Set FRAME's size to WCONFIG's, returning a possibly scaled wtree. If the frame size was set correctly, return WCONFIG's wtree unchanged. If it wasn't, return a copy of WCONFIG's wtree scaled +with `wg-scale-wconfigs-wtree' to fit the frame as it exists." + (let ((frame (or frame (selected-frame)))) + (wg-abind wconfig ((wcwidth width) (wcheight height)) + (when (and wg-restore-frame-size window-system wcwidth wcheight) + (set-frame-size frame wcwidth wcheight)) + (let ((fwidth (frame-parameter frame 'width)) + (fheight (frame-parameter frame 'height))) + (if (and (= wcwidth fwidth) (= wcheight fheight)) + (wg-wtree wconfig) + (wg-scale-wconfigs-wtree wconfig fwidth fheight)))))) + +(defun w-frame-scale-wtree (wconfig &optional frame) + "Set FRAME's size to WCONFIG's, returning a possibly scaled wtree. +If the frame size was set correctly, return WCONFIG's wtree +unchanged. If it wasn't, return a copy of WCONFIG's wtree scaled with `wg-scale-wconfigs-wtree' to fit the frame as it exists." (let ((frame (or frame (selected-frame)))) (wg-abind wconfig ((wcwidth width) (wcheight height)) @@ -1061,7 +1081,7 @@ Return the buffer if it was found, nil otherwise." (let ((frame (selected-frame)) wtree) (wg-abind wconfig (left top sbars sbwid) (setq wtree (w-set-frame-size-and-scale-wtree wconfig frame)) - (when (and wg-restore-position left top) + (when (and wg-restore-frame-position window-system left top) (set-frame-position frame left top)) (when (and wg-morph-on after-init-time) (wg-morph (wg-ewtree->wtree) wtree wg-morph-no-error)) From e789c2ffd53f69c6a0e3bd84fbc72266d62f1fe4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 17 Jan 2013 15:04:22 -0800 Subject: [PATCH 2/2] pretty-print the saved workgroups, for easier editing/diffing --- workgroups.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workgroups.el b/workgroups.el index e1ef1b2..fe0be6b 100644 --- a/workgroups.el +++ b/workgroups.el @@ -632,7 +632,7 @@ variable, and the cadr as the key." "Write the printable representation of SEXP to FILE." (with-temp-buffer (let (print-level print-length) - (insert (format "%S" sexp)) + (insert (pp sexp)) (write-file file)))) (defun wg-read-sexp-from-file (file)