From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#25410: 26.0.50; Refine an unified diff hunk only if adds lines Date: Wed, 11 Jan 2017 17:13:02 +0900 Message-ID: <8760lmqak1.fsf@gmail.com> References: <8737grz0q3.fsf@gmail.com> <8737gr0zbn.fsf@users.sourceforge.net> <87fukqe2eu.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484122456 18163 195.159.176.226 (11 Jan 2017 08:14:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 11 Jan 2017 08:14:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 25410@debbugs.gnu.org, Tino Calancha To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 11 09:14:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRE2q-0003vI-HJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Jan 2017 09:14:08 +0100 Original-Received: from localhost ([::1]:52150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRE2u-0005uI-Q3 for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Jan 2017 03:14:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRE2o-0005u9-W9 for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2017 03:14:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRE2k-0002Lk-Jy for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2017 03:14:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33943) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRE2k-0002Lf-GS for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2017 03:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cRE2k-0007Ne-65 for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2017 03:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Jan 2017 08:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25410 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25410-submit@debbugs.gnu.org id=B25410.148412239428306 (code B ref 25410); Wed, 11 Jan 2017 08:14:02 +0000 Original-Received: (at 25410) by debbugs.gnu.org; 11 Jan 2017 08:13:14 +0000 Original-Received: from localhost ([127.0.0.1]:49342 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRE1y-0007MS-D8 for submit@debbugs.gnu.org; Wed, 11 Jan 2017 03:13:14 -0500 Original-Received: from mail-pf0-f196.google.com ([209.85.192.196]:35795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRE1w-0007MG-PG for 25410@debbugs.gnu.org; Wed, 11 Jan 2017 03:13:13 -0500 Original-Received: by mail-pf0-f196.google.com with SMTP id f144so13488156pfa.2 for <25410@debbugs.gnu.org>; Wed, 11 Jan 2017 00:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=tGezf4Cw4BJSVlnuIxULTTtG77sT9zoz/ysUUq0/Yic=; b=EldpRm4TZ2qisbwInv9X/ImPvKMsxRbX4CEXTFKJGgiNWALQmJEanLLd4u2TKjx5dL y1QgwJWZ9xPdENrpMDBCwmMMqGBRBqvTLwkYYUtGuhLNIlV3crAHA3ZgMIvbMG3PpBHD D303/oigK0LXpoAEycftSxfOuCUJBIvpoJWzOLmZYwraHyA6S7cSNZ7BoYB04VKMeNQl J64nHU3ByTQwr5OE/SafciLzNQ/ksRm/WEVaaxjecAt+e7WnYqTmRIVwou3yks6/oOF0 uv8H4p5/5UhgUMUA1oCnNXHi54Ymf0zFP7kJTsfAX1Vim+nBkVCHAGNrSHIAYOsU4xMu 8SoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=tGezf4Cw4BJSVlnuIxULTTtG77sT9zoz/ysUUq0/Yic=; b=s4Q3R02LmWl4v5BlGpz1gyBOEiyrNGcGZl4LnhhluIT6iowCIP7L8kp4WPJYRsyh33 ij4AsOypPWB5WAdgDKb29xKtDZJGqbjBYo+SgVo8MwggwZbWRkQ+YI+eSCcFo2P2OWTF nmb/ofTsPlJxBuyHte6unxNBo8Hmo9xe7rdwl8Sv7ydTdx+8OzAP2WKVD5mFHhZJsDDg icB6ZekHFF12xekzZfDR5vGTED0PrJ/T8/ai21K6rZ+EI5knT+7Jg7bI5OimJ6hDBLC4 ERAz+vpwshSPsJvD/SO9Jbclr79iR9igurKA2BZbZgXbfaifCaWEMhFgQj7+YNHHKNF/ ZArA== X-Gm-Message-State: AIkVDXLDTuF1kZY8vD5dJO2WpgO9SgVdXaxhlmWaqeVubWD9vQFoBRqhWCs92mY7WKlxhw== X-Received: by 10.98.75.156 with SMTP id d28mr8849226pfj.59.1484122387202; Wed, 11 Jan 2017 00:13:07 -0800 (PST) Original-Received: from calancha-pc (217.225.128.101.dy.bbexcite.jp. [101.128.225.217]) by smtp.gmail.com with ESMTPSA id p25sm11289036pfd.0.2017.01.11.00.13.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jan 2017 00:13:06 -0800 (PST) In-Reply-To: <87fukqe2eu.fsf@gmail.com> (Tino Calancha's message of "Wed, 11 Jan 2017 11:49:45 +0900") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127988 Archived-At: Tino Calancha writes: > npostavs@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 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