]> code.delx.au - gnu-emacs/blobdiff - lisp/linum.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / linum.el
index 23e560596b3141be592cc0ce6835452a73131ccd..de15274314cedee97cc8a7535d86da0e1ecb6b99 100644 (file)
@@ -138,6 +138,14 @@ Linum mode is a buffer-local minor mode."
       (mapc #'delete-overlay linum-available)
       (setq linum-available nil))))
 
+(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."
   (goto-char (window-start win))
@@ -178,6 +186,10 @@ 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
+                   (/ (* 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)