[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 28263c7 12/42: Handle narrowing (fixes #48)
From: |
Dmitry Gutov |
Subject: |
[elpa] master 28263c7 12/42: Handle narrowing (fixes #48) |
Date: |
Wed, 09 Sep 2015 19:03:31 +0000 |
branch: master
commit 28263c711bcfb2d955b42e10d4e27d828c209dcc
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Handle narrowing (fixes #48)
---
diff-hl.el | 64 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/diff-hl.el b/diff-hl.el
index 8057833..17106c1 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -265,31 +265,33 @@
(current-line 1))
(diff-hl-remove-overlays)
(save-excursion
- (goto-char (point-min))
- (dolist (c changes)
- (cl-destructuring-bind (line len type) c
- (forward-line (- line current-line))
- (setq current-line line)
- (let ((hunk-beg (point)))
- (while (cl-plusp len)
- (diff-hl-add-highlighting
- type
- (cond
- ((not diff-hl-draw-borders) 'empty)
- ((and (= len 1) (= line current-line)) 'single)
- ((= len 1) 'bottom)
- ((= line current-line) 'top)
- (t 'middle)))
- (forward-line 1)
- (cl-incf current-line)
- (cl-decf len))
- (let ((h (make-overlay hunk-beg (point)))
- (hook '(diff-hl-overlay-modified)))
- (overlay-put h 'diff-hl t)
- (overlay-put h 'diff-hl-hunk t)
- (overlay-put h 'modification-hooks hook)
- (overlay-put h 'insert-in-front-hooks hook)
- (overlay-put h 'insert-behind-hooks hook))))))))
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (dolist (c changes)
+ (cl-destructuring-bind (line len type) c
+ (forward-line (- line current-line))
+ (setq current-line line)
+ (let ((hunk-beg (point)))
+ (while (cl-plusp len)
+ (diff-hl-add-highlighting
+ type
+ (cond
+ ((not diff-hl-draw-borders) 'empty)
+ ((and (= len 1) (= line current-line)) 'single)
+ ((= len 1) 'bottom)
+ ((= line current-line) 'top)
+ (t 'middle)))
+ (forward-line 1)
+ (cl-incf current-line)
+ (cl-decf len))
+ (let ((h (make-overlay hunk-beg (point)))
+ (hook '(diff-hl-overlay-modified)))
+ (overlay-put h 'diff-hl t)
+ (overlay-put h 'diff-hl-hunk t)
+ (overlay-put h 'modification-hooks hook)
+ (overlay-put h 'insert-in-front-hooks hook)
+ (overlay-put h 'insert-behind-hooks hook)))))))))
(defun diff-hl-add-highlighting (type shape)
(let ((o (make-overlay (point) (point))))
@@ -301,17 +303,17 @@
(overlay-put ovl 'before-string (diff-hl-fringe-spec type shape
diff-hl-side)))
-(defun diff-hl-remove-overlays ()
- (dolist (o (overlays-in (point-min) (point-max)))
- (when (overlay-get o 'diff-hl) (delete-overlay o))))
+(defun diff-hl-remove-overlays (&optional beg end)
+ (save-restriction
+ (widen)
+ (dolist (o (overlays-in (or beg (point-min)) (or end (point-max))))
+ (when (overlay-get o 'diff-hl) (delete-overlay o)))))
(defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
"Delete the hunk overlay and all our line overlays inside it."
(unless after-p
(when (overlay-buffer ov)
- (save-restriction
- (narrow-to-region (overlay-start ov) (overlay-end ov))
- (diff-hl-remove-overlays))
+ (diff-hl-remove-overlays (overlay-start ov) (overlay-end ov))
(delete-overlay ov))))
(defvar diff-hl-timer nil)
- [elpa] master updated (cde5d9a -> a454a24), Dmitry Gutov, 2015/09/09
- [elpa] master 38a83db 01/42: Add documentation for diff-hl-dired-status-files., Dmitry Gutov, 2015/09/09
- [elpa] master 5bfb314 03/42: Move diff-hl-margin-side after diff-hl-margin-mode definition, Dmitry Gutov, 2015/09/09
- [elpa] master 1743a80 07/42: Merge pull request #42 from tarsius/silentio, Dmitry Gutov, 2015/09/09
- [elpa] master eb92f0e 04/42: Merge pull request #39 from jamessan/diff-hl-margin-load-error, Dmitry Gutov, 2015/09/09
- [elpa] master d188525 02/42: Merge pull request #37 from holocronweaver/documentation, Dmitry Gutov, 2015/09/09
- [elpa] master 4959c6e 10/42: Autoload diff-hl-dired-mode-unless-remote, Dmitry Gutov, 2015/09/09
- [elpa] master d6b7d82 05/42: Support the "next" Magit version, Dmitry Gutov, 2015/09/09
- [elpa] master 934fef0 11/42: Promote diff-hl-margin-side to diff-hl-side, Dmitry Gutov, 2015/09/09
- [elpa] master 28263c7 12/42: Handle narrowing (fixes #48),
Dmitry Gutov <=
- [elpa] master 84d5110 09/42: Bump the copyright years, Dmitry Gutov, 2015/09/09
- [elpa] master 12def16 14/42: Allow bitmap width only up to 16 (#49), Dmitry Gutov, 2015/09/09
- [elpa] master bf27c41 15/42: vc-disable-async-diff: Don't bind when it's undefined, Dmitry Gutov, 2015/09/09
- [elpa] master 7ea8159 16/42: Define diff-hl-command-map without destroying existing bindings, Dmitry Gutov, 2015/09/09
- [elpa] master 733ad33 06/42: silence byte-compiler, Dmitry Gutov, 2015/09/09
- [elpa] master 028b2bf 17/42: Merge pull request #51 from tarsius/keep-bindings, Dmitry Gutov, 2015/09/09
- [elpa] master 327e01c 20/42: Add commentary to diff-hl-flydiff, Dmitry Gutov, 2015/09/09
- [elpa] master 75d4bdc 08/42: Remove CR characters, Dmitry Gutov, 2015/09/09
- [elpa] master 0db7160 21/42: Change version predicate for vc-git polyfilling, Dmitry Gutov, 2015/09/09
- [elpa] master c79dc5b 13/42: Allow diffing on-the-fly, Dmitry Gutov, 2015/09/09