emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 0932b94: Fix todo-mode bug involving archived ite


From: Stephen Berman
Subject: [Emacs-diffs] emacs-25 0932b94: Fix todo-mode bug involving archived items (bug#23447)
Date: Wed, 04 May 2016 19:53:13 +0000

branch: emacs-25
commit 0932b948971770201b135d5f0dee82b91a1eef92
Author: Stephen Berman <address@hidden>
Commit: Stephen Berman <address@hidden>

    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.
---
 lisp/calendar/todo-mode.el |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 0529e97..8e75258 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]