[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/goldenratio 7593ba59b3 79/95: Merge pull request #48 from
From: 
ELPA Syncer 
Subject: 
[nongnu] elpa/goldenratio 7593ba59b3 79/95: Merge pull request #48 from aboabo/master 
Date: 
Thu, 7 Sep 2023 22:02:15 0400 (EDT) 
branch: elpa/goldenratio
commit 7593ba59b35b3c788e5a93865aed04d31b9c6291
Merge: d5413c832b e47c29f87e
Author: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Commit: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Merge pull request #48 from aboabo/master
Simplify `goldenratiomode'

goldenratio.el  91 +++++++++++++++++++++
1 file changed, 34 insertions(+), 57 deletions()
diff git a/goldenratio.el b/goldenratio.el
index d32d73de92..67970fe91e 100644
 a/goldenratio.el
+++ b/goldenratio.el
@@ 115,9 +115,14 @@ will not cause the window to be resized to the golden
ratio."
(withselectedwindow (or window (selectedwindow))
(let ((nrow (floor ( (first dimensions) (windowheight))))
(ncol (floor ( (second dimensions) (windowwidth)))))
 (when (windowresizablep (selectedwindow) nrow)
+ (when (and
+ (windowresizablep (selectedwindow) nrow)
+ ;; don't enlarge ignored windows
+ (> nrow 0))
(enlargewindow nrow))
 (when (windowresizablep (selectedwindow) ncol t)
+ (when (and (windowresizablep (selectedwindow) ncol t)
+ ;; don't enlarge ignored windows
+ (> ncol 0))
(enlargewindow ncol t)))))
(defun goldenratioexcludemajormodep ()
@@ 126,70 +131,42 @@ will not cause the window to be resized to the golden
ratio."
(member (symbolname majormode)
goldenratioexcludemodes)))
+(defvar goldenratioinprogress nil
+ "Avoid recursive adjustment.")
+
;;;###autoload
(defun goldenratio ()
"Resizes current window to the goldenratio's size specs."
(interactive)
 (unless (or (not goldenratiomode)
 (windowminibufferp)
 (onewindowp)
 (goldenratioexcludemajormodep)
 (member (buffername)
 goldenratioexcludebuffernames)
 (and goldenratioinhibitfunctions
 (loop for fun in goldenratioinhibitfunctions
 thereis (funcall fun))))
 (let ((dims (goldenratiodimensions))
 (goldenratiomode nil))
 ;; Always disable `goldenratiomode' to avoid
 ;; infinite loop in `balancewindows'.
 (balancewindows)
 (goldenratioresizewindow dims)
 (when goldenratiorecenter
 (scrollright) (recenter)))))

;; Should return nil
(defadvice otherwindow
 (after goldenratioresizewindow)
 (goldenratio) nil)

;; Should return the buffer
(defadvice poptobuffer
 (around goldenratioresizewindow)
 (prog1 addoit (goldenratio)))

(defun goldenratiopostcommandhook ()
 (when (or (memq thiscommand goldenratioextracommands)
 (and (consp thiscommand) ; A lambda form.
 (loop for com in goldenratioextracommands
 thereis (or (memq com thiscommand)
 (memq (carsafe com) thiscommand)))))
 ;; This is needed in emacs25 to avoid this error from `recenter':
 ;; `recenter'ing a window that does not display currentbuffer.
 ;; This doesn't happen in emacs24.4 and previous versions.
 (runwithidletimer 0.01 nil (lambda () (goldenratio)))))

(defun goldenratiomouseleavebufferhook ()
 (runattime 0.1 nil (lambda ()
 (goldenratio))))
+ (when (and goldenratiomode
+ (not goldenratioinprogress))
+ (let ((goldenratioinprogress t))
+ (unless (or (windowminibufferp)
+ (onewindowp)
+ (goldenratioexcludemajormodep)
+ (member (buffername)
+ goldenratioexcludebuffernames)
+ (and goldenratioinhibitfunctions
+ (loop for fun in goldenratioinhibitfunctions
+ thereis (funcall fun))))
+ (balancewindows)
+ (goldenratioresizewindow (goldenratiodimensions))
+ (when goldenratiorecenter
+ (scrollright) (recenter))))))
+
+(defadvice selectwindow (after goldenratioselectwindow activate)
+ (when goldenratiomode
+ (goldenratio)))
+
+(defadvice splitwindow (after goldenratioselectwindow activate)
+ (when goldenratiomode
+ (goldenratio)))
;;;###autoload
(defineminormode goldenratiomode
"Enable automatic window resizing with golden ratio."
:lighter " Golden"
 :global t
 (if goldenratiomode
 (progn
 (addhook 'windowconfigurationchangehook 'goldenratio)
 (addhook 'postcommandhook 'goldenratiopostcommandhook)
 (addhook 'mouseleavebufferhook
'goldenratiomouseleavebufferhook)
 (adactivate 'otherwindow)
 (adactivate 'poptobuffer))
 (removehook 'windowconfigurationchangehook 'goldenratio)
 (removehook 'postcommandhook 'goldenratiopostcommandhook)
 (removehook 'mouseleavebufferhook
'goldenratiomouseleavebufferhook)
 (addeactivate 'otherwindow)
 (addeactivate 'poptobuffer)))
+ :global t)
(provide 'goldenratio)
 [nongnu] elpa/goldenratio cbd076aa12 62/95: Merge pull request #34 from hickinbottoms/fixmousewindowselect, (continued)
 [nongnu] elpa/goldenratio cbd076aa12 62/95: Merge pull request #34 from hickinbottoms/fixmousewindowselect, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 6173b7c416 64/95: Prevent recenter error in postcommandhook for emacs25., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 64ceb4f0c8 68/95: Added widescreens header to readme., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio c506ddc04a 66/95: Added explanation of goldenratioadjust., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio b343baac28 69/95: Added automatic scaling of width according to frame size., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio d5413c832b 75/95: Fix types in goldenratioexcludemodes., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio e47c29f87e 78/95: Trigger after splitwindow as well, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio f7bee8e221 65/95: Added width adjustment to adjust for very wide frames., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 76f5307ad0 72/95: Merge pull request #43 from EricGebhart/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 0287ac76fd 76/95: Simplify `goldenratiomode', ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 7593ba59b3 79/95: Merge pull request #48 from aboabo/master,
ELPA Syncer <=
 [nongnu] elpa/goldenratio ac9bcedc63 81/95: Reenable improvements removed by error when reverting last PR., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 5e5b6c805b 85/95: Call windowconfigurationchangehook only once, after the goldenratio command., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio c5e916d238 86/95: Add fixed width feature, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio f5807212d3 88/95: Merge pull request #81 from wictory/pr_20190406, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 1325ecac07 92/95: support minimal change, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 656117e490 93/95: change default minimal change to 1, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio bf0035fd6a 95/95: Merge pull request #89 from skangas/nongnuelpafixes, ELPA Syncer, 2023/09/07