el/dot-emacs.el: Abstract out `mdw-frame-with-for-columns' function.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 6 Dec 2023 14:23:02 +0000 (14:23 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 6 Dec 2023 14:23:02 +0000 (14:23 +0000)
el/dot-emacs.el

index 4be3268..ed894dd 100644 (file)
@@ -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)