From 078e38fb576dbd91fb92b7bca89d4a9d47f88e79 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 13 Nov 2015 15:14:06 +0100 Subject: Cleaning code for auto width adapting. Less guessing, separate guessing code. --- generic/pg-response.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'generic') diff --git a/generic/pg-response.el b/generic/pg-response.el index e278cec3..e903858e 100644 --- a/generic/pg-response.el +++ b/generic/pg-response.el @@ -130,6 +130,18 @@ Internal variable, setting this will have no effect!") (defun proof-three-window-enable () (proof-layout-windows)) + +(defun proof-guess-3win-display-policy (&optional policy) + "Return the 3 windows mode layout policy from user choice POLICY. +If POLIY is smart then guess the good policy from the current +frame geometry, otherwise follow POLICY." + (if (eq policy 'smart) + (cond + ((>= (frame-width) (* 1.5 split-width-threshold)) 'horizontal) + ((>= (frame-width) split-width-threshold) 'hybrid) + (t 'vertical)) + policy)) + (defun proof-select-three-b (b1 b2 b3 &optional policy) "Put the given three buffers into three windows. Following POLICY, which can be one of 'smart, 'horizontal, @@ -137,15 +149,7 @@ Following POLICY, which can be one of 'smart, 'horizontal, (interactive "bBuffer1:\nbBuffer2:\nbBuffer3:") (delete-other-windows) (switch-to-buffer b1) - (let ((pol)) - (if (eq policy 'smart) - (cond - ((>= (frame-width) (* 1.5 split-width-threshold)) - (setq pol 'horizontal)) - ((>= (frame-width) split-width-threshold) - (setq pol 'hybrid)) - (t (setq pol 'vertical))) - (setq pol policy)) + (let ((pol (proof-guess-3win-display-policy policy))) (save-selected-window (cond ((eq pol 'hybrid) -- cgit v1.2.3