GNU bug report logs - #20832
25.0.50; todo-show accidentally deleted my todo file.

Previous Next

Package: emacs;

Reported by: Nicolas Richard <youngfrog <at> members.fsf.org>

Date: Wed, 17 Jun 2015 05:41:02 UTC

Severity: normal

Found in version 25.0.50

Done: Stephen Berman <stephen.berman <at> gmx.net>

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: Nicolas Richard <youngfrog <at> members.fsf.org>
Subject: bug#20832: closed (Re: bug#20832: 25.0.50; todo-show accidentally
 deleted my todo file.)
Date: Fri, 19 Jun 2015 15:15:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#20832: 25.0.50; todo-show accidentally deleted my todo file.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 20832 <at> debbugs.gnu.org.

-- 
20832: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20832
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stephen Berman <stephen.berman <at> gmx.net>
To: Nicolas Richard <nrichard <at> members.fsf.org>
Cc: 20832-done <at> debbugs.gnu.org
Subject: Re: bug#20832: 25.0.50; todo-show accidentally deleted my todo file.
Date: Fri, 19 Jun 2015 17:14:31 +0200
On Thu, 18 Jun 2015 13:52:21 +0200 Nicolas Richard <nrichard <at> members.fsf.org> wrote:

> Le 18/06/2015 12:15, Stephen Berman a écrit :

>>                                              But if there are other
>> triggers, then your patch may be needed.  However, since I haven't found
>> any other way to make the problem you encountered occur, I'm inclined to
>> install just the patch below; that way, if there is some other way to
>> get an empty but modified todo-mode buffer, we may find it and be able
>> to fix the underlying cause.
>
> Throwing an error seemed like a good way to find such problems, to me,
> better so than silently deleting the file.

That's true, I guess it's better to be safe than sorry.

>> The following patch makes todo-show display the todo file in the
>> previous window when invoked in the minibuffer.  An alternative would be
>> to simply error out when invoking todo-show in the minibuffer.  But I
>> think it could be useful to display the todo file while in the
>> minibuffer.  Do you see a problem with this?
>
> I don't see a need for (with-selected-window)

You're right, it's unnecessary; thanks for noticing.  (I had first tried
to fix it without that macro and on testing it changed the selected
window from the minibuffer to the todo-mode buffer, so that's why I
thought I needed with-selected-window, but I must have used different
functions, I can't remember anymore.)

I installed both patches in separate commits to keep the author credits
clear (with a slightly tweaked error message in your patch) and am
closing this bug.  Thanks again.

Steve Berman

[Message part 3 (message/rfc822, inline)]
From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; todo-show accidentally deleted my todo file.
Date: Wed, 17 Jun 2015 07:39:59 +0200
[Message part 4 (text/plain, inline)]
I managed to lose my todo-mode.el todo file. I don't really know how
this happened, I guess it was a combination of showing the todo file
while in the minibuffer and hitting C-g, but I noticed it too late, and
then could not reproduce.

In any case, I suspect that todo-mode.el itself deleted it, so I suggest
the following patch as a safety measure.

[0001-todo-show-Throw-an-error-if-buffer-is-empty-but-was-.patch (text/x-diff, inline)]
From 9088fc5037f587eab00c083d703b0a8cbf3eaf31 Mon Sep 17 00:00:00 2001
From: Nicolas Richard <youngfrog <at> members.fsf.org>
Date: Thu, 28 May 2015 08:57:45 +0200
Subject: [PATCH] (todo-show): Throw an error if buffer is empty but was
 modified.

* lisp/calendar/todo-mode.el (todo-show): Throw an error if buffer
is empty but was modified.
---
 lisp/calendar/todo-mode.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 7369ec2..85d4a80 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -743,6 +743,8 @@ corresponding todo file, displaying the corresponding category."
 	    (setq todo-category-number (todo-category-number cat)))
 	  ;; If this is a new todo file, add its first category.
 	  (when (zerop (buffer-size))
+            (when (buffer-modified-p)
+              (error "Buffer is empty but modified. Aborting."))
 	    (let (cat-added)
 	      (unwind-protect
 		  (setq todo-category-number
-- 
1.9.1


This bug report was last modified 10 years and 37 days ago.

Previous Next


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