diff options
Diffstat (limited to 'lisp/linum.el')
| -rw-r--r-- | lisp/linum.el | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lisp/linum.el b/lisp/linum.el index d9d7e5ad120..7b6a3ea4e42 100644 --- a/lisp/linum.el +++ b/lisp/linum.el @@ -1,9 +1,9 @@ ;;; linum.el --- display line numbers in the left margin -*- lexical-binding: t -*- -;; Copyright (C) 2008-2013 Free Software Foundation, Inc. +;; Copyright (C) 2008-2015 Free Software Foundation, Inc. ;; Author: Markus Triska <markus.triska@gmx.at> -;; Maintainer: FSF +;; Maintainer: emacs-devel@gnu.org ;; Keywords: convenience ;; Version: 0.9x @@ -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,6 +138,17 @@ Linum mode is a buffer-local minor mode." (mapc #'delete-overlay linum-available) (setq linum-available nil)))) +;; 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." (goto-char (window-start win)) @@ -152,7 +163,7 @@ Linum mode is a buffer-local minor mode." (run-hooks 'linum-before-numbering-hook) ;; Create an overlay (or reuse an existing one) for each ;; line visible in this window, if necessary. - (while (and (not (eobp)) (<= (point) limit)) + (while (and (not (eobp)) (< (point) limit)) (let* ((str (if fmt (propertize (format fmt line) 'face 'linum) (funcall linum-format line))) @@ -178,6 +189,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) |
