summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Berman <stephen.berman@gmx.net>2016-05-04 21:52:32 +0200
committerStephen Berman <stephen.berman@gmx.net>2016-05-04 21:52:32 +0200
commit0932b948971770201b135d5f0dee82b91a1eef92 (patch)
tree6dc46c625d02d661971de186690fa913b2ee61bf
parente68ad1f3f08268f0642ba19e7c894f9e05cb8e6f (diff)
downloademacs-0932b948971770201b135d5f0dee82b91a1eef92.tar.gz
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.
-rw-r--r--lisp/calendar/todo-mode.el39
1 files changed, 19 insertions, 20 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 0529e970333..8e752586053 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -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.