diff options
| author | Stephen Berman | 2012-10-08 14:50:40 +0200 |
|---|---|---|
| committer | Stephen Berman | 2012-10-08 14:50:40 +0200 |
| commit | fec0fdaebb3e1db03b7b76ef5ea2dad61c2399f8 (patch) | |
| tree | f68c098128e7a70b376ffe379e4e1ff33e840ecb | |
| parent | 57da062dfef7a780b82742e26cb797f8841b6745 (diff) | |
| download | emacs-fec0fdaebb3e1db03b7b76ef5ea2dad61c2399f8.tar.gz emacs-fec0fdaebb3e1db03b7b76ef5ea2dad61c2399f8.zip | |
* calendar/todos.el (todos-move-item): If user quits before
completing movement, restore display of initial category; If item
is moved to end of target category, make sure the items above it
are displayed in the window.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 98 |
2 files changed, 64 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 377b1883be6..ae920322f8a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-10-08 Stephen Berman <Stephen.Berman@rub.de> | ||
| 2 | |||
| 3 | * calendar/todos.el (todos-move-item): If user quits before | ||
| 4 | completing movement, restore display of initial category; If item | ||
| 5 | is moved to end of target category, make sure the items above it | ||
| 6 | are displayed in the window. | ||
| 7 | |||
| 1 | 2012-10-08 Stephen Berman <stephen.berman@gmx.net> | 8 | 2012-10-08 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 9 | ||
| 3 | * calendar/todos.el: Fixes to todos-move-item and some of its | 10 | * calendar/todos.el: Fixes to todos-move-item and some of its |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index b6dff87348a..977d74501a9 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -4762,7 +4762,7 @@ entry/entries in that category." | |||
| 4762 | file1)) | 4762 | file1)) |
| 4763 | (count 0) | 4763 | (count 0) |
| 4764 | (count-diary 0) | 4764 | (count-diary 0) |
| 4765 | ov cat2 nmark) | 4765 | ov cat2 moved nmark) |
| 4766 | (set-buffer (find-file-noselect file2)) | 4766 | (set-buffer (find-file-noselect file2)) |
| 4767 | (unwind-protect | 4767 | (unwind-protect |
| 4768 | (progn | 4768 | (progn |
| @@ -4802,46 +4802,62 @@ entry/entries in that category." | |||
| 4802 | (when (todos-diary-item-p) (setq count-diary 1))) | 4802 | (when (todos-diary-item-p) (setq count-diary 1))) |
| 4803 | (set-window-buffer (selected-window) | 4803 | (set-window-buffer (selected-window) |
| 4804 | (set-buffer (find-file-noselect file2))) | 4804 | (set-buffer (find-file-noselect file2))) |
| 4805 | (todos-set-item-priority item cat2 t) | 4805 | (unwind-protect |
| 4806 | (setq nmark (point-marker)) | 4806 | (progn |
| 4807 | (todos-update-count 'todo count) | 4807 | (todos-set-item-priority item cat2 t) |
| 4808 | (todos-update-count 'diary count-diary) | 4808 | (setq moved t)) |
| 4809 | (todos-update-categories-sexp) | 4809 | (cond |
| 4810 | (with-current-buffer (find-buffer-visiting file1) | 4810 | ;; Move succeeded, so remove item from starting category, |
| 4811 | (save-excursion | 4811 | ;; update item counts and display the category containing |
| 4812 | (save-restriction | 4812 | ;; the moved item. |
| 4813 | (widen) | 4813 | (moved |
| 4814 | (goto-char omark) | 4814 | (setq nmark (point-marker)) |
| 4815 | (if marked | 4815 | (todos-update-count 'todo count) |
| 4816 | (let (beg end) | 4816 | (todos-update-count 'diary count-diary) |
| 4817 | (setq item nil) | 4817 | (todos-update-categories-sexp) |
| 4818 | (re-search-backward | 4818 | (with-current-buffer (find-buffer-visiting file1) |
| 4819 | (concat "^" (regexp-quote todos-category-beg)) nil t) | 4819 | (save-excursion |
| 4820 | (forward-line) | 4820 | (save-restriction |
| 4821 | (setq beg (point)) | 4821 | (widen) |
| 4822 | (re-search-forward | 4822 | (goto-char omark) |
| 4823 | (concat "^" (regexp-quote todos-category-done)) nil t) | 4823 | (if marked |
| 4824 | (setq end (match-beginning 0)) | 4824 | (let (beg end) |
| 4825 | (goto-char beg) | 4825 | (setq item nil) |
| 4826 | (while (< (point) end) | 4826 | (re-search-backward |
| 4827 | (if (todos-marked-item-p) | 4827 | (concat "^" (regexp-quote todos-category-beg)) nil t) |
| 4828 | (todos-remove-item) | 4828 | (forward-line) |
| 4829 | (todos-forward-item))) | 4829 | (setq beg (point)) |
| 4830 | ;; FIXME: does this work? | 4830 | (re-search-forward |
| 4831 | (remove-overlays (point-min) (point-max) | 4831 | (concat "^" (regexp-quote todos-category-done)) nil t) |
| 4832 | 'before-string todos-item-mark) | 4832 | (setq end (match-beginning 0)) |
| 4833 | (setq todos-categories-with-marks | 4833 | (goto-char beg) |
| 4834 | (assq-delete-all cat1 todos-categories-with-marks))) | 4834 | (while (< (point) end) |
| 4835 | (if ov (delete-overlay ov)) | 4835 | (if (todos-marked-item-p) |
| 4836 | (todos-remove-item)))) | 4836 | (todos-remove-item) |
| 4837 | (todos-update-count 'todo (- count) cat1) | 4837 | (todos-forward-item))) |
| 4838 | (todos-update-count 'diary (- count-diary) cat1) | 4838 | ;; FIXME: does this work? |
| 4839 | (todos-update-categories-sexp)) | 4839 | (remove-overlays (point-min) (point-max) |
| 4840 | (set-window-buffer (selected-window) | 4840 | 'before-string todos-item-mark) |
| 4841 | (set-buffer (find-file-noselect file2))) | 4841 | (setq todos-categories-with-marks |
| 4842 | (setq todos-category-number (todos-category-number cat2)) | 4842 | (assq-delete-all cat1 todos-categories-with-marks))) |
| 4843 | (todos-category-select) | 4843 | (if ov (delete-overlay ov)) |
| 4844 | (goto-char nmark))))) | 4844 | (todos-remove-item)))) |
| 4845 | (todos-update-count 'todo (- count) cat1) | ||
| 4846 | (todos-update-count 'diary (- count-diary) cat1) | ||
| 4847 | (todos-update-categories-sexp)) | ||
| 4848 | (set-window-buffer (selected-window) | ||
| 4849 | (set-buffer (find-file-noselect file2))) | ||
| 4850 | (setq todos-category-number (todos-category-number cat2)) | ||
| 4851 | (todos-category-select) | ||
| 4852 | (goto-char nmark) | ||
| 4853 | ;; If item is moved to end of category, make sure the | ||
| 4854 | ;; items above it are displayed in the window. | ||
| 4855 | (recenter)) | ||
| 4856 | ;; User quit before moving, so return to starting category. | ||
| 4857 | (t | ||
| 4858 | (todos-category-number cat1) | ||
| 4859 | (todos-category-select) | ||
| 4860 | (goto-char omark)))))))) | ||
| 4845 | 4861 | ||
| 4846 | (defun todos-move-item-to-file () | 4862 | (defun todos-move-item-to-file () |
| 4847 | "Move the current todo item to a category in another Todos file." | 4863 | "Move the current todo item to a category in another Todos file." |