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 00:34:45 +0300 Message-ID: <20190912213445.16304-1-Hi-Angel@yandex.ru> References: <1568323985.28657.0@yandex.ru> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="126562"; 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 Thu Sep 12 23:36: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 1i8Wl8-000WlC-KW for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Sep 2019 23:36:10 +0200 Original-Received: from localhost ([::1]:38956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Wl7-0000a4-HJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Sep 2019 17:36:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32775) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Wl1-0000Zr-0a for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 17:36:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8Wl0-0002x0-27 for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 17:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35343) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8Wkz-0002we-V8 for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 17:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i8Wkz-0008Hy-R3 for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 17:36:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <1568323985.28657.0@yandex.ru> Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Sep 2019 21:36: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.156832410731784 (code B ref 37395); Thu, 12 Sep 2019 21:36:01 +0000 Original-Received: (at 37395) by debbugs.gnu.org; 12 Sep 2019 21:35:07 +0000 Original-Received: from localhost ([127.0.0.1]:44164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8Wk7-0008Ga-47 for submit@debbugs.gnu.org; Thu, 12 Sep 2019 17:35:07 -0400 Original-Received: from forward103o.mail.yandex.net ([37.140.190.177]:40361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8Wk4-0008Fo-ES for 37395@debbugs.gnu.org; Thu, 12 Sep 2019 17:35:06 -0400 Original-Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward103o.mail.yandex.net (Yandex) with ESMTP id B60535F80328 for <37395@debbugs.gnu.org>; Fri, 13 Sep 2019 00:34:56 +0300 (MSK) Original-Received: from sas8-b94264ec42f5.qloud-c.yandex.net (sas8-b94264ec42f5.qloud-c.yandex.net [2a02:6b8:c1b:2a1f:0:640:b942:64ec]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ght53kdkbd-Yu2Of1fV; Fri, 13 Sep 2019 00:34:56 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1568324096; bh=RirpcKE9vFeFFy7WOMFvsAzQ7ZjgkwSuajtPlOb08bg=; h=Subject:To:From:Date:Message-Id; b=TgN5kCxJyESscOughTD2x2bPxtM1uy4bub2hc202WwHTdskmQZYnwTrxFN9T7/ODh kgc2qBs/CnoHZeZaoG5AhHsJjP0pxTsN21gRSkOK16bx8G1VXSJIVUgUTurUkv6G10 O51CaitexXAaoT37G8zfsoIfBkBl2lOl9J+TFmjY= Authentication-Results: mxback12g.mail.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by sas8-b94264ec42f5.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZbSwCbAh8H-YuEeXpBs; Fri, 13 Sep 2019 00:34:56 +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 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:166376 Archived-At: * lisp/vc/diff-mode.el (diff-goto-line-before-patch-separator): an inline function to check if prev. line was git-format-patch separator, in which case go there. (diff-end-of-hunk): make use of (diff-goto-line-before-patch-separator) --- lisp/vc/diff-mode.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 19f9c802d4..a3e4923fb4 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -511,6 +511,14 @@ diff-hunk-style (goto-char (match-end 0))) style) +(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." + (previous-line) + (when (not (looking-at "-- ")) + (next-line)) + (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 +569,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-goto-line-before-patch-separator))) ;; The return value is used by easy-mmode-define-navigation. (goto-char (or end (point-max))))) -- 2.23.0