[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nlinum 132ef19 04/20: * nlinum.el (nlinum-format): New
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nlinum 132ef19 04/20: * nlinum.el (nlinum-format): New custom variable. |
Date: |
Sat, 28 Nov 2020 18:42:22 -0500 (EST) |
branch: externals/nlinum
commit 132ef194fb5e1690db961b22c0b4a6bb561893de
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* nlinum.el (nlinum-format): New custom variable.
(nlinum--region): Change calling convention of nlinum-format-function.
(nlinum-format-function): Change default value accordingly; Use
nlinum-format;
Try to generate less garbage.
---
nlinum.el | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/nlinum.el b/nlinum.el
index 40d6214..750ebc0 100644
--- a/nlinum.el
+++ b/nlinum.el
@@ -4,7 +4,7 @@
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: convenience
-;; Version: 1.2
+;; Version: 1.3
;; 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
@@ -26,6 +26,10 @@
;;; News:
+;; v1.3:
+;; - New custom variable `nlinum-format'.
+;; - Change in calling convention of `nlinum-format-function'.
+
;; v1.2:
;; - New global mode `global-nlinum-mode'.
;; - New config var `nlinum-format-function'.
@@ -77,6 +81,8 @@ Linum mode is a buffer-local minor mode."
(lambda (buf)
(with-current-buffer buf
(with-silent-modifications
+ ;; FIXME: only remove `fontified' on those parts of the
+ ;; buffer that had an nlinum overlay!
(remove-text-properties
(point-min) (point-max) '(fontified)))))
(current-buffer)))
@@ -149,14 +155,24 @@ Linum mode is a buffer-local minor mode."
(setq nlinum--line-number-cache (cons (point) pos))
pos))
+(defcustom nlinum-format "%d"
+ "Format of the line numbers.
+Used by the default `nlinum-format-function'."
+ :type 'string
+ :group 'linum)
+
(defvar nlinum-format-function
- (lambda (line)
- (let* ((fmt (format "%%%dd" nlinum--width))
- (str (propertize (format fmt line) 'face 'linum)))
+ (lambda (line width)
+ (let ((str (format nlinum-format line)))
+ (when (< (length str) width)
+ ;; Left pad to try and right-align the line-numbers.
+ (setq str (concat (make-string (- width (length str)) ?\ ) str)))
+ (put-text-property 0 width 'face 'linum str)
str))
"Function to build the string representing the line number.
-Takes one argument (the line number) and returns a string whose width
-should be at least equal to `nlinum--width'.")
+Takes 2 arguments LINE and WIDTH, both of them numbers, and should return
+a string. WIDTH is the ideal width of the result. If the result is larger,
+it may cause the margin to be resized and line numbers to be recomputed.")
(defun nlinum--region (start limit)
(save-excursion
@@ -170,7 +186,8 @@ should be at least equal to `nlinum--width'.")
(while
(and (not (eobp)) (< (point) limit)
(let* ((ol (make-overlay (point) (1+ (point))))
- (str (funcall nlinum-format-function line))
+ (str (funcall nlinum-format-function
+ line nlinum--width))
(width (string-width str)))
(when (< nlinum--width width)
(setq nlinum--width width)
- [elpa] externals/nlinum 37cc4b2 01/20: Add nlinum.el, (continued)
- [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, 2020/11/28
- [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 <=
- [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
- [elpa] externals/nlinum 8fd46ee 14/20: Fix nlinum face height function (Bug#26552), Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 7b18687 15/20: * packages/nlinum/nlinum.el: Bump version to 1.8.1., Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum 60d6af0 20/20: * .gitignore: New file, Stefan Monnier, 2020/11/28
- [elpa] externals/nlinum ac8059b 18/20: * packages/nlinum/nlinum.el (nlinum--check-narrowing): Reset current-line, Stefan Monnier, 2020/11/28