From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#37395: [PATCH] diff-mode.el: take into account patch separators Date: Fri, 13 Sep 2019 09:58:27 +0300 Message-ID: <1568357907.5095.0@yandex.ru> References: <1568323985.28657.0@yandex.ru> <20190912213445.16304-1-Hi-Angel@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-5; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="176346"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 37395@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 13 08:59:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i8fXz-000jka-9A for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Sep 2019 08:59:11 +0200 Original-Received: from localhost ([::1]:40686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8fXx-0006Cz-Hk for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Sep 2019 02:59:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58939) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8fXr-0006Cr-2r for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 02:59:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8fXq-0000i3-1t for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 02:59:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35453) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8fXp-0000hi-VJ for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 02:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i8fXp-0000aE-TY for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 02:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Sep 2019 06:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37395 X-GNU-PR-Package: emacs Original-Received: via spool by 37395-submit@debbugs.gnu.org id=B37395.15683579222213 (code B ref 37395); Fri, 13 Sep 2019 06:59:01 +0000 Original-Received: (at 37395) by debbugs.gnu.org; 13 Sep 2019 06:58:42 +0000 Original-Received: from localhost ([127.0.0.1]:44274 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8fXW-0000Zd-DO for submit@debbugs.gnu.org; Fri, 13 Sep 2019 02:58:42 -0400 Original-Received: from forward104j.mail.yandex.net ([5.45.198.247]:48166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8fXT-0000ZM-GL for 37395@debbugs.gnu.org; Fri, 13 Sep 2019 02:58:41 -0400 Original-Received: from mxback21j.mail.yandex.net (mxback21j.mail.yandex.net [IPv6:2a02:6b8:0:1619::221]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 99DF04A0CB4; Fri, 13 Sep 2019 09:58:32 +0300 (MSK) Original-Received: from myt4-6a59ac13d093.qloud-c.yandex.net (myt4-6a59ac13d093.qloud-c.yandex.net [2a02:6b8:c12:88f:0:640:6a59:ac13]) by mxback21j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dDkbhkWb8d-wWSm3tjk; Fri, 13 Sep 2019 09:58:32 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1568357912; bh=tqvDt4kPHXj7+o7D5PXngEZvRSYdUGj8GwSHrMM+k+o=; h=In-Reply-To:Cc:To:Subject:From:References:Date:Message-Id; b=VB7sO+yaZf3nviRzSaBu+CAN3qrnMZJDkwbFR31JiddP0ALKmzlxQnJ5hD9j6vV6h BiMug7AYd2Ri25XkInTlMT/wxH+Mfj9B2j1euKSMur1N5Kt1lxBEd5+7F98jqGVymw UTnO2prex1OHjFeIo17nxXXTA5aqVpFzzu0WK3EQ= Authentication-Results: mxback21j.mail.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by myt4-6a59ac13d093.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id hmr2fpHNN7-wVF49NjO; Fri, 13 Sep 2019 09:58:31 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) In-Reply-To: <838sqs205w.fsf@gnu.org> X-Mailer: geary/3.33.90 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: 209.51.188.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:166382 Archived-At: On =BF=E2, =E1=D5=DD 13, 2019 at 09:14, Eli Zaretskii wrote: >> From: Konstantin Kharlamov >> Date: Fri, 13 Sep 2019 00:34:45 +0300 >>=20 >> * lisp/vc/diff-mode.el (diff-goto-line-before-patch-separator): an >> inline function to check if prev. line was git-format-patch=20 >> separator, >> in which case go there. >> (diff-end-of-hunk): make use of=20 >> (diff-goto-line-before-patch-separator) >=20 > The descriptions of changes should start with a capital letter. Also, > your lines in the commit log message are too long, they should not > exceed 61 characters (because in the release tarball we create a > ChangeLog file from them, which prepends a TAB character to each > line). >=20 >> +(defsubst diff-goto-line-before-patch-separator () >> + "Go to prev. line, then if it has patch separator as produced >> +by git-format-patch, stay there. Otherwise go back." >=20 > The first line of a doc string should be a complete sentence. I > suggest to rephrase as follows: >=20 > Return buffer position before patch separator produced by=20 > git-format-patch. Thank you, I'll address the comments a bit later this day! >> + (previous-line) >> + (when (not (looking-at "-- ")) >> + (next-line)) >> + (point)) >=20 > Btw, Diff mode is more general than just Git-produced diffs. Is there > any possibility that this change will misfire in diffs produced by > other tools? If so, perhaps we should also verify the buffer is under > Git control. Oh, while writing this, I figured I should change the regexp from `-- `=20 to `^-- $`. Will do. With that addressed: very unlikely. A miscalculation could happen if=20 all of the following holds true *simultaneously*: * The diff removes a line with the exact text `- `, i.e. two=20 characters {dash,space}. That would result in {dash,dash,space} diff,=20 same as patch separator. * The line was the last line removed in the hunk. * The hunk has no context after the removed line Note, these need to hold true simultaneously. Give the low probability=20 of this compared to git-format-patch that is used literally everywhere=20 (and that without this patch diff-mode can't handle it), I think this=20 is a reasonable trade-off. =