From: Stephen Berman Date: Wed, 28 May 2025 15:17:23 +0000 (+0200) Subject: Fix bug in 'todo-jump-to-category' (bug#78608) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=97802d8460ddde2bcf8f21296fc8ae979da40e6c;p=emacs.git 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). (cherry picked from commit 4507b6a9c7587c2b3caa241982db13e999197b1c) --- diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 5b9bf2d8e16..1430eda5b03 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -950,12 +950,9 @@ Categories mode." todo-current-todo-file) ".toda") ;; Otherwise, jump to the category in the todo file. todo-current-todo-file))) - (len (length todo-categories)) (cat+file (unless cat (todo-read-category "Jump to category: " (if archive 'archive) file))) - (add-item (and todo-add-item-if-new-category - (> (length todo-categories) len))) (category (or cat (car cat+file)))) (unless cat (setq file0 (cdr cat+file))) (with-current-buffer (find-file-noselect file0 'nowarn) @@ -969,7 +966,10 @@ Categories mode." (todo-category-select) (goto-char (point-min)) (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) "Move point down to the beginning of the next item.