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.
This commit is contained in:
parent
bc70fda2c9
commit
e5c17f4678
1 changed files with 18 additions and 7 deletions
|
@ -1414,7 +1414,12 @@ the archive of the file moved to, creating it if it does not exist."
|
||||||
(setq todo-files (funcall todo-files-function))
|
(setq todo-files (funcall todo-files-function))
|
||||||
(todo-reevaluate-filelist-defcustoms))
|
(todo-reevaluate-filelist-defcustoms))
|
||||||
(dolist (buf buffers)
|
(dolist (buf buffers)
|
||||||
|
;; Make sure archive file is in Todo Archive mode so that
|
||||||
|
;; todo-categories has correct value.
|
||||||
(with-current-buffer (find-file-noselect buf)
|
(with-current-buffer (find-file-noselect buf)
|
||||||
|
(when (equal (file-name-extension (buffer-file-name)) "toda")
|
||||||
|
(unless (derived-mode-p 'todo-archive-mode)
|
||||||
|
(todo-archive-mode)))
|
||||||
(widen)
|
(widen)
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(let* ((beg (re-search-backward
|
(let* ((beg (re-search-backward
|
||||||
|
@ -1466,10 +1471,18 @@ the archive of the file moved to, creating it if it does not exist."
|
||||||
(re-search-backward
|
(re-search-backward
|
||||||
(concat "^" (regexp-quote todo-category-beg)
|
(concat "^" (regexp-quote todo-category-beg)
|
||||||
"\\(" (regexp-quote cat) "\\)$") nil t)
|
"\\(" (regexp-quote cat) "\\)$") nil t)
|
||||||
(replace-match new nil nil nil 1)))
|
(replace-match new nil nil nil 1))
|
||||||
(setq todo-categories
|
(setq todo-categories
|
||||||
(append todo-categories (list (cons (or new cat) counts))))
|
(append todo-categories (list (cons (or new cat) counts))))
|
||||||
(todo-update-categories-sexp)
|
(goto-char (point-min))
|
||||||
|
(if (looking-at "((\"")
|
||||||
|
;; Delete existing sexp.
|
||||||
|
(delete-region (line-beginning-position) (line-end-position))
|
||||||
|
;; Otherwise, file is new, so make space for categories sexp.
|
||||||
|
(insert "\n")
|
||||||
|
(goto-char (point-min)))
|
||||||
|
;; Insert (new or updated) sexp.
|
||||||
|
(prin1 todo-categories (current-buffer)))
|
||||||
;; If archive was just created, save it to avoid "File
|
;; If archive was just created, save it to avoid "File
|
||||||
;; <xyz> no longer exists!" message on invoking
|
;; <xyz> no longer exists!" message on invoking
|
||||||
;; `todo-view-archived-items'.
|
;; `todo-view-archived-items'.
|
||||||
|
@ -1500,9 +1513,7 @@ the archive of the file moved to, creating it if it does not exist."
|
||||||
(setq todo-category-number 1))
|
(setq todo-category-number 1))
|
||||||
(todo-category-select)))))
|
(todo-category-select)))))
|
||||||
(set-window-buffer (selected-window)
|
(set-window-buffer (selected-window)
|
||||||
(set-buffer (find-file-noselect nfile)))
|
(set-buffer (find-file-noselect nfile))))))
|
||||||
(todo-category-number (or new cat))
|
|
||||||
(todo-category-select))))
|
|
||||||
|
|
||||||
(defun todo-merge-category (&optional file)
|
(defun todo-merge-category (&optional file)
|
||||||
"Merge current category into another existing category.
|
"Merge current category into another existing category.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue