aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2016-03-26 23:14:50 +0100
committerStephen Berman2016-03-26 23:14:50 +0100
commite5c17f46785e2eca165ccd5aa890f212c6a61ca1 (patch)
treed7380a4fc823d2f736974329ccedc406bc2f6e53
parentbc70fda2c9f93a30351c7c79a2b5763bbbd7bbc6 (diff)
downloademacs-e5c17f46785e2eca165ccd5aa890f212c6a61ca1.tar.gz
emacs-e5c17f46785e2eca165ccd5aa890f212c6a61ca1.zip
Fix todo-mode category movement
* lisp/calendar/todo-mode.el (todo-move-category): Use moved category's existing categories sexp instead of invoking todo-update-categories-sexp in file moved to, in order to take archived items into account. If the moved category has archived items, handle the source archive buffer properly. Remove superfluous code.
-rw-r--r--lisp/calendar/todo-mode.el25
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 94cd08eaa4e..9574c03043e 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -1414,7 +1414,12 @@ the archive of the file moved to, creating it if it does not exist."
1414 (setq todo-files (funcall todo-files-function)) 1414 (setq todo-files (funcall todo-files-function))
1415 (todo-reevaluate-filelist-defcustoms)) 1415 (todo-reevaluate-filelist-defcustoms))
1416 (dolist (buf buffers) 1416 (dolist (buf buffers)
1417 ;; Make sure archive file is in Todo Archive mode so that
1418 ;; todo-categories has correct value.
1417 (with-current-buffer (find-file-noselect buf) 1419 (with-current-buffer (find-file-noselect buf)
1420 (when (equal (file-name-extension (buffer-file-name)) "toda")
1421 (unless (derived-mode-p 'todo-archive-mode)
1422 (todo-archive-mode)))
1418 (widen) 1423 (widen)
1419 (goto-char (point-max)) 1424 (goto-char (point-max))
1420 (let* ((beg (re-search-backward 1425 (let* ((beg (re-search-backward
@@ -1466,10 +1471,18 @@ the archive of the file moved to, creating it if it does not exist."
1466 (re-search-backward 1471 (re-search-backward
1467 (concat "^" (regexp-quote todo-category-beg) 1472 (concat "^" (regexp-quote todo-category-beg)
1468 "\\(" (regexp-quote cat) "\\)$") nil t) 1473 "\\(" (regexp-quote cat) "\\)$") nil t)
1469 (replace-match new nil nil nil 1))) 1474 (replace-match new nil nil nil 1))
1470 (setq todo-categories 1475 (setq todo-categories
1471 (append todo-categories (list (cons (or new cat) counts)))) 1476 (append todo-categories (list (cons (or new cat) counts))))
1472 (todo-update-categories-sexp) 1477 (goto-char (point-min))
1478 (if (looking-at "((\"")
1479 ;; Delete existing sexp.
1480 (delete-region (line-beginning-position) (line-end-position))
1481 ;; Otherwise, file is new, so make space for categories sexp.
1482 (insert "\n")
1483 (goto-char (point-min)))
1484 ;; Insert (new or updated) sexp.
1485 (prin1 todo-categories (current-buffer)))
1473 ;; If archive was just created, save it to avoid "File 1486 ;; If archive was just created, save it to avoid "File
1474 ;; <xyz> no longer exists!" message on invoking 1487 ;; <xyz> no longer exists!" message on invoking
1475 ;; `todo-view-archived-items'. 1488 ;; `todo-view-archived-items'.
@@ -1500,9 +1513,7 @@ the archive of the file moved to, creating it if it does not exist."
1500 (setq todo-category-number 1)) 1513 (setq todo-category-number 1))
1501 (todo-category-select))))) 1514 (todo-category-select)))))
1502 (set-window-buffer (selected-window) 1515 (set-window-buffer (selected-window)
1503 (set-buffer (find-file-noselect nfile))) 1516 (set-buffer (find-file-noselect nfile))))))
1504 (todo-category-number (or new cat))
1505 (todo-category-select))))
1506 1517
1507(defun todo-merge-category (&optional file) 1518(defun todo-merge-category (&optional file)
1508 "Merge current category into another existing category. 1519 "Merge current category into another existing category.