emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117497: * lisp/linum.el (linum--face-height): New f


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r117497: * lisp/linum.el (linum--face-height): New function.
Date: Tue, 08 Jul 2014 19:33:43 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117497
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17813
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2014-07-08 15:33:37 -0400
message:
  * lisp/linum.el (linum--face-height): New function.
  (linum-update-window): Use it to adjust margin to linum's width.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/linum.el                  linum.el-20091113204419-o5vbwnq5f7feedwu-8259
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-07-08 19:15:28 +0000
+++ b/lisp/ChangeLog    2014-07-08 19:33:37 +0000
@@ -1,5 +1,8 @@
 2014-07-08  Stefan Monnier  <address@hidden>
 
+       * 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.

=== modified file 'lisp/linum.el'
--- a/lisp/linum.el     2014-02-10 01:34:22 +0000
+++ b/lisp/linum.el     2014-07-08 19:33:37 +0000
@@ -138,6 +138,9 @@
       (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 @@
       (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)


reply via email to

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