bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25524: 26.0.50; diff-mode is broken


From: Tino Calancha
Subject: bug#25524: 26.0.50; diff-mode is broken
Date: Thu, 26 Jan 2017 01:32:56 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]