chiark / gitweb /
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 4be32686d9488b755136a2eb839cbfb54a1bfba1..ed894dd9b45af47c95f0b1ef71a746ef614aa548 100644 (file)
@@ -253,6 +253,12 @@ (defun mdw-divvy-window (&optional width)
       (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 @@ (defun mdw-set-frame-width (columns &optional width)
 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)