Last active
February 6, 2020 01:15
-
-
Save paulbdavis/9b83c0bba46ab91b96f48485b3257378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ds/handle-new-window (window) | |
(let ((new-class (window-class window)) | |
(current-class (window-class (current-window)))) | |
(let* ((frames (group-frames (current-group))) | |
(isempty (= 1 (length (group-windows (current-group))))) | |
(fx (- (screen-width (current-screen)) 5)) | |
(fy (- (screen-height (current-screen)) 30)) | |
(dir (if (= (mod (length frames) 2) 0) :row :column))) | |
(focus-frame (current-group) (find-frame (current-group) fx fy)) | |
;; (ds/split-frame-to-empty (current-group) dir 0.61803))) | |
(if (not isempty) | |
(let ((newframe (frame-by-number (current-group) (split-frame (current-group) dir 0.61803)))) | |
(focus-frame (current-group) newframe) | |
(pull-window window newframe) | |
(if (ds/group-empty-frames (current-group)) | |
(remove-split))))) | |
)) | |
(defun ds/group-empty-frames (group) | |
(remove-if-not (lambda (f) (equal nil (frame-window f))) (group-frames group))) | |
(defun ds/handle-destroy-window (window) | |
(let ((new-class (window-class window))) | |
(if (< 1 (length (group-frames (current-group)))) | |
(remove-split)))) | |
(add-hook *new-window-hook* 'ds/handle-new-window) | |
(add-hook *destroy-window-hook* 'ds/handle-destroy-window) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment