1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Fix bug in 'todo-jump-to-category' (bug#78608)

* lisp/calendar/todo-mode.el (todo-jump-to-category): Eliminate
comparison of the number of Todo categories before and after
specifying the category to jump to and replace it by a check of
whether there are any items in the category, since an existing
category should always have at least one item (perhaps done or
archived).
This commit is contained in:
Stephen Berman 2025-05-28 17:17:23 +02:00
parent 3e57c35323
commit 4507b6a9c7

View file

@ -952,12 +952,9 @@ Categories mode."
todo-current-todo-file) ".toda") todo-current-todo-file) ".toda")
;; Otherwise, jump to the category in the todo file. ;; Otherwise, jump to the category in the todo file.
todo-current-todo-file))) todo-current-todo-file)))
(len (length todo-categories))
(cat+file (unless cat (cat+file (unless cat
(todo-read-category "Jump to category: " (todo-read-category "Jump to category: "
(if archive 'archive) file))) (if archive 'archive) file)))
(add-item (and todo-add-item-if-new-category
(> (length todo-categories) len)))
(category (or cat (car cat+file)))) (category (or cat (car cat+file))))
(unless cat (setq file0 (cdr cat+file))) (unless cat (setq file0 (cdr cat+file)))
(with-current-buffer (find-file-noselect file0 'nowarn) (with-current-buffer (find-file-noselect file0 'nowarn)
@ -971,7 +968,10 @@ Categories mode."
(todo-category-select) (todo-category-select)
(goto-char (point-min)) (goto-char (point-min))
(if (bound-and-true-p hl-line-mode) (hl-line-highlight)) (if (bound-and-true-p hl-line-mode) (hl-line-highlight))
(when add-item (todo-insert-item--basic)))))) (when (and todo-add-item-if-new-category
;; A new category is empty on creation.
(seq-every-p #'zerop (cdr (assoc category todo-categories))))
(todo-insert-item--basic))))))
(defun todo-next-item (&optional count) (defun todo-next-item (&optional count)
"Move point down to the beginning of the next item. "Move point down to the beginning of the next item.