From: Mark Wooding Date: Wed, 6 Dec 2023 14:23:02 +0000 (+0000) Subject: el/dot-emacs.el: Abstract out `mdw-frame-with-for-columns' function. X-Git-Url: https://git.distorted.org.uk/~mdw/profile/commitdiff_plain/0bb9be93c106e149d21d72d20de02da8b978bf9e el/dot-emacs.el: Abstract out `mdw-frame-with-for-columns' function. --- diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 4be3268..ed894dd 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -253,6 +253,12 @@ fringes is not taken out of the allowance for WIDTH, unlike (other-window 1)) (select-window win))) +(defun mdw-frame-width-for-columns (columns width) + "Return the preferred width for a frame with so many COLUMNS of WIDTH." + (let ((sb-width (mdw-horizontal-window-overhead))) + (- (* columns (+ width sb-width)) + sb-width))) + (defun mdw-set-frame-width (columns &optional width) "Set the current frame to be the correct width for COLUMNS columns. @@ -262,11 +268,9 @@ can be set interactively with a prefix argument.)" P") (setq width (if width (prefix-numeric-value width) (mdw-preferred-column-width))) - (let ((sb-width (mdw-horizontal-window-overhead))) - (set-frame-width (selected-frame) - (- (* columns (+ width sb-width)) - sb-width)) - (mdw-divvy-window width))) + (set-frame-width (selected-frame) + (mdw-frame-width-for-columns columns width)) + (mdw-divvy-window width)) (defcustom mdw-frame-width-fudge (cond ((<= emacs-major-version 20) 1)