all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Dima Kogan <dima@secretsauce.net>
Cc: 25524@debbugs.gnu.org, tino.calancha@gmail.com
Subject: bug#25524: 26.0.50; diff-mode is broken
Date: Thu, 26 Jan 2017 01:32:56 +0900	[thread overview]
Message-ID: <87tw8ncd6v.fsf@gmail.com> (raw)
In-Reply-To: <874m0nwshr.fsf@secretsauce.net> (Dima Kogan's message of "Tue, 24 Jan 2017 22:42:08 -0800")

Dima Kogan <dima@secretsauce.net> writes:

> I'm using a very recent build from git: 0a49f158f15. I see diff-mode
> being broken in 2 ways.
Thank you for report this.  I confirm your observations.
> I'm attaching a diff file, produced by C-x v D in a project using
> subversion (then cut down and de-contented).
>
> Breakage 1:
>
>   1. emacs -Q /tmp/tst.patch
>   2. M-k
>
> I would expect this to kill the first hunk. Instead emacs barfs:
> Args out of range: something something
`diff-beginning-of-hunk' must return the pos of the beginning
of the hunk as stated in its docstring.

>
> Breakage 2:
>
>   1. emacs -Q /tmp/tst.patch
>   2. M-g g 13 RET     move point to the start of the 2nd hunk
>   3. M-k              I would expect this to kill the hunk at point (2nd
>                       hunk). I would then expect the point to remain at
>                       the 2nd hunk
>   4. M-k              Same as before. Should kill 2nd hunk
>   5. M-k              Same as before. Should kill 2nd hunk
>
> Instead, M-k #2 kills the 2nd hunk and then moves the point to the 1st
> hunk. So that subsequent M-k #3 kills the 1st hunk.
After recent changes `diff-file-junk-re' must be updated; currently,
it just contains Git diff keywords, i.e. `diff--at-diff-header-p'
with point in the first line of your example returns nil.

Following patch fix 1) and 2):
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 91351edff90628a1c134d79e13f3062467612478 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Thu, 26 Jan 2017 01:16:31 +0900
Subject: [PATCH] Fix Bug#25524

* lisp/vc/diff-mode.el (diff-beginning-of-hunk):
Return pos at beginning of hunk.
(diff-file-junk-re): Add SVN keywords.
---
 lisp/vc/diff-mode.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index b7ad8e8ebd..0de314df2d 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -499,9 +499,11 @@ diff-end-of-hunk
     (goto-char (or end (point-max)))))
 
 ;; "index ", "old mode", "new mode", "new file mode" and
-;; "deleted file mode" are output by git-diff.
+;; "deleted file mode" are output by git-diff; "Index: " and
+;; "========..." by SVN.
 (defconst diff-file-junk-re
-  "diff \\|index \\|\\(?:deleted file\\|new\\(?: file\\)?\\|old\\) mode\\|=== modified file")
+  (concat "Index: \\|" (make-string 67 ?=) "\\|"
+          "diff \\|index \\|\\(?:deleted file\\|new\\(?: file\\)?\\|old\\) mode\\|=== modified file"))
 
 ;; If point is in a diff header, then return beginning
 ;; of hunk position otherwise return nil.
@@ -545,7 +547,8 @@ diff-beginning-of-hunk
                (error "Can't find the beginning of the hunk")))
             ((re-search-backward regexp nil t)) ; In the middle of a hunk.
             ((re-search-forward regexp nil t) ; At first hunk header.
-             (forward-line 0))
+             (forward-line 0)
+             (point))
             (t (error "Can't find the beginning of the hunk"))))))
 
 (defun diff-unified-hunk-p ()
-- 
2.11.0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.6)
 of 2017-01-26
Repository revision: 6bfa9e9abca17290bc393d90aedb5abef83a3e06





  reply	other threads:[~2017-01-25 16:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25  6:42 bug#25524: 26.0.50; diff-mode is broken Dima Kogan
2017-01-25 16:32 ` Tino Calancha [this message]
2017-01-25 20:47   ` Noam Postavsky
2017-01-25 21:25     ` Dima Kogan
2017-01-26  4:29     ` Tino Calancha
2017-01-29  9:53       ` Tino Calancha

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tw8ncd6v.fsf@gmail.com \
    --to=tino.calancha@gmail.com \
    --cc=25524@debbugs.gnu.org \
    --cc=dima@secretsauce.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.