GNU bug report logs - #25570
24.5; diff-hunk-kill: Show more clear error messages

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Sun, 29 Jan 2017 11:37:01 UTC

Severity: minor

Tags: patch

Found in version 24.5

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#25570: closed (24.5; diff-hunk-kill: Show more clear error
 messages)
Date: Thu, 02 Feb 2017 13:34:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 02 Feb 2017 22:33:16 +0900
with message-id <87poj07m5f.fsf <at> calancha-pc>
and subject line Re: bug#25570: 24.5; diff-hunk-kill: Show more clear error messages
has caused the debbugs.gnu.org bug report #25570,
regarding 24.5; diff-hunk-kill: Show more clear error messages
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
25570: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25570
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; diff-hunk-kill: Show more clear error messages
Date: Sun, 29 Jan 2017 20:36:41 +0900 (JST)
emacs -Q:
; Put following content in a buffer in diff-mode:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; START
diff --git a/a b/a
index 184cbf6..d2d9a24 100644
--- a/a
+++ b/a
@@ -1,2 +1,2 @@
-I have a foo in my bar.
+I have a qux in my bar.
 Me too.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END
< ; Go to beginning of buffer
M-k ; Signal error: Can't find the beginning of the file.
M-K ; Same.
M-n M-k ; Delete hunk OK, but it shows previous error in echo area.

I propose the following patch:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 10af5a6466328acff37485364f8332a8043872e8 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sun, 29 Jan 2017 20:17:09 +0900
Subject: [PATCH] Ignore error after kill last file or hunk

* lisp/vc/diff-mode.el (diff-hunk-kill): Ignore error after kill last hunk.
(diff-file-kill): Idem.
Go to beginning of hunk before kill (Bug#25570).
---
 lisp/vc/diff-mode.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index e609ca9f94..3f3ade799b 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -668,7 +668,7 @@ diff-hunk-kill
 	 (inhibit-read-only t))
     (apply 'kill-region bounds)
     (goto-char (car bounds))
-    (diff-beginning-of-hunk t)))
+    (ignore-errors (diff-beginning-of-hunk t))))

 (defun diff-beginning-of-file-and-junk ()
   "Go to the beginning of file-related diff-info.
@@ -720,9 +720,10 @@ diff-beginning-of-file-and-junk
 (defun diff-file-kill ()
   "Kill current file's hunks."
   (interactive)
+  (diff-beginning-of-hunk t)
   (let ((inhibit-read-only t))
     (apply 'kill-region (diff-bounds-of-file)))
-  (diff-beginning-of-hunk t))
+  (ignore-errors (diff-beginning-of-hunk t)))

 (defun diff-kill-junk ()
   "Kill spurious empty diffs."
-- 
2.11.0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.6)
 of 2017-01-29
Repository revision: 0073223c23749ffd6bd3f882bc30a82cc37efd2a


[Message part 3 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: 25570-done <at> debbugs.gnu.org
Subject: Re: bug#25570: 24.5; diff-hunk-kill: Show more clear error messages
Date: Thu, 02 Feb 2017 22:33:16 +0900
Tino Calancha <tino.calancha <at> gmail.com> writes:

> emacs -Q:
> ; Put following content in a buffer in diff-mode:
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; START
> diff --git a/a b/a
> index 184cbf6..d2d9a24 100644
> --- a/a
> +++ b/a
> @@ -1,2 +1,2 @@
> -I have a foo in my bar.
> +I have a qux in my bar.
>  Me too.
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END
> < ; Go to beginning of buffer
> M-k ; Signal error: Can't find the beginning of the file.
> M-K ; Same.
> M-n M-k ; Delete hunk OK, but it shows previous error in echo area.
Pushed fix to master branch as commit 01d87bf846b478dea0bfe824678e76089f5af2c7


This bug report was last modified 8 years and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.