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 v2] diff-mode.el: take into account patch separators Date: Fri, 13 Sep 2019 12:19:21 +0300 Message-ID: <20190913091921.23441-1-Hi-Angel@yandex.ru> References: <838sqs205w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="227554"; mail-complaints-to="usenet@blaine.gmane.org" To: 37395@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 13 11:20:10 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 1i8hkQ-000x48-HS for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Sep 2019 11:20:10 +0200 Original-Received: from localhost ([::1]:41672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8hkP-0002Ks-Bk for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Sep 2019 05:20:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53367) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8hkJ-0002KK-4a for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 05:20:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8hkI-0004lP-5Q for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 05:20:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8hkH-0004l8-QY for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 05:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i8hkH-0006Ej-KC for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2019 05:20: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 09:20: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.156836638023942 (code B ref 37395); Fri, 13 Sep 2019 09:20:01 +0000 Original-Received: (at 37395) by debbugs.gnu.org; 13 Sep 2019 09:19:40 +0000 Original-Received: from localhost ([127.0.0.1]:44369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8hjw-0006E6-3F for submit@debbugs.gnu.org; Fri, 13 Sep 2019 05:19:40 -0400 Original-Received: from forward100j.mail.yandex.net ([5.45.198.240]:48669) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8hjt-0006Dq-5u for 37395@debbugs.gnu.org; Fri, 13 Sep 2019 05:19:38 -0400 Original-Received: from mxback3j.mail.yandex.net (mxback3j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10c]) by forward100j.mail.yandex.net (Yandex) with ESMTP id E75B950E07F5 for <37395@debbugs.gnu.org>; Fri, 13 Sep 2019 12:19:29 +0300 (MSK) Original-Received: from sas1-8413c76d2429.qloud-c.yandex.net (sas1-8413c76d2429.qloud-c.yandex.net [2a02:6b8:c08:2206:0:640:8413:c76d]) by mxback3j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id C91Dewgosj-JTYSOMr5; Fri, 13 Sep 2019 12:19:29 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1568366369; bh=BKNJXxJGBfAMLpiDE6PaVllP3qL2D2FhHhmqIw7ObmE=; h=In-Reply-To:Subject:To:From:References:Date:Message-Id; b=PGeaHvKf1k43+jxACjl3jxrdNxhPgxzd4bD0hSzQKeCwNbEjzlaXMEbi1lmSp9KdJ yBNvViGgcCkpaP04Sf0t0DHE3sYOqGMaDRYl2xKcLhR2vm9ZiOQ6P1DC8MHmhcpamH ppH6g9LAMVdZrKOmWOS8xES4+PtPkp+VHXiFG6lU= Authentication-Results: mxback3j.mail.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by sas1-8413c76d2429.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id E6Ujd12ZdY-JTEe4m0j; Fri, 13 Sep 2019 12:19:29 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Mailer: git-send-email 2.23.0 In-Reply-To: <838sqs205w.fsf@gnu.org> 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:166386 Archived-At: * lisp/vc/diff-mode.el (diff-prev-line-if-patch-separator): An inline function to return prev. line if it has git-format-patch separator. (diff-end-of-hunk): Make use of diff-prev-line-if-patch-separator --- v2: * Start commit description with capital letter * Limit commit description to 61 character line length * Rename diff-goto-line-before-patch-separator, to diff-prev-line-if-patch-separator and rephrase the doc-string. * diff-prev-line-if-patch-separator now does not mutate point. * Make sure we're at line beginning before (looking-at …) lisp/vc/diff-mode.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 19f9c802d4..6702614472 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -511,6 +511,17 @@ diff-hunk-style (goto-char (match-end 0))) style) +(defsubst diff-prev-line-if-patch-separator () + "Return previous line if it has patch separator produced by +git-format-patch." + (save-excursion + (let ((old-point (point))) + (previous-line) + (beginning-of-line) + (if (looking-at "^-- $") + (point) + old-point)))) + (defun diff-end-of-hunk (&optional style donttrustheader) "Advance to the end of the current hunk, and return its position." (let (end) @@ -561,7 +572,8 @@ diff-end-of-hunk (goto-char (or end (point-max))) (while (eq ?\n (char-before (1- (point)))) (forward-char -1) - (setq end (point))))) + (setq end (point)))) + (setq end (diff-prev-line-if-patch-separator))) ;; The return value is used by easy-mmode-define-navigation. (goto-char (or end (point-max))))) -- 2.23.0