From: Tino Calancha <tino.calancha@gmail.com>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: npostavs@users.sourceforge.net, Mark Oteiza <mvoteiza@udel.edu>,
Stefan Monnier <monnier@iro.umontreal.ca>,
Dmitry Gutov <dgutov@yandex.ru>,
25105@debbugs.gnu.org, Dima Kogan <dima@secretsauce.net>
Subject: bug#25105: M-p in diff-mode jumps too far
Date: Mon, 16 Jan 2017 15:26:00 +0900 (JST) [thread overview]
Message-ID: <alpine.DEB.2.20.1701161514330.7787@calancha-pc> (raw)
In-Reply-To: <alpine.DEB.2.20.1701141441450.4011@calancha-pc>
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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
next prev parent reply other threads:[~2017-01-16 6:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-08 21:21 bug#25400: M-p in diff-mode jumps too far Stefan Monnier
2017-01-08 23:27 ` Mark Oteiza
2017-01-09 4:34 ` Stefan Monnier
2017-01-11 4:38 ` bug#25105: " Tino Calancha
2017-01-11 23:27 ` Mark Oteiza
2017-01-11 23:34 ` Dmitry Gutov
2017-01-12 3:53 ` bug#25400: " Tino Calancha
2017-01-13 3:35 ` Dmitry Gutov
2017-01-13 3:55 ` Tino Calancha
2017-01-14 3:11 ` bug#25105: bug#25400: " Dmitry Gutov
2017-01-21 3:02 ` Tino Calancha
2017-01-23 3:42 ` bug#25105: " Dmitry Gutov
2017-01-13 4:25 ` Tino Calancha
2017-01-13 5:57 ` bug#25105: " npostavs
2017-01-13 6:26 ` Tino Calancha
2017-01-13 6:42 ` bug#25105: " npostavs
2017-01-13 6:54 ` Tino Calancha
2017-01-14 1:49 ` npostavs
2017-01-14 5:47 ` Tino Calancha
2017-01-16 6:26 ` Tino Calancha [this message]
2017-01-17 23:24 ` Dmitry Gutov
2017-01-18 6:11 ` Tino Calancha
2017-01-14 3:16 ` bug#25105: bug#25400: " Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1701161514330.7787@calancha-pc \
--to=tino.calancha@gmail.com \
--cc=25105@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=dima@secretsauce.net \
--cc=monnier@iro.umontreal.ca \
--cc=mvoteiza@udel.edu \
--cc=npostavs@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).