]> code.delx.au - gnu-emacs/blobdiff - lisp/linum.el
Add a link from Tool Bar to Images
[gnu-emacs] / lisp / linum.el
index b13bd8dbbb6ad5780feeaff6788a2f9f424ade40..d49ccb356ff7cd720ada5c8f9da0e87c7f424ac6 100644 (file)
@@ -1,6 +1,6 @@
 ;;; linum.el --- display line numbers in the left margin -*- lexical-binding: t -*-
 
-;; Copyright (C) 2008-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2016 Free Software Foundation, Inc.
 
 ;; Author: Markus Triska <markus.triska@gmx.at>
 ;; Maintainer: emacs-devel@gnu.org
@@ -62,7 +62,7 @@ See also `linum-before-numbering-hook'."
 
 (defcustom linum-eager t
   "Whether line numbers should be updated after each command.
-The conservative setting `nil' might miss some buffer changes,
+The conservative setting nil might miss some buffer changes,
 and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
   :group 'linum
   :type 'boolean)
@@ -138,8 +138,16 @@ 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))
+;; Behind display-graphic-p test.
+(declare-function font-info "font.c" (name &optional frame))
+
+(defun linum--face-width (face)
+  (let ((info (font-info (face-font face)))
+       width)
+    (setq width (aref info 11))
+    (if (<= width 0)
+       (setq width (aref info 10)))
+    width))
 
 (defun linum-update-window (win)
   "Update line numbers for the portion visible in window WIN."
@@ -183,10 +191,8 @@ Linum mode is a buffer-local minor mode."
       (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)))))
+                   (/ (* width 1.0 (linum--face-width 'linum))
+                      (frame-char-width)))))
     (set-window-margins win width (cdr (window-margins win)))))
 
 (defun linum-after-change (beg end _len)