branch: elpa/golden-ratio
commit 95a06337338010378461655174c9fa30629ba350
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>
* golden-ratio.el: Finally allow reusing balance-windows safely. Most
issues fixed now.
(golden-ratio): Allow reuse of balance-windows by disabling
golden-ratio-mode.
(golden-ratio--window-height-after-balance,
golden-ratio--window-width-after-balance): Get rid of them, removed.
---
golden-ratio.el | 32 ++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/golden-ratio.el b/golden-ratio.el
index 825d4d2043..6cbdb5f059 100644
--- a/golden-ratio.el
+++ b/golden-ratio.el
@@ -68,32 +68,13 @@ will not cause the window to be resized to the golden
ratio."
(defun golden-ratio--resize-window (dimensions &optional window)
(with-selected-window (or window (selected-window))
- (let ((nrow (floor (- (first dimensions)
- (golden-ratio--window-height-after-balance))))
- (ncol (floor (- (second dimensions)
- (golden-ratio--window-width-after-balance)))))
+ (let ((nrow (floor (- (first dimensions) (window-height))))
+ (ncol (floor (- (second dimensions) (window-width)))))
(when (window-resizable-p (selected-window) nrow)
(enlarge-window nrow))
(when (window-resizable-p (selected-window) ncol t)
(enlarge-window ncol t)))))
-(defun golden-ratio--window-width-after-balance ()
- (let* ((size-ls (loop for i in (window-list)
- unless (window-full-width-p i)
- collect (window-width i)))
- (len (length size-ls))
- (width (and size-ls (floor (/ (apply #'+ size-ls) len)))))
- (if width (min (window-width) width) (window-width))))
-
-(defun golden-ratio--window-height-after-balance ()
- (let* ((size-ls (loop for i in (window-list)
- unless (or (window-full-height-p i)
- (not (window-full-width-p i)))
- collect (window-height i)))
- (len (length size-ls))
- (height (and size-ls (floor (/ (apply #'+ size-ls) len)))))
- (if height (min (window-height) height) (window-height))))
-
;;;###autoload
(defun golden-ratio ()
"Resizes current window to the golden-ratio's size specs."
@@ -107,10 +88,13 @@ will not cause the window to be resized to the golden
ratio."
(and golden-ratio-inhibit-functions
(loop for fun in golden-ratio-inhibit-functions
always (funcall fun))))
- (let ((dims (golden-ratio--dimensions)))
+ (let ((dims (golden-ratio--dimensions))
+ (golden-p golden-ratio-mode))
+ (and golden-p (golden-ratio-mode -1))
+ (balance-windows)
(golden-ratio--resize-window dims)
- (scroll-left)
- (recenter))))
+ (scroll-right) (recenter)
+ (and golden-p (golden-ratio-mode 1)))))
;; Should return nil
(defadvice other-window