Subject: bug#27609: 26.0.50; Todo-mode bugs with hidden headers, etc.

From: Stephen Berman <[email-masked]>
Date: Fri, 07 Jul 2017 15:29:57 +0200

I found several bugs involving todo-mode hidden item date-time headers,
and in the course of debugging these found several other unrelated bugs.
I've fixed all of these and, being the maintainer of todo-mode.el, I
will push the fixes to master, together with accompanying tests I've
written.  This bug report is for reference, so I'll just list the bugs
without providing recipes to reproduce them (the tests more or less
embody recipes).

These are the bugs related to hidden headers:

- With date-time headers hidden (by typing `h' todo-toggle-item-header),
  relocating an item by changing its priority (`r', `l', `#'), moving it
  to another category (`m'), the done items section (`d') or archive (`A
  d'), undoing or unarchiving it (`u')) results in its date-time header
  being shown.
  
- With date-time headers hidden, if a new item is inserted, its
  date-time header is not hidden.
  
- With date-time headers hidden, `h' in an empty category fails to show
  the headers (but when the headers are shown, `h' in an empty category
  hides them).
  
- When date-time headers are hidden, typing `p' (todo-previous-item)
  moves point to the end of the item two items higher; it should move to
  the beginning of the next higher item.  And with item highlighting
  also enabled (by typing `H'), after `p' the item below point is
  highlighted: that's the correct item but it appears to be incorrect,
  since point is incorrectly not on that item.

These are the unrelated bugs:

- Typing `C *' (todo-mark-category) corrupts an internal data structure,
  resulting in incorrect item counts (shown by typing `F c' to display
  the table of categories in the file).  Also, when there are no todo
  items in the category and the done items are shown, typing `C *'
  raises a wrong-type-argument error.

- Typing `*' to mark an item and then `m' to move it to a preceding
  category results in an infinite loop.
  
- Typing `r' (todo-raise-item-priority) or `l' (todo-lower-item-priority)
  on a done item or an empty line raises a wrong-type-argument error;
  they should be noops.

- Typing `u' (todo-unarchive-items) on an archived item to restore it as
  a done item in its category puts point on the done items separator
  instead of on the restored item.

- Typing `g' (todo-revert-buffer) puts point at (point-max) and makes
  the category buffer writable; point should stay put and the category
  should be read-only.

Steve Berman

In GNU Emacs 26.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version 3.22.8)
 of 2017-07-07 built on rosalinde
Repository revision: 579a9ee22e0decf7bed8aff1751c5b3d147b921f