Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

be independent of frame size, avoiding breakage on different-sized screen; pretty-print workgroups file, for easier edit/diff #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions workgroups.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -627,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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down