[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/diff-hl 05eb5c1 1/2: Silence the diff-auto-refine-mode
From: |
ELPA Syncer |
Subject: |
[elpa] externals/diff-hl 05eb5c1 1/2: Silence the diff-auto-refine-mode warnings |
Date: |
Sat, 22 May 2021 20:57:08 -0400 (EDT) |
branch: externals/diff-hl
commit 05eb5c192272597a91ce85e5676617df0d3982d7
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Silence the diff-auto-refine-mode warnings
#163
https://debbugs.gnu.org/32991
---
diff-hl.el | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/diff-hl.el b/diff-hl.el
index 74bc372..335627b 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -329,17 +329,27 @@ Only affects Git, it's the only backend that has staging
area."
(defun diff-hl-changes-from-buffer (buf)
(with-current-buffer buf
- (let* (diff-auto-refine-mode res)
+ (let (res)
(goto-char (point-min))
(unless (eobp)
+ ;; TODO: When 27.1 is the minimum requirement, we can drop
+ ;; these bindings: that version, in addition to switching over
+ ;; to the diff-refine var, also added the
+ ;; called-interactively-p check, so refinement can't be
+ ;; triggered by code calling the navigation functions, only by
+ ;; direct interactive invocations.
(ignore-errors
- (diff-beginning-of-hunk t))
+ (with-no-warnings
+ (let (diff-auto-refine-mode)
+ (diff-beginning-of-hunk t))))
(while (looking-at diff-hunk-header-re-unified)
(let ((line (string-to-number (match-string 3)))
(len (let ((m (match-string 4)))
(if m (string-to-number m) 1)))
(beg (point)))
- (diff-end-of-hunk)
+ (with-no-warnings
+ (let (diff-auto-refine-mode)
+ (diff-end-of-hunk)))
(let* ((inserts (diff-count-matches "^\\+" beg (point)))
(deletes (diff-count-matches "^-" beg (point)))
(type (cond ((zerop deletes) 'insert)
@@ -542,8 +552,9 @@ in the source file, or the last line of the hunk above it."
(when (eobp)
(with-current-buffer ,buffer (diff-hl-remove-overlays))
(user-error "Buffer is up-to-date"))
- (let (diff-auto-refine-mode)
- (diff-hl-diff-skip-to ,line))
+ (with-no-warnings
+ (let (diff-auto-refine-mode)
+ (diff-hl-diff-skip-to ,line)))
(save-excursion
(while (looking-at "[-+]") (forward-line 1))
(setq end-line (line-number-at-pos (point)))
@@ -560,8 +571,9 @@ in the source file, or the last line of the hunk above it."
(if (>= wbh (- end-line beg-line))
(recenter (/ (+ wbh (- beg-line end-line) 2) 2))
(recenter 1)))
- (when diff-auto-refine-mode
- (diff-refine-hunk))
+ (with-no-warnings
+ (when diff-auto-refine-mode
+ (diff-refine-hunk)))
(if diff-hl-ask-before-revert-hunk
(unless (yes-or-no-p (format "Revert current hunk in %s? "
,(cl-caadr fileset)))