aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/calendar')
-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."
902 (todo-show) 902 (todo-show)
903 (let* ((archive (eq where 'archive)) 903 (let* ((archive (eq where 'archive))
904 (cat (unless archive where)) 904 (cat (unless archive where))
905 (goto-archive (and cat
906 todo-skip-archived-categories
907 (zerop (todo-get-count 'todo cat))
908 (zerop (todo-get-count 'done cat))
909 (not (zerop (todo-get-count 'archived cat)))))
905 (file0 (when cat ; We're in Todo Categories mode. 910 (file0 (when cat ; We're in Todo Categories mode.
906 ;; With non-nil `todo-skip-archived-categories' 911 (if goto-archive
907 ;; jump to archive file of a category with only 912 ;; If the category has only archived items and
908 ;; archived items. 913 ;; `todo-skip-archived-categories' is non-nil, jump to
909 (if (and todo-skip-archived-categories 914 ;; the archive category.
910 (zerop (todo-get-count 'todo cat))
911 (zerop (todo-get-count 'done cat))
912 (not (zerop (todo-get-count 'archived cat))))
913 (concat (file-name-sans-extension 915 (concat (file-name-sans-extension
914 todo-current-todo-file) ".toda") 916 todo-current-todo-file) ".toda")
915 ;; Otherwise, jump to current todo file. 917 ;; Otherwise, jump to the category in the todo file.
916 todo-current-todo-file))) 918 todo-current-todo-file)))
917 (len (length todo-categories)) 919 (len (length todo-categories))
918 (cat+file (unless cat 920 (cat+file (unless cat
@@ -923,18 +925,15 @@ Categories mode."
923 (category (or cat (car cat+file)))) 925 (category (or cat (car cat+file))))
924 (unless cat (setq file0 (cdr cat+file))) 926 (unless cat (setq file0 (cdr cat+file)))
925 (with-current-buffer (find-file-noselect file0 'nowarn) 927 (with-current-buffer (find-file-noselect file0 'nowarn)
926 (setq todo-current-todo-file file0) 928 (when goto-archive (todo-archive-mode))
927 ;; If called from Todo Categories mode, clean up before jumping. 929 (set-window-buffer (selected-window)
928 (if (string= (buffer-name) todo-categories-buffer) 930 (set-buffer (find-buffer-visiting file0)))
929 (kill-buffer)) 931 (unless todo-global-current-todo-file
930 (set-window-buffer (selected-window) 932 (setq todo-global-current-todo-file todo-current-todo-file))
931 (set-buffer (find-buffer-visiting file0))) 933 (todo-category-number category)
932 (unless todo-global-current-todo-file 934 (todo-category-select)
933 (setq todo-global-current-todo-file todo-current-todo-file)) 935 (goto-char (point-min))
934 (todo-category-number category) 936 (when add-item (todo-insert-item--basic))))))
935 (todo-category-select)
936 (goto-char (point-min))
937 (when add-item (todo-insert-item--basic))))))
938 937
939(defun todo-next-item (&optional count) 938(defun todo-next-item (&optional count)
940 "Move point down to the beginning of the next item. 939 "Move point down to the beginning of the next item.