Subject: bug#66395: 28.2; Todo-mode locks up when trying to edit an entry

From: "Nathan R. DeGruchy" <[email-masked]>
Date: Sat, 7 Oct 2023 23:20:51 +0000

Stephen Berman <[email-masked]> writes:

> On Sat, 7 Oct 2023 19:06:55 +0000 "Nathan R. DeGruchy" <[email-masked]> wrote:
>
>> I am trying to explore using 'todo-mode' as a todo list and while I can
>> see and create entries in todo-mode using the normal functions, trying
>> to edit an item seems to cause emacs to soft-lock. I can reproduce this
>> in a config-less emacs via `emacs -Q`.
>>
>> Basically, I have a todo-file at $HOME/.config/emacs/todo/tasks.todo,
>> this was created when using `todo-show` initially. The contents are not
>> very complex:
>>
>> (("Emacs" . [1 0 0 0]) ("Home" . [1 0 0 0]))
>> --==-- Emacs
>> [2023-10-07] Learn Todo Mode
>>
>> ==--== DONE
>> --==-- Home
>> [2023-10-07] Get new wiper blades
>>
>> ==--== DONE
>>
>> When on either of the items, if I hit 'e' to edit them, it causes emacs
>> to lock up, specifically around `todo-done-item-p()`. I found this out
>> by enabling `toggle-debug-on-quit`, reproducing the error, and the
>> C-g'ing out of the loop/lockup. I also tried to trace through the
>> todo-edit-item with edebug-defun. Stepping through, it seems to reach
>> the same predicate function and ... stop.
>>
>> I'm not sure where to go from here.
>
> On Sat, 07 Oct 2023 14:37:00 -0500 LdBeth <[email-masked]> wrote:
>
>> As we have discussed on IRC, the nonstandard timestamp format is the cause.
>
> Yes.  This is a duplicate of bug#55284.  At the time that bug was
> reported, I didn't have time to try fixing it (being the todo-mode
> maintainer), and later, unfortunately, I forgot about it.  I'll try to
> look into it soon, but, as I noted in that bug thread, I think it's not
> easy to fix.  One issue is that todo-mode basically employs the same
> handling of date formats as diary-lib.el, and the ISO date style causes
> problems there too, see bug#55286.
>
>> The hang is cause by the while loop `todo-item-start' not properly handle fail
>> case, however.
>>
>> This patch would at least fix the hang.
>>
>> ---
>> LdBeth
>>
>> --- todo-mode.el.old	2023-10-07 14:28:59.000000000 -0500
>> +++ todo-mode.el	2023-10-07 14:30:20.000000000 -0500
>> @@ -5242,8 +5242,8 @@
>>  	   ;; Buffer is widened.
>>  	   (looking-at (regexp-quote todo-category-beg)))
>>      (goto-char (line-beginning-position))
>> -    (while (not (looking-at todo-item-start))
>> -      (forward-line -1))
>> +    (while (and (not (looking-at todo-item-start))
>> +                (= (forward-line -1) 0)))
>>      (point)))
>>
>>  (defun todo-item-end ()
>
> Thanks.  Even though this doesn't eliminate other problems with using
> the ISO date style in todo-mode (or in the Emacs Diary), since it does
> prevent the infinite loop here, it may be a good stopgap.
>
> Steve Berman

I guess I could also change back to 'american' or 'european' forms
instead of trying to force ISO8601. I appreciate the work being done.

-- 
Nathan DeGruchy
https://degruchy.org/
[email-masked]