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

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

[nongnu] elpa/visual-fill-column fac6a4ce67 044/137: Take text scaling i


From: ELPA Syncer
Subject: [nongnu] elpa/visual-fill-column fac6a4ce67 044/137: Take text scaling into account when computing margins
Date: Sun, 2 Jan 2022 22:59:10 -0500 (EST)

branch: elpa/visual-fill-column
commit fac6a4ce674dbc6cc1e034f5012e8584d33dd07d
Author: Clément Pit--Claudel <clement.pitclaudel@live.com>
Commit: Clément Pit--Claudel <clement.pitclaudel@live.com>

    Take text scaling into account when computing margins
---
 visual-fill-column.el | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/visual-fill-column.el b/visual-fill-column.el
index ba560e66fd..3527ced83c 100644
--- a/visual-fill-column.el
+++ b/visual-fill-column.el
@@ -146,12 +146,22 @@ windows with wide margins."
   "Return the maximum possible text width of WINDOW.
 The maximum possible text width is the width of the current text
 area plus the margins, but excluding the fringes, scroll bar and
-right divider.  WINDOW defaults to the selected window."
+right divider.  WINDOW defaults to the selected window.  The
+return value is scaled to account for `text-scale-mode-amount'
+and `text-scale-mode-step'."
   (or window (setq window (selected-window)))
-  (let ((margins (window-margins window)))
-    (+ (window-width window)
-       (or (car margins) 0)
-       (or (cdr margins) 0))))
+  (let* ((margins (window-margins window))
+         (buffer (window-buffer window))
+         (scale (if (and (boundp 'text-scale-mode-step)
+                         (boundp 'text-scale-mode-amount))
+                    (with-current-buffer buffer
+                      (expt text-scale-mode-step
+                            text-scale-mode-amount))
+                  1.0)))
+    (truncate (/ (+ (window-width window)
+                    (or (car margins) 0)
+                    (or (cdr margins) 0))
+                 (float scale)))))
 
 (defun visual-fill-column--set-margins ()
   "Set window margins for the current window."



reply via email to

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