roman / golden-ratio.el

Automatic resizing of Emacs windows to the golden ratio
MIT License
589 stars 38 forks source link

infinite recursing when using balance-windows #75

Open zenspider opened 7 years ago

zenspider commented 7 years ago
(defun rwd-golden-ratio-inhibitor ()
  (and (<= (length (window-list)) 2)
       (or (one-window-p) (balance-windows) t))) ; rebalance if we drop to 1-2

in certain situations, like when using elscreen, I'm hitting infinite recursion between balance-windows and the invocation of my hook via golden-ratio. A guard could prevent this from triggering while already triggering.

wictory commented 4 years ago

The golden-ratio function calls balance-windows and avoids infinite recursion by disabling golden-ratio-mode before the call. golden-ratio is calls the members of golden-ratio-inhibit-functions before inhibiting itself.

The interface of golden-ratio-inhibit-functions does not specify what side-effects are allowed, so it's fair to call this a bug. There are two solutions: 1) redefine the interface to allow calls balance-windows, or 2) disable golden-ratio-mode before calling golden-ratio-inhibit-functions.