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#25524: 26.0.50; diff-mode is broken Date: Thu, 26 Jan 2017 01:32:56 +0900 Message-ID: <87tw8ncd6v.fsf@gmail.com> References: <874m0nwshr.fsf@secretsauce.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1485362066 25167 195.159.176.226 (25 Jan 2017 16:34:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Jan 2017 16:34:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 25524@debbugs.gnu.org, tino.calancha@gmail.com To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 25 17:34:22 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 1cWQWR-0005SV-MG for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jan 2017 17:34:11 +0100 Original-Received: from localhost ([::1]:32807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWQWW-0003Ee-V7 for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jan 2017 11:34:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWQWL-0003Dp-Tf for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 11:34:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWQWI-0000kR-Qn for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 11:34:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cWQWI-0000kI-NY for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 11:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cWQWH-0005M6-UG for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 11:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Jan 2017 16:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25524 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25524-submit@debbugs.gnu.org id=B25524.148536199020525 (code B ref 25524); Wed, 25 Jan 2017 16:34:01 +0000 Original-Received: (at 25524) by debbugs.gnu.org; 25 Jan 2017 16:33:10 +0000 Original-Received: from localhost ([127.0.0.1]:42997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWQVR-0005Ky-Sm for submit@debbugs.gnu.org; Wed, 25 Jan 2017 11:33:10 -0500 Original-Received: from mail-pf0-f193.google.com ([209.85.192.193]:35315) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWQVQ-0005Km-8E for 25524@debbugs.gnu.org; Wed, 25 Jan 2017 11:33:08 -0500 Original-Received: by mail-pf0-f193.google.com with SMTP id f144so14703651pfa.2 for <25524@debbugs.gnu.org>; Wed, 25 Jan 2017 08:33:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=7Ia5ozesL48oduWsK2/k8i2XsqZmrvKHdiyzQ4ZwteI=; b=KxsYKK8OguxjgiEe4BVsKXFLQesTW+XfofKZSOg02G9Nh/GSe4FV3PAYvKgumw+t1U 2Vsj4sB6yDmXmeclAdDEFcw8EjyvaspmxQ+qDQjBdTUIlLoK6aReXmJ/xQcoytujcpH6 XlrPKE/8Md7BeCnxNBHknfA4A2FDRqwG572hSI6BO/Xwq499jagCiycYon9Dj5HL1idn zjs5GfQ+nosGurFA3+KKuTGic+hYt0OF3ywdPfuOD7rgekpjwZje+DpSCZoXpV8sbhpB JxPV46wXYZ+DvCeGOHGBi/na47gUWyJ6OCJTylAcz9BxSbCbOTENnAt5lhY5qolJjCFG eaiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=7Ia5ozesL48oduWsK2/k8i2XsqZmrvKHdiyzQ4ZwteI=; b=pf/uiicUq1GCxTZPV4Pk2zOZycUGF2f5NSOXrG77zWgPSry8kgAnaPj3/O2Wo9wawd m1u9lWWx8wo4ZcB4Jt2j+g6r2XVh84DlKFgMHE5rhl9HS6JEkEdnCVZcMy0zXREQbvRo ucD2UKmiQogUsKRrNZUMI/JZCL76d9DvOhvavg8bdpIUSpE1kklzMGtQA2N+hWZ2f+pf MgHI89GZENNcKH5VMiyGmUMmny6xek/MV5OtmwVZ/QX4hw5S2gYbZJ/LRo0eRie28hZo 0yFKNuG9t4ONYcyjnjr/WoumJcuGbjtWRDfXCLI9km1efnTZW32zJhwxBvha72FJ05g2 h2Yw== X-Gm-Message-State: AIkVDXKcKCwKesV4nkDQ9i/193OQzd9KWMFSVU9SsbNG9efyPUFfbbvv61Np8Jty7FEaGA== X-Received: by 10.84.136.7 with SMTP id 7mr5018161plk.100.1485361982296; Wed, 25 Jan 2017 08:33:02 -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 z74sm2347742pfd.70.2017.01.25.08.33.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jan 2017 08:33:01 -0800 (PST) In-Reply-To: <874m0nwshr.fsf@secretsauce.net> (Dima Kogan's message of "Tue, 24 Jan 2017 22:42:08 -0800") 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:128455 Archived-At: Dima Kogan 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 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