GNU bug report logs -
#25410
26.0.50; Refine an unified diff hunk only if adds lines
Previous Next
Reported by: Tino Calancha <tino.calancha <at> gmail.com>
Date: Tue, 10 Jan 2017 10:09:01 UTC
Severity: normal
Tags: fixed, patch
Found in version 26.0.50
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Tino Calancha <tino.calancha <at> gmail.com> writes:
> npostavs <at> users.sourceforge.net writes:
>
>> What about a diff that adds a very large file? Perhaps we should only
>> refine if there added lines *and* deleted lines?
> I have updated the patch. Now it checks before the `pcase' that
> the hunk adds and removes lines. Only when this is true, we enter
> in the `pcase'.
> - nil 'diff-refine-preproc props-r props-a))))))))
> + ;; Only refine the hunk if both adds and removes lines (Bug#25410).
> + (when (and (save-excursion (re-search-forward "^-.*\n" end t))
> + (re-search-forward "^\\+.*\n" end t))
> + (remove-overlays beg end 'diff-mode 'fine)
> + (goto-char beg)
> + (pcase style
> + (`unified
This check only has sense for unified diffs, where the new lines start with
'+' and the deleted ones start with '-'.
We might use the first patch in this thread or the following one:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 89742f18291c1bb7fc99dfd5ac71a7d625699534 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Wed, 11 Jan 2017 17:05:05 +0900
Subject: [PATCH] Refine an unified diff hunk only if both removes and adds
lines
* lisp/vc/diff-mode.el (diff-refine-hunk): Refine the unified
diff hunk only if it adds and removes some lines (Bug#25410).
---
lisp/vc/diff-mode.el | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 9dfcd944bb..4cc20338c1 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2075,22 +2075,23 @@ diff-refine-hunk
(props-c '((diff-mode . fine) (face diff-refine-changed)))
(props-r '((diff-mode . fine) (face diff-refine-removed)))
(props-a '((diff-mode . fine) (face diff-refine-added))))
-
(remove-overlays beg end 'diff-mode 'fine)
-
(goto-char beg)
(pcase style
(`unified
- (while (re-search-forward
- (eval-when-compile
- (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?"))
- (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re
- "\\(\\)"
- "\\(?:\\+.*\n\\)+" no-LF-at-eol-re)))
- end t)
- (smerge-refine-subst (match-beginning 0) (match-end 1)
- (match-end 1) (match-end 0)
- nil 'diff-refine-preproc props-r props-a)))
+ ;; Only refine an unified hunk if both adds and removes lines (Bug#25410).
+ (when (and (save-excursion (re-search-forward "^-.*\n" end t))
+ (save-excursion (re-search-forward "^\\+.*\n" end t)))
+ (while (re-search-forward
+ (eval-when-compile
+ (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?"))
+ (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re
+ "\\(\\)"
+ "\\(?:\\+.*\n\\)+" no-LF-at-eol-re)))
+ end t)
+ (smerge-refine-subst (match-beginning 0) (match-end 1)
+ (match-end 1) (match-end 0)
+ nil 'diff-refine-preproc props-r props-a))))
(`context
(let* ((middle (save-excursion (re-search-forward "^---")))
(other middle))
--
2.11.0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.5)
of 2017-01-11
Repository revision: fa0a2b4e7c81f57aecc1d94df00588a4dd5c281d
This bug report was last modified 8 years and 124 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.