[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 77c062f: * nlinum.el (nlinum--setup-window): Better preser
From: |
Stefan Monnier |
Subject: |
[elpa] master 77c062f: * nlinum.el (nlinum--setup-window): Better preserve margin settings |
Date: |
Thu, 28 May 2015 18:28:11 +0000 |
branch: master
commit 77c062f41bfe20d5a7a259beeda1c2a26b95f5d0
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* nlinum.el (nlinum--setup-window): Better preserve margin settings
(bug#20674)
---
packages/nlinum/nlinum.el | 42 ++++++++++++++++++++++++++++++------------
1 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/packages/nlinum/nlinum.el b/packages/nlinum/nlinum.el
index 2505c98..98c9cbc 100644
--- a/packages/nlinum/nlinum.el
+++ b/packages/nlinum/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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 77c062f: * nlinum.el (nlinum--setup-window): Better preserve margin settings,
Stefan Monnier <=