]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/linum.el (linum--face-height): New function.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 8 Jul 2014 19:33:37 +0000 (15:33 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 8 Jul 2014 19:33:37 +0000 (15:33 -0400)
(linum-update-window): Use it to adjust margin to linum's width.

Fixes: debbugs:17813
lisp/ChangeLog
lisp/linum.el

index 6dbd14f6a48112f2a71125814a519d0a6582bee5..0158ce91aeafef39d359eef68562f13cd9e73e8b 100644 (file)
@@ -1,5 +1,8 @@
 2014-07-08  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * linum.el (linum--face-height): New function (bug#17813).
+       (linum-update-window): Use it to adjust margin to linum's width.
+
        * leim/quail/sisheng.el (sisheng-list): Don't bother with-case-table.
        * eshell/em-smart.el (eshell-smart-scroll-window): Use
        with-selected-window.
index bbf7ebec3998e6b2d45054e239400f9949b9be7f..b13bd8dbbb6ad5780feeaff6788a2f9f424ade40 100644 (file)
@@ -138,6 +138,9 @@ Linum mode is a buffer-local minor mode."
       (mapc #'delete-overlay linum-available)
       (setq linum-available nil))))
 
+(defun linum--face-height (face)
+  (aref (font-info (face-font face)) 2))
+
 (defun linum-update-window (win)
   "Update line numbers for the portion visible in window WIN."
   (goto-char (window-start win))
@@ -178,6 +181,12 @@ Linum mode is a buffer-local minor mode."
       (let ((inhibit-point-motion-hooks t))
         (forward-line))
       (setq line (1+ line)))
+    (when (display-graphic-p)
+      (setq width (ceiling
+                   ;; We'd really want to check the widths rather than the
+                   ;; heights, but it's a start.
+                   (/ (* width 1.0 (linum--face-height 'linum))
+                      (frame-char-height)))))
     (set-window-margins win width (cdr (window-margins win)))))
 
 (defun linum-after-change (beg end _len)