[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nlinum fbe07f1 09/20: * nlinum.el (nlinum--setup-window
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nlinum fbe07f1 09/20: * nlinum.el (nlinum--setup-window): Better preserve margin settings |
Date: |
Sat, 28 Nov 2020 18:42:23 -0500 (EST) |
branch: externals/nlinum
commit fbe07f183320e50cc24cf75a1fc94bf4e17b2a76
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* nlinum.el (nlinum--setup-window): Better preserve margin settings
(bug#20674)
---
nlinum.el | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/nlinum.el b/nlinum.el
index 2505c98..98c9cbc 100644
--- a/nlinum.el
+++ b/nlinum.el
@@ -82,18 +82,36 @@ Linum mode is a buffer-local minor mode."
width)))))
(defun nlinum--setup-window ()
- (let ((width (if (display-graphic-p)
- (ceiling
- (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)))))
+ ;; FIXME: The interaction between different uses of the margin is
+ ;; problematic. We should have a way for different packages to indicate (and
+ ;; change) their preference independently.
+ (let* ((width (if (display-graphic-p)
+ (ceiling
+ (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))
+ (cur-margins (window-margins))
+ (cur-margin (car cur-margins))
+ ;; (EXT . OURS) keeps track of the size of the margin, where EXT is
the
+ ;; size chosen by external code and OURS is the size we last set.
+ ;; OURS is used to detect when someone else modifies the margin.
+ (margin-settings (window-parameter nil 'linum--margin)))
+ (if margin-settings
+ (unless (eq (cdr margin-settings) cur-margin)
+ ;; Damn! The margin is not what it used to be! => Update EXT!
+ (setcar margin-settings cur-margin))
+ (set-window-parameter nil 'linum--margin
+ (setq margin-settings (list cur-margin))))
+ (and (car margin-settings) width
+ (setq width (max width (car margin-settings))))
+ (setcdr margin-settings width)
+ (set-window-margins nil (if nlinum-mode width (car margin-settings))
+ (cdr cur-margins))))
(defun nlinum--setup-windows ()
(dolist (win (get-buffer-window-list nil nil t))
- [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, 2020/11/28
- [elpa] externals/nlinum fbe07f1 09/20: * nlinum.el (nlinum--setup-window): Better preserve margin settings,
Stefan Monnier <=
- [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
- [elpa] externals/nlinum 8fd46ee 14/20: Fix nlinum face height function (Bug#26552), Stefan Monnier, 2020/11/28