emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/olivetti 8558589 111/134: Rewrite olivetti-set-environm


From: Stefan Monnier
Subject: [elpa] externals/olivetti 8558589 111/134: Rewrite olivetti-set-environment
Date: Thu, 25 Apr 2019 09:57:39 -0400 (EDT)

branch: externals/olivetti
commit 8558589d453b992714f26ac3325e066354396684
Author: Paul Rankin <address@hidden>
Commit: Paul Rankin <address@hidden>

    Rewrite olivetti-set-environment
    
    - separate left/right margin values compensating for differing fringe values
---
 olivetti.el | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/olivetti.el b/olivetti.el
index 09bc0e4..19ab010 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -185,25 +185,22 @@ find the `olivetti-safe-width' to which to set
 relative to each window. Finally set the window margins, taking
 care that the maximum size is 0."
   (dolist (window (get-buffer-window-list nil nil t))
-    (let* ((n (olivetti-safe-width (if (integerp olivetti-body-width)
-                                       (olivetti-scale-width 
olivetti-body-width)
-                                     olivetti-body-width)
-                                   window))
-           (fringes (window-fringes window))
-           (window-width (- (window-total-width window)
-                            (+ (/ (car fringes)
-                                  (float (frame-char-width)))
-                               (/ (cadr fringes)
-                                  (float (frame-char-width))))))
-           (width (cond ((integerp n) n)
-                        ((floatp n) (* window-width
-                                       n))))
-           (margin (max (round (/ (- window-width
-                                     width)
-                                  2))
-                        0)))
+    (olivetti-reset-window window)
+    (let ((width (olivetti-safe-width olivetti-body-width window))
+          (window-width (window-total-width window))
+          (fringes (window-fringes window))
+          left-fringe right-fringe margin-total left-margin right-margin)
+      (cond ((integerp width)
+             (setq width (olivetti-scale-width width)))
+            ((floatp width)
+             (setq width (* window-width width))))
+      (setq left-fringe (/ (car fringes) (float (frame-char-width frame)))
+            right-fringe (/ (cadr fringes) (float (frame-char-width frame))))
+      (setq margin-total (max (/ (- window-width width) 2) 0)
+            left-margin (max (round (- margin-total left-fringe)) 0)
+            right-margin (max (round (- margin-total right-fringe)) 0))
       (set-window-parameter window 'split-window 'olivetti-split-window)
-      (set-window-margins window margin margin))
+      (set-window-margins window left-margin right-margin))
     (if olivetti-hide-mode-line (olivetti-set-mode-line))))
 
 (defun olivetti-reset-all-windows ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]