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

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

[nongnu] elpa/visual-fill-column 5f5928fd7f 045/137: Merge pull request


From: ELPA Syncer
Subject: [nongnu] elpa/visual-fill-column 5f5928fd7f 045/137: Merge pull request #19 from cpitclaudel/master
Date: Sun, 2 Jan 2022 22:59:10 -0500 (EST)

branch: elpa/visual-fill-column
commit 5f5928fd7fc3716632b02deac58b198eeda37d84
Merge: 865c9b32ea fac6a4ce67
Author: Joost Kremers <joostkremers@fastmail.fm>
Commit: GitHub <noreply@github.com>

    Merge pull request #19 from cpitclaudel/master
    
    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]