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

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

[elpa] externals/olivetti d40a054 126/134: Fixed olivetti-scale-width fo


From: Stefan Monnier
Subject: [elpa] externals/olivetti d40a054 126/134: Fixed olivetti-scale-width for integer heights
Date: Thu, 25 Apr 2019 09:57:43 -0400 (EDT)

branch: externals/olivetti
commit d40a054420eb0a656732f6b92f52c3ad50860da6
Author: Niels uit de Bos <address@hidden>
Commit: Niels uit de Bos <address@hidden>

    Fixed olivetti-scale-width for integer heights
    
    The function `olivetti-scale-width` incorrectly assumes that the height is
    always a fraction. However, it can in very normal circumstances be an 
integer
    such as 120 (see section 39.12.1 from the manual
    
(https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attributes.html)).
    In such a case, the old function scales the width by a number that is far 
too
    large, which results in margins of width 0.
    
    To see how this fails, set the height to something like 120 by using, for
    example, buffer-face-mode.
    
    I fixed this by scaling by height/100 if the height is an integer. If it is 
a
    float or something else entirely, the new function behaves as the old.
---
 olivetti.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/olivetti.el b/olivetti.el
index 0998e80..16c177f 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -275,11 +275,15 @@ instead `olivetti-set-mode-line'."
 
 For compatibility with `text-scale-mode', if
 `face-remapping-alist' includes a :height property on the default
-face, scale N by that factor, otherwise scale by 1."
-  (* n (or (plist-get (cadr (assq 'default
-                                  face-remapping-alist))
-                      :height)
-           1)))
+face, scale N by that factor if it is a fraction, by (height/100)
+if it is an integer, and otherwise scale by 1."
+  (let
+      ((height (plist-get (cadr (assq 'default face-remapping-alist)) 
:height)))
+    (cond
+     ((integerp height) (* n (/ height 100.0)))
+     ((floatp height) (* n height))
+     (t n))))
+
 
 (defun olivetti-safe-width (width window)
   "Parse WIDTH to a safe value for `olivetti-body-width' for WINDOW.



reply via email to

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