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

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

[elpa] externals/nlinum ba66199 06/20: * packages/nlinum/nlinum.el (nlin


From: Stefan Monnier
Subject: [elpa] externals/nlinum ba66199 06/20: * packages/nlinum/nlinum.el (nlinum--face-height): New function.
Date: Sat, 28 Nov 2020 18:42:23 -0500 (EST)

branch: externals/nlinum
commit ba66199f7eac118f0d7c29df44981cc10d908d33
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * packages/nlinum/nlinum.el (nlinum--face-height): New function.
    (nlinum--setup-window): Use it.
---
 nlinum.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/nlinum.el b/nlinum.el
index 41b79b6..8719e92 100644
--- a/nlinum.el
+++ b/nlinum.el
@@ -4,7 +4,7 @@
 
 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
 ;; Keywords: convenience
-;; Version: 1.3
+;; Version: 1.4
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -68,9 +68,18 @@ Linum mode is a buffer-local minor mode."
     (jit-lock-register #'nlinum--region t))
   (nlinum--setup-windows))
 
+(defun nlinum--face-height (face)
+  (aref (font-info (face-font face)) 2))
+
 (defun nlinum--setup-window ()
-  (set-window-margins nil (if nlinum-mode nlinum--width)
-                      (cdr (window-margins))))
+  (let ((width (ceiling
+                ;; We'd really want to check the widths rather than the
+                ;; heights, but it's a start.
+                (/ (* nlinum--width 1.0
+                      (nlinum--face-height 'linum))
+                   (frame-char-height)))))
+    (set-window-margins nil (if nlinum-mode width)
+                        (cdr (window-margins)))))
 
 (defun nlinum--setup-windows ()
   (dolist (win (get-buffer-window-list nil nil t))



reply via email to

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