branch: externals/olivetti
commit 3c6090814a88c14ecd302f4b3399c889801f083f
Author: Paul Rankin <[email protected]>
Commit: Paul Rankin <[email protected]>

    Made set-environment use safe-width
---
 olivetti.el | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/olivetti.el b/olivetti.el
index f80f0bc..6521ea0 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -162,18 +162,11 @@ mode line. Finally redraw the frame."
 
 (defun olivetti-set-environment ()
   "Set text body width to `olivetti-body-width' with relative margins."
-  (let* ((n olivetti-body-width)
-         (width
-          (cond ((integerp n) n)
-                ((and (floatp n)
-                      (< n 1)
-                      (> n 0))
-                 (* (window-total-width) n)))))
-    (if width
-        (let ((margin
-               (round (/ (- (window-total-width) width) 2))))
-          (set-window-margins (selected-window) margin margin))
-      (message "`olivetti-body-width' must be an integer or a float between 0 
and 1"))))
+  (let* ((n (olivetti-safe-width olivetti-body-width))
+         (width (cond ((integerp n) n)
+                      ((floatp n) (* (window-total-width) n))))
+         (margin (round (/ (- (window-total-width) width) 2))))
+    (set-window-margins (selected-window) margin margin)))
 
 (defun olivetti-toggle-hide-modeline ()
   "Toggle the visibility of the modeline.

Reply via email to