X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/590892e2edc0811fb977454f0839dec2a880a8e1..6517ec8921438deae6547ab5eb38e004935d5618:/packages/nlinum/nlinum.el diff --git a/packages/nlinum/nlinum.el b/packages/nlinum/nlinum.el index 41b79b6f4..82e274c7a 100644 --- a/packages/nlinum/nlinum.el +++ b/packages/nlinum/nlinum.el @@ -4,7 +4,7 @@ ;; Author: Stefan Monnier ;; Keywords: convenience -;; Version: 1.3 +;; Version: 1.5 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -68,9 +68,20 @@ Linum mode is a buffer-local minor mode." (jit-lock-register #'nlinum--region t)) (nlinum--setup-windows)) +(defun nlinum--face-height (face) + (aref (font-info (face-font face)) 2)) + (defun nlinum--setup-window () - (set-window-margins nil (if nlinum-mode nlinum--width) - (cdr (window-margins)))) + (let ((width (if (display-graphic-p) + (ceiling + ;; We'd really want to check the widths rather than the + ;; heights, but it's a start. + (/ (* nlinum--width 1.0 + (nlinum--face-height 'linum)) + (frame-char-height))) + nlinum--width))) + (set-window-margins nil (if nlinum-mode width) + (cdr (window-margins))))) (defun nlinum--setup-windows () (dolist (win (get-buffer-window-list nil nil t))