el/dot-emacs.el: Abstract out the frame column-width logic.
[profile] / el / dot-emacs.el
index d99134d..24d076d 100644 (file)
@@ -200,13 +200,16 @@ fringes is not taken out of the allowance for WIDTH, unlike
         ((>= width 0) (+ width (mdw-horizontal-window-overhead)))
         ((< width 0) width))))
 
+(defun mdw-preferred-column-width ()
+  "Return the preferred column width."
+  (if (and window-system (mdw-emacs-version-p 22)) mdw-column-width
+    (1+ mdw-column-width)))
+
 (defun mdw-divvy-window (&optional width)
   "Split a wide window into appropriate widths."
   (interactive "P")
-  (setq width (cond (width (prefix-numeric-value width))
-                   ((and window-system (mdw-emacs-version-p 22))
-                    mdw-column-width)
-                   (t (1+ mdw-column-width))))
+  (setq width (if width (prefix-numeric-value width)
+               (mdw-preferred-column-width)))
   (let* ((win (selected-window))
         (sb-width (mdw-horizontal-window-overhead))
         (c (/ (+ (window-width) sb-width)
@@ -220,10 +223,8 @@ fringes is not taken out of the allowance for WIDTH, unlike
 (defun mdw-set-frame-width (columns &optional width)
   (interactive "nColumns: 
 P")
-  (setq width (cond (width (prefix-numeric-value width))
-                   ((and window-system (mdw-emacs-version-p 22))
-                    mdw-column-width)
-                   (t (1+ mdw-column-width))))
+  (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))