branch: elpa/golden-ratio commit 1325ecac07a14c3566715d3ad6b9091a4d4950d8 Author: Shou Ya <sho...@users.noreply.github.com> Commit: Shou Ya <sho...@users.noreply.github.com>
support minimal change --- golden-ratio.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/golden-ratio.el b/golden-ratio.el index 28a637d939..201cf0f270 100644 --- a/golden-ratio.el +++ b/golden-ratio.el @@ -92,6 +92,16 @@ will prevent the window to be resized to the golden ratio." :type '(repeat string) :group 'golden-ratio) +(defcustom golden-ratio-minimal-width-change 0 + "Minimal width change needed to trigger actual window resizing." + :group 'golden-ratio + :type 'integer) + +(defcustom golden-ratio-minimal-height-change 0 + "Minimal height change needed to trigger actual window resizing." + :group 'golden-ratio + :type 'integer) + ;;; Compatibility ;; (unless (fboundp 'window-resizable-p) @@ -129,9 +139,11 @@ will prevent the window to be resized to the golden ratio." (with-selected-window (or window (selected-window)) (let ((nrow (floor (- (first dimensions) (window-height)))) (ncol (floor (- (second dimensions) (window-width))))) - (when (window-resizable-p (selected-window) nrow) + (when (and (> nrow golden-ratio-minimal-height-change) + (window-resizable-p (selected-window) nrow)) (enlarge-window nrow)) - (when (window-resizable-p (selected-window) ncol t) + (when (and (> ncol golden-ratio-minimal-width-change) + (window-resizable-p (selected-window) ncol t)) (enlarge-window ncol t))))) (defun golden-ratio-exclude-major-mode-p ()