summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2014-07-08 15:33:37 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2014-07-08 15:33:37 -0400
commitdff76c18cce008747c917a3e5f79d242338c7884 (patch)
tree8a1e9eb9482440ea1ce6d22678cc6c033e5afbdb /lisp
parent78478ff63638bafb83ddd5e34f242210833c1f1e (diff)
downloademacs-dff76c18cce008747c917a3e5f79d242338c7884.tar.gz
* lisp/linum.el (linum--face-height): New function.
(linum-update-window): Use it to adjust margin to linum's width. Fixes: debbugs:17813
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/linum.el9
2 files changed, 12 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6dbd14f6a48..0158ce91aea 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
2014-07-08 Stefan Monnier <monnier@iro.umontreal.ca>
+ * 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.
diff --git a/lisp/linum.el b/lisp/linum.el
index bbf7ebec399..b13bd8dbbb6 100644
--- a/lisp/linum.el
+++ b/lisp/linum.el
@@ -138,6 +138,9 @@ 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))
+
(defun linum-update-window (win)
"Update line numbers for the portion visible in window WIN."
(goto-char (window-start win))
@@ -178,6 +181,12 @@ 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
+ ;; 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)