[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nlinum c64e489 05/20: * packages/nlinum/nlinum.el (nlin
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nlinum c64e489 05/20: * packages/nlinum/nlinum.el (nlinum-mode): Don't leave overlays around when |
Date: |
Sat, 28 Nov 2020 18:42:22 -0500 (EST) |
branch: externals/nlinum
commit c64e48952fe7bb494f57e0a803ae0546b31de09d
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* packages/nlinum/nlinum.el (nlinum-mode): Don't leave overlays around when
switching major mode.
---
nlinum.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/nlinum.el b/nlinum.el
index 750ebc0..41b79b6 100644
--- a/nlinum.el
+++ b/nlinum.el
@@ -54,12 +54,15 @@ 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 'after-change-functions #'nlinum--after-change)
+ (remove-hook 'after-change-functions #'nlinum--after-change t)
(kill-local-variable 'nlinum--line-number-cache)
(remove-overlays (point-min) (point-max) 'nlinum t)
;; (kill-local-variable 'nlinum--ol-counter)
(kill-local-variable 'nlinum--width)
(when nlinum-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 '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))
@@ -136,6 +139,14 @@ Linum mode is a buffer-local minor mode."
(defvar nlinum--line-number-cache nil)
(make-variable-buffer-local 'nlinum--line-number-cache)
+;; We could try and avoid flushing the cache at every change, e.g. with:
+;; (defun nlinum--before-change (start _end)
+;; (if (and nlinum--line-number-cache
+;; (< start (car nlinum--line-number-cache)))
+;; (save-excursion (goto-char start) (nlinum--line-number-at-pos))))
+;; But it's far from clear that it's worth the trouble. The current simplistic
+;; approach seems to be good enough in practice.
+
(defun nlinum--after-change (&rest _args)
(setq nlinum--line-number-cache nil))
- [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 <=
- [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, 2020/11/28
- [elpa] externals/nlinum ba66199 06/20: * packages/nlinum/nlinum.el (nlinum--face-height): New function., Stefan Monnier, 2020/11/28