1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-14 16:50:58 +00:00

Fix todo-mode bug involving archived items (bug#23447)

* lisp/calendar/todo-mode.el (todo-jump-to-category): When jumping
from Todo Categories mode to a category with only archived items
and todo-skip-archived-categories is non-nil, make sure the
archive file buffer is in Todo Archive mode to prevent
todo-category-select from raising an error, and don't set
todo-current-todo-file, since that makes todo-show display the
archived category.  Remove a no-op call to kill-buffer, which is
already called in todo-insert-category-line.
This commit is contained in:
Stephen Berman 2016-05-04 21:52:32 +02:00
parent e68ad1f3f0
commit 0932b94897

View File

@ -902,17 +902,19 @@ Categories mode."
(todo-show)
(let* ((archive (eq where 'archive))
(cat (unless archive where))
(goto-archive (and cat
todo-skip-archived-categories
(zerop (todo-get-count 'todo cat))
(zerop (todo-get-count 'done cat))
(not (zerop (todo-get-count 'archived cat)))))
(file0 (when cat ; We're in Todo Categories mode.
;; With non-nil `todo-skip-archived-categories'
;; jump to archive file of a category with only
;; archived items.
(if (and todo-skip-archived-categories
(zerop (todo-get-count 'todo cat))
(zerop (todo-get-count 'done cat))
(not (zerop (todo-get-count 'archived cat))))
(if goto-archive
;; If the category has only archived items and
;; `todo-skip-archived-categories' is non-nil, jump to
;; the archive category.
(concat (file-name-sans-extension
todo-current-todo-file) ".toda")
;; Otherwise, jump to current todo file.
;; Otherwise, jump to the category in the todo file.
todo-current-todo-file)))
(len (length todo-categories))
(cat+file (unless cat
@ -923,18 +925,15 @@ Categories mode."
(category (or cat (car cat+file))))
(unless cat (setq file0 (cdr cat+file)))
(with-current-buffer (find-file-noselect file0 'nowarn)
(setq todo-current-todo-file file0)
;; If called from Todo Categories mode, clean up before jumping.
(if (string= (buffer-name) todo-categories-buffer)
(kill-buffer))
(set-window-buffer (selected-window)
(set-buffer (find-buffer-visiting file0)))
(unless todo-global-current-todo-file
(setq todo-global-current-todo-file todo-current-todo-file))
(todo-category-number category)
(todo-category-select)
(goto-char (point-min))
(when add-item (todo-insert-item--basic))))))
(when goto-archive (todo-archive-mode))
(set-window-buffer (selected-window)
(set-buffer (find-buffer-visiting file0)))
(unless todo-global-current-todo-file
(setq todo-global-current-todo-file todo-current-todo-file))
(todo-category-number category)
(todo-category-select)
(goto-char (point-min))
(when add-item (todo-insert-item--basic))))))
(defun todo-next-item (&optional count)
"Move point down to the beginning of the next item.