[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nlinum 02d3ccf 08/20: * nlinum.el: Use face-width if av
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nlinum 02d3ccf 08/20: * nlinum.el: Use face-width if available. Hook into text-scale-mode |
Date: |
Sat, 28 Nov 2020 18:42:23 -0500 (EST) |
branch: externals/nlinum
commit 02d3ccf1d5fcb5fa8d330578d3a10c3e53f18845
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* nlinum.el: Use face-width if available. Hook into text-scale-mode
---
nlinum.el | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/nlinum.el b/nlinum.el
index 82e274c..2505c98 100644
--- a/nlinum.el
+++ b/nlinum.el
@@ -1,10 +1,10 @@
;;; nlinum.el --- Show line numbers in the margin -*- lexical-binding: t -*-
-;; Copyright (C) 2012, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2012, 2014, 2015 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: convenience
-;; Version: 1.5
+;; Version: 1.6
;; 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
@@ -54,6 +54,7 @@ Linum mode is a buffer-local minor mode."
:lighter nil ;; (" NLinum" nlinum--desc)
(jit-lock-unregister #'nlinum--region)
(remove-hook 'window-configuration-change-hook #'nlinum--setup-window t)
+ (remove-hook 'text-scale-mode-hook #'nlinum--setup-window t)
(remove-hook 'after-change-functions #'nlinum--after-change t)
(kill-local-variable 'nlinum--line-number-cache)
(remove-overlays (point-min) (point-max) 'nlinum t)
@@ -63,6 +64,7 @@ Linum mode is a buffer-local minor mode."
;; FIXME: Another approach would be to make the mode permanent-local,
;; which might indeed be preferable.
(add-hook 'change-major-mode-hook (lambda () (nlinum-mode -1)))
+ (add-hook 'text-scale-mode-hook #'nlinum--setup-window nil t)
(add-hook 'window-configuration-change-hook #'nlinum--setup-window nil t)
(add-hook 'after-change-functions #'nlinum--after-change nil t)
(jit-lock-register #'nlinum--region t))
@@ -71,14 +73,24 @@ Linum mode is a buffer-local minor mode."
(defun nlinum--face-height (face)
(aref (font-info (face-font face)) 2))
+(defun nlinum--face-width (face) ;New info only in Emacs>=25.
+ (let ((fi (font-info (face-font face))))
+ (when (> (length fi) 11)
+ (let ((width (aref fi 11)))
+ (if (<= width 0)
+ (aref fi 10)
+ width)))))
+
(defun nlinum--setup-window ()
(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)))
+ (let ((width (nlinum--face-width 'linum)))
+ (if width
+ (/ (* nlinum--width 1.0 width)
+ (frame-char-width))
+ (/ (* nlinum--width 1.0
+ (nlinum--face-height 'linum))
+ (frame-char-height)))))
nlinum--width)))
(set-window-margins nil (if nlinum-mode width)
(cdr (window-margins)))))
- [elpa] branch externals/nlinum created (now 60d6af0), Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 37cc4b2 01/20: Add nlinum.el, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum c64e489 05/20: * packages/nlinum/nlinum.el (nlinum-mode): Don't leave overlays around when, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 5081418 02/20: * nlinum.el: Speed up by caching last line-number., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum d7dbf4a 03/20: * nlinum.el: Add global-nlinum-mode and nlinum-format-function., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 9a52252 07/20: Fixes: debbugs:17906, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 02d3ccf 08/20: * nlinum.el: Use face-width if available. Hook into text-scale-mode,
Stefan Monnier <=
- [elpa] externals/nlinum fbe07f1 09/20: * nlinum.el (nlinum--setup-window): Better preserve margin settings, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 0ef1df7 10/20: * nlinum.el: Add highlighting of the current line, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum a4ae169 12/20: nlinum.el: Make it possible to use the right margin, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum f959610 13/20: * nlinum/nlinum.el: Don't assume nlinum-use-right-margin is fixed, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 132ef19 04/20: * nlinum.el (nlinum-format): New custom variable., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum ba66199 06/20: * packages/nlinum/nlinum.el (nlinum--face-height): New function., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 16d30cf 19/20: * packages/nlinum/nlinum.el (nlinum--flush): Widen to really flush all., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 99d0fef 16/20: * packages/nlinum/nlinum.el (nlinum-widen): New custom var, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 05d0274 17/20: * packages/nlinum/nlinum.el (nlinum--check-narrowing): Flush the line-number-cache as well., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 5cda97a 11/20: * nlinum.el: Bump version to 1.7, Stefan Monnier, 2020/11/28