]> git.eshelyaron.com Git - emacs.git/commitdiff
* calendar/todos.el (todos-archive-done-item): Fix archiving of
authorStephen Berman <stephen.berman@gmx.net>
Sat, 15 Dec 2012 23:33:14 +0000 (00:33 +0100)
committerStephen Berman <stephen.berman@gmx.net>
Sat, 15 Dec 2012 23:33:14 +0000 (00:33 +0100)
all done items in a category and resulting display of todo file.

lisp/ChangeLog
lisp/calendar/todos.el

index 57113398ec73c13143f8f3be704651e07bae8beb..4a8f05464398493ae58d9854c6ed22090fd90101 100644 (file)
@@ -1,3 +1,8 @@
+2012-12-15  Stephen Berman  <stephen.berman@gmx.net>
+
+       * calendar/todos.el (todos-archive-done-item): Fix archiving of
+       all done items in a category and resulting display of todo file.
+
 2012-12-14  Stephen Berman  <stephen.berman@gmx.net>
 
        * calendar/todos.el (todos-priorities-rules): Fix customization
index b4ad6c16f6450b239772812607661bb3fe327842..4b603e67abaafcba70695222e945007ebe740e25 100644 (file)
@@ -5329,6 +5329,7 @@ this category does not exist in the archive, it is created."
                          (get-buffer-create afile)))
               (item (and (todos-done-item-p) (concat (todos-item-string) "\n")))
               (count 0)
+              (opoint (unless (todos-done-item-p) (point)))
               marked-items beg end all-done
               buffer-read-only)
          (cond
@@ -5358,7 +5359,10 @@ this category does not exist in the archive, it is created."
                                  (match-beginning 0)
                                (point-max))
                          all-done (buffer-substring-no-properties beg end)
-                         count (todos-get-count 'done))))
+                         count (todos-get-count 'done))
+                   ;; Restore starting point, unless it was on a done
+                   ;; item, since they will all be deleted.
+                   (when opoint (goto-char opoint))))
              (throw 'end nil))))
          (when (or marked all item)
            (with-current-buffer archive
@@ -5389,7 +5393,11 @@ this category does not exist in the archive, it is created."
                  (write-region nil nil afile)
                  (kill-buffer))))
            (with-current-buffer tbuf
-             (cond ((or marked item)
+             (cond ((or marked
+                        ;; If we're archiving all done items, can't
+                        ;; first archive item point was on, since
+                        ;; that will short-circuit the rest.
+                        (and item (not all)))
                     (and marked (goto-char (point-min)))
                     (catch 'done
                       (while (not (eobp))
@@ -5405,10 +5413,14 @@ this category does not exist in the archive, it is created."
                                 (throw 'done (setq item nil))))
                           (todos-forward-item)))))
                    (all
-                    (remove-overlays beg end)
-                    (delete-region beg end)
-                    (todos-update-count 'done (- count))
-                    (todos-update-count 'archived count)))
+                    (save-excursion
+                      (save-restriction
+                        ;; Make sure done items are accessible.
+                        (widen)
+                        (remove-overlays beg end)
+                        (delete-region beg end)
+                        (todos-update-count 'done (- count))
+                        (todos-update-count 'archived count)))))
              (when marked
                (remove-overlays (point-min) (point-max)
                                 'before-string todos-item-mark)
@@ -5420,7 +5432,12 @@ this category does not exist in the archive, it is created."
          (todos-category-number cat)
          (todos-category-select)
          (split-window-below)
-         (set-window-buffer (selected-window) tbuf))))))
+         (set-window-buffer (selected-window) tbuf)
+         ;; Make todo file current to select category.
+         (find-file (buffer-file-name tbuf))
+         ;; Make sure done item separator is hidden (if done items
+         ;; were initially visible).
+         (let (todos-show-with-done) (todos-category-select)))))))
 
 (defun todos-archive-category-done-items ()
   "Move all done items in this category to its archive."