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#25105: M-p in diff-mode jumps too far Date: Mon, 16 Jan 2017 15:26:00 +0900 (JST) Message-ID: References: <87a8aydxe4.fsf@gmail.com> <3c2e407b-8ba2-1791-15e6-a0be6dac2897@yandex.ru> <87fuknzem8.fsf@users.sourceforge.net> <87d1frzcil.fsf_-_@users.sourceforge.net> <877f5yza02.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Trace: blaine.gmane.org 1484548043 27944 195.159.176.226 (16 Jan 2017 06:27:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Jan 2017 06:27:23 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: npostavs@users.sourceforge.net, Mark Oteiza , Stefan Monnier , Dmitry Gutov , 25105@debbugs.gnu.org, Dima Kogan To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 16 07:27:16 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 1cT0l2-0005yt-6g for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jan 2017 07:27:08 +0100 Original-Received: from localhost ([::1]:54478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cT0l6-0000Uv-K2 for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jan 2017 01:27:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cT0kz-0000Ua-UN for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 01:27:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cT0kw-0007fw-QU for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 01:27:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cT0kw-0007fq-Lw for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 01:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cT0kw-00005U-Cd for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 01:27: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: Mon, 16 Jan 2017 06:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25105 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 25105-submit@debbugs.gnu.org id=B25105.148454797232740 (code B ref 25105); Mon, 16 Jan 2017 06:27:02 +0000 Original-Received: (at 25105) by debbugs.gnu.org; 16 Jan 2017 06:26:12 +0000 Original-Received: from localhost ([127.0.0.1]:55181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cT0k8-0008W0-G5 for submit@debbugs.gnu.org; Mon, 16 Jan 2017 01:26:12 -0500 Original-Received: from mail-pf0-f193.google.com ([209.85.192.193]:34698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cT0k7-0008Vo-BO for 25105@debbugs.gnu.org; Mon, 16 Jan 2017 01:26:11 -0500 Original-Received: by mail-pf0-f193.google.com with SMTP id y143so13486644pfb.1 for <25105@debbugs.gnu.org>; Sun, 15 Jan 2017 22:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=5y7guFZfGCfjxf6xSbM+7m5djXMPbN8cRXtwYTcpt1g=; b=aq46ilah1WS1f/D4Z1SGExZjA+qp/f8JAeuDnngvI8C1JmRwNzAoYSrbZ4OIwtTua3 UiWlbASyOKnmgQy/g0xCaKW5yETZ5xu0bSyvH45SVUb2DQ/pnLtic+YlTEmEk2bmkYRB 1RXXNM/Aly7nXXLJxXYSz0ZPP+hTQ8/pkMBotD+O3NQXh8yk7iYcZP1vH7jsCX+dQAkr br1mKv7jCtyxw+qUntyHX7/aYwoj3fuETeRY0N6OISO7tVPvV/7fkCEFAECfIyKtqvht dYlxawIeRqw4rkPhmRT6ijYMGkz6gQz+h8MV+OclP8K4cXAvdnYIzw47X46X4leYHWVY UC6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=5y7guFZfGCfjxf6xSbM+7m5djXMPbN8cRXtwYTcpt1g=; b=YGJaES3x0mEFrz9Aul7d7S0Fd59YuJN2CXuYZeXIHnTsEjhy/BvA758W1DlrIil2W3 bipU0w9VY+XmUzh6zEeVp85WwB6lDmVm4FcC8TWYPT5CC7eoTD/B0H3JwTmz5Jd2htrg 3UQdLL++zeXv1r1Zv4lRWt5nLMPy6h4oOE8ARz3rpri2E7RCrRYW7QDdcB2UPtyFNAyp zW9d3mUEM8SSGt3fiGxBl/CNB6oCU3Tba1VKHlsmMD8h8dSmPmPSu/ShxYM/dX1+HPB9 5cJnZLlwXkKAh2MUNN+15tPhOkYe4DPgk35ymquAgoxaMabflYHPvlc4VXsOe8VpUctJ h18A== X-Gm-Message-State: AIkVDXKFibwFlhICp+pUxB1oEj1VC2cO86Aq1Ui6rjAL4oy3blrn+1YDjzwgvYyu/oHxAA== X-Received: by 10.84.233.201 with SMTP id m9mr47633819pln.91.1484547965270; Sun, 15 Jan 2017 22:26:05 -0800 (PST) Original-Received: from calancha-pc (33.94.100.220.dy.bbexcite.jp. [220.100.94.33]) by smtp.gmail.com with ESMTPSA id k76sm28596893pfg.42.2017.01.15.22.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jan 2017 22:26:04 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: 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:128145 Archived-At: On Sat, 14 Jan 2017, Tino Calancha wrote: > Essentially, my patch fix 1. and 2. in the commit message of 2c8a7e5. > I am going to prepare one draft for the commit message based on Dima's > message by Monday or Tuesday: i will drop mentions to the navigation > commands. Then i will show it here so that people in this thread can > give me comments/corrections to make the message clear for everyone. OK, below is my draft for the second commit. Please don't hesitate to send me comments to make it more clear or/and fix some broken grammar. ;; For the first commit, the revert of 2c8a7e5, i propose to keep the same ;; as before. Let me know in case you want to change it as well. Maybe ;; you want this commit list all the commits that it reverts? ;; Currently it just mentions 2c8a7e5, but it doesn't say a word about ;; the 'children commits': ;; e5ef59b8, 6b6abe0d, 73349822, a283d655 and 61c6a10e. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Improve diff-mode manipulation commands Fix Bug#17544. The use of `diff-apply-hunk' and `diff-hunk-kill' had several annoying corner cases that this patch fixes. These corner cases were largely due to inconsistent treatment of diff headers. Consider following diff: diff --git a/foo b/bar index 44556ddd4a..3fc4713f0f 100644 --- a/foo +++ b/bar @@ -52,7 +52,7 @@ hunk1 @@ -74,7 +74,7 @@ hunk2 diff --git a/baz b/qux index a8c3fcca2f..6b316c4073 100644 --- a/baz +++ b/qux @@ -608,6 +608,6 @@ hunk3 @@ -654,7 +654,7 @@ hunk4 The lines starting and ending with '@@' are the hunk headers. The lines starting with '---' and '+++' are the file headers. In addition, Git diffs add extra lines as those starting with 'diff' and 'index' above. Let's call these lines Git header. >From now on, these three headers are referred together as the diff header, that is, diff header = 'Git + file + hunk' headers. Commands `diff-apply-hunk' and `diff-hunk-kill' behaves differently depending on the point position within a diff header. 1. If point is at hunk1 header, '@@ -52,7 +52,7 @@' above, then `diff-apply-hunk' moves point to hunk2 header, i.e., '@@ -74,7 +74,7 @@' line. If point is at '--- a/foo' line, then `diff-apply-hunk' moves point to hunk1 header. 2. If point is at hunk3 header or its file header, then `diff-hunk-kill' deletes hunk3. If point is at the beginning of its Git header, i.e., 'diff --git a/baz b/qux' line, then `diff-hunk-kill' deletes hunk2. After this patch the behaviour of these commands is independent of the point position in the diff header. Then, it's possible to apply hunks in order. It's also possible to press M-k repeatedly to kill hunks in the order they appear in the buffer. * lisp/vc/diff-mode.el (diff-file-junk-re): Move definition before it's used. (diff--at-diff-header-p): New predicate. (diff-beginning-of-hunk): Use it. (diff-apply-hunk): Jump to beginning of hunk before apply the hunk. (diff-hunk-kill, diff-file-kill): Jump to beginning of hunk after kill. (diff-post-command-hook): Call diff-beginning-of-hunk with non-nil argument. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;