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

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

[nongnu] elpa/visual-fill-column 60d8a031d5 017/137: Do not use `window-


From: ELPA Syncer
Subject: [nongnu] elpa/visual-fill-column 60d8a031d5 017/137: Do not use `window-total-width'.
Date: Sun, 2 Jan 2022 22:59:08 -0500 (EST)

branch: elpa/visual-fill-column
commit 60d8a031d54ffa9d7878706df9b0c5b1a52d249d
Author: Joost Kremers <joostkremers@fastmail.fm>
Commit: Joost Kremers <joostkremers@fastmail.fm>

    Do not use `window-total-width'.
    
    Calculate window width on the basis of `window-width' and the width of
    the margins instead.
---
 visual-fill-column.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/visual-fill-column.el b/visual-fill-column.el
index 940443e899..4c71afa392 100644
--- a/visual-fill-column.el
+++ b/visual-fill-column.el
@@ -100,11 +100,22 @@ in which `visual-line-mode' is active as well."
   (set-window-fringes (selected-window) nil nil 
visual-fill-column-fringes-outside-margins)
   (visual-fill-column--set-margins))
 
+(defun visual-fill-column--window-body-width (&optional window)
+  "Return the body width of WINDOW.
+The body width here refers to the width of the text area plus the
+margins, but excluding the fringes, scroll bar and right
+divider. WINDOW defaults to the selected window."
+  (or window (setq window (selected-window)))
+  (let ((margins (window-margins window)))
+    (+ (window-width window)
+       (or (car margins) 0)
+       (or (cdr margins) 0))))
+
 (defun visual-fill-column--set-margins ()
   "Set window margins for the current window."
   ;; calculate left & right margins
   (let* ((window (selected-window))
-         (total-width (window-total-width window))
+         (total-width (visual-fill-column--window-body-width window))
          (width (or visual-fill-column-width
                     fill-column))
          (margins (if (< (- total-width width) 0) ; margins must be >= 0



reply via email to

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