diff options
| author | Stephen Berman | 2013-01-08 14:06:12 +0100 |
|---|---|---|
| committer | Stephen Berman | 2013-01-08 14:06:12 +0100 |
| commit | c4bf3e3daad163c81e215a08c141269601f4194e (patch) | |
| tree | 1e72857246dbaa362ad63cba337cb625ac6faeb8 | |
| parent | 3a898abefd967d00573ec4ddb19c26db1ff9c1f6 (diff) | |
| download | emacs-c4bf3e3daad163c81e215a08c141269601f4194e.tar.gz emacs-c4bf3e3daad163c81e215a08c141269601f4194e.zip | |
* calendar/todos.el (todos-move-item): Allow moving done items to
done section of another category.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 106 |
2 files changed, 78 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9ca318515e9..754e936f2b3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-01-08 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * calendar/todos.el (todos-move-item): Allow moving done items to | ||
| 4 | done section of another category. | ||
| 5 | |||
| 1 | 2013-01-06 Stephen Berman <stephen.berman@gmx.net> | 6 | 2013-01-06 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 7 | ||
| 3 | * calendar/todos.el: Display numerical priority string of top | 8 | * calendar/todos.el: Display numerical priority string of top |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index b956e7807ae..0b3a3b57a9b 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -771,6 +771,7 @@ less than or equal the category's top priority setting." | |||
| 771 | (((class color) (min-colors 88) (background dark)) | 771 | (((class color) (min-colors 88) (background dark)) |
| 772 | :foreground "chocolate1") | 772 | :foreground "chocolate1") |
| 773 | (((class color) (min-colors 16) (background light)) | 773 | (((class color) (min-colors 16) (background light)) |
| 774 | ;; FIXME: this is the same as todos-date with default value of diary face | ||
| 774 | :foreground "red") | 775 | :foreground "red") |
| 775 | (((class color) (min-colors 16) (background dark)) | 776 | (((class color) (min-colors 16) (background dark)) |
| 776 | :foreground "red1") | 777 | :foreground "red1") |
| @@ -5001,7 +5002,7 @@ The new priority is set either interactively by prompt or by a | |||
| 5001 | numerical prefix argument, or noninteractively by argument ARG, | 5002 | numerical prefix argument, or noninteractively by argument ARG, |
| 5002 | whose value can be either of the symbols `raise' or `lower', | 5003 | whose value can be either of the symbols `raise' or `lower', |
| 5003 | meaning to raise or lower the item's priority by one." | 5004 | meaning to raise or lower the item's priority by one." |
| 5004 | (interactive) | 5005 | (interactive) ; Prefix arg? |
| 5005 | (let* ((item (or item (todos-item-string))) | 5006 | (let* ((item (or item (todos-item-string))) |
| 5006 | (marked (todos-marked-item-p)) | 5007 | (marked (todos-marked-item-p)) |
| 5007 | (cat (or cat (cond ((eq major-mode 'todos-mode) | 5008 | (cat (or cat (cond ((eq major-mode 'todos-mode) |
| @@ -5104,34 +5105,41 @@ meaning to raise or lower the item's priority by one." | |||
| 5104 | (todos-set-item-priority nil nil nil 'lower)) | 5105 | (todos-set-item-priority nil nil nil 'lower)) |
| 5105 | 5106 | ||
| 5106 | (defun todos-move-item (&optional file) | 5107 | (defun todos-move-item (&optional file) |
| 5107 | "Move at least one todo item to another category. | 5108 | "Move at least one todo or done item to another category. |
| 5108 | |||
| 5109 | If there are marked items, move all of these; otherwise, move | 5109 | If there are marked items, move all of these; otherwise, move |
| 5110 | the item at point. | 5110 | the item at point. |
| 5111 | 5111 | ||
| 5112 | With prefix argument FILE, prompt for a specific Todos file and | 5112 | With prefix argument FILE, prompt for a specific Todos file and |
| 5113 | choose (with TAB completion) a category in it to move the item or | 5113 | choose (with TAB completion) a category in it to move the item or |
| 5114 | items to; otherwise, choose and move to any category in either | 5114 | items to; otherwise, choose and move to any category in either |
| 5115 | the current Todos file or a file in `todos-category-completions-files'. | 5115 | the current Todos file or one of the files in |
| 5116 | 5116 | `todos-category-completions-files'. If the chosen category is | |
| 5117 | If the chosen category is not one of the existing categories, | 5117 | not an existing categories, then it is created and the item(s) |
| 5118 | then it is created and the item(s) become(s) the first | 5118 | become(s) the first entry/entries in that category. |
| 5119 | entry/entries in that category." | 5119 | |
| 5120 | With moved Todo items, prompt to set the priority in the category | ||
| 5121 | moved to (with multiple todos items, the one that had the highest | ||
| 5122 | priority in the category moved from gets the new priority and the | ||
| 5123 | rest of the moved todo items are inserted in sequence below it). | ||
| 5124 | Moved done items are appended to the end of the done items | ||
| 5125 | section in the category moved to." | ||
| 5120 | (interactive "P") | 5126 | (interactive "P") |
| 5121 | (let* ((cat1 (todos-current-category)) | 5127 | (let* ((cat1 (todos-current-category)) |
| 5122 | (marked (assoc cat1 todos-categories-with-marks))) | 5128 | (marked (assoc cat1 todos-categories-with-marks))) |
| 5123 | (unless (or (todos-done-item-p) | 5129 | ;; NOP if point is not on an item and there are no marked items. |
| 5124 | ;; Point is between todo and done items. | 5130 | (unless (and (looking-at "^$") |
| 5125 | (and (looking-at "^$") (not marked))) | 5131 | (not marked)) |
| 5126 | (let* ((buffer-read-only) | 5132 | (let* ((buffer-read-only) |
| 5127 | (file1 todos-current-todos-file) | 5133 | (file1 todos-current-todos-file) |
| 5128 | (num todos-category-number) | 5134 | (num todos-category-number) |
| 5129 | (item (todos-item-string)) | 5135 | (item (todos-item-string)) |
| 5130 | (diary-item (todos-diary-item-p)) | 5136 | (diary-item (todos-diary-item-p)) |
| 5137 | (done-item (and (todos-done-item-p) (concat item "\n"))) | ||
| 5131 | (omark (save-excursion (todos-item-start) (point-marker))) | 5138 | (omark (save-excursion (todos-item-start) (point-marker))) |
| 5132 | (count 0) | 5139 | (todo 0) |
| 5133 | (count-diary 0) | 5140 | (diary 0) |
| 5134 | ov cat+file cat2 file2 moved nmark) | 5141 | (done 0) |
| 5142 | ov cat+file cat2 file2 moved nmark todo-items done-items) | ||
| 5135 | (unwind-protect | 5143 | (unwind-protect |
| 5136 | (progn | 5144 | (progn |
| 5137 | (unless marked | 5145 | (unless marked |
| @@ -5149,24 +5157,50 @@ entry/entries in that category." | |||
| 5149 | (set-buffer (find-buffer-visiting file1)) | 5157 | (set-buffer (find-buffer-visiting file1)) |
| 5150 | (if marked | 5158 | (if marked |
| 5151 | (progn | 5159 | (progn |
| 5152 | (setq item nil) | ||
| 5153 | (goto-char (point-min)) | 5160 | (goto-char (point-min)) |
| 5154 | (while (not (eobp)) | 5161 | (while (not (eobp)) |
| 5155 | (when (todos-marked-item-p) | 5162 | (when (todos-marked-item-p) |
| 5156 | (setq item (concat item (todos-item-string) "\n")) | 5163 | (if (todos-done-item-p) |
| 5157 | (setq count (1+ count)) | 5164 | (setq done-items (concat done-items |
| 5158 | (when (todos-diary-item-p) | 5165 | (todos-item-string) "\n") |
| 5159 | (setq count-diary (1+ count-diary)))) | 5166 | done (1+ done)) |
| 5167 | (setq todo-items (concat todo-items | ||
| 5168 | (todos-item-string) "\n") | ||
| 5169 | todo (1+ todo)) | ||
| 5170 | (when (todos-diary-item-p) | ||
| 5171 | (setq diary (1+ diary))))) | ||
| 5160 | (todos-forward-item)) | 5172 | (todos-forward-item)) |
| 5161 | ;; Chop off last newline. | 5173 | ;; Chop off last newline of multiple todo item string, |
| 5162 | (setq item (substring item 0 -1))) | 5174 | ;; since it will be reinserted when setting priority |
| 5163 | (setq count 1) | 5175 | ;; (but with done items priority is not set, so keep |
| 5164 | (when (todos-diary-item-p) (setq count-diary 1))) | 5176 | ;; last newline). |
| 5177 | (and todo-items | ||
| 5178 | (setq todo-items (substring todo-items 0 -1)))) | ||
| 5179 | (if (todos-done-item-p) | ||
| 5180 | (setq done 1) | ||
| 5181 | (setq todo 1) | ||
| 5182 | (when (todos-diary-item-p) (setq diary 1)))) | ||
| 5165 | (set-window-buffer (selected-window) | 5183 | (set-window-buffer (selected-window) |
| 5166 | (set-buffer (find-file-noselect file2 'nowarn))) | 5184 | (set-buffer (find-file-noselect file2 'nowarn))) |
| 5167 | (unwind-protect | 5185 | (unwind-protect |
| 5168 | (progn | 5186 | (progn |
| 5169 | (todos-set-item-priority item cat2 t) | 5187 | (when (or todo-items (and item (not done-item))) |
| 5188 | (todos-set-item-priority (or todo-items item) cat2 t)) | ||
| 5189 | ;; Move done items en bloc to end of done item section. | ||
| 5190 | (when (or done-items done-item) | ||
| 5191 | (todos-category-number cat2) | ||
| 5192 | (widen) | ||
| 5193 | (goto-char (point-min)) | ||
| 5194 | (re-search-forward (concat "^" (regexp-quote | ||
| 5195 | (concat todos-category-beg cat2)) | ||
| 5196 | "$") | ||
| 5197 | nil t) | ||
| 5198 | (goto-char (if (re-search-forward | ||
| 5199 | (concat "^" (regexp-quote todos-category-beg)) | ||
| 5200 | nil t) | ||
| 5201 | (match-beginning 0) | ||
| 5202 | (point-max))) | ||
| 5203 | (insert (or done-items done-item))) | ||
| 5170 | (setq moved t)) | 5204 | (setq moved t)) |
| 5171 | (cond | 5205 | (cond |
| 5172 | ;; Move succeeded, so remove item from starting category, | 5206 | ;; Move succeeded, so remove item from starting category, |
| @@ -5174,8 +5208,9 @@ entry/entries in that category." | |||
| 5174 | ;; the moved item. | 5208 | ;; the moved item. |
| 5175 | (moved | 5209 | (moved |
| 5176 | (setq nmark (point-marker)) | 5210 | (setq nmark (point-marker)) |
| 5177 | (todos-update-count 'todo count) | 5211 | (when todo (todos-update-count 'todo todo)) |
| 5178 | (todos-update-count 'diary count-diary) | 5212 | (when diary (todos-update-count 'diary diary)) |
| 5213 | (when done (todos-update-count 'done done)) | ||
| 5179 | (todos-update-categories-sexp) | 5214 | (todos-update-categories-sexp) |
| 5180 | (with-current-buffer (find-buffer-visiting file1) | 5215 | (with-current-buffer (find-buffer-visiting file1) |
| 5181 | (save-excursion | 5216 | (save-excursion |
| @@ -5189,9 +5224,11 @@ entry/entries in that category." | |||
| 5189 | (concat "^" (regexp-quote todos-category-beg)) nil t) | 5224 | (concat "^" (regexp-quote todos-category-beg)) nil t) |
| 5190 | (forward-line) | 5225 | (forward-line) |
| 5191 | (setq beg (point)) | 5226 | (setq beg (point)) |
| 5192 | (re-search-forward | 5227 | (setq end (if (re-search-forward |
| 5193 | (concat "^" (regexp-quote todos-category-done)) nil t) | 5228 | (concat "^" (regexp-quote |
| 5194 | (setq end (match-beginning 0)) | 5229 | todos-category-beg)) nil t) |
| 5230 | (match-beginning 0) | ||
| 5231 | (point-max))) | ||
| 5195 | (goto-char beg) | 5232 | (goto-char beg) |
| 5196 | (while (< (point) end) | 5233 | (while (< (point) end) |
| 5197 | (if (todos-marked-item-p) | 5234 | (if (todos-marked-item-p) |
| @@ -5204,18 +5241,21 @@ entry/entries in that category." | |||
| 5204 | (assq-delete-all cat1 todos-categories-with-marks))) | 5241 | (assq-delete-all cat1 todos-categories-with-marks))) |
| 5205 | (if ov (delete-overlay ov)) | 5242 | (if ov (delete-overlay ov)) |
| 5206 | (todos-remove-item)))) | 5243 | (todos-remove-item)))) |
| 5207 | (todos-update-count 'todo (- count) cat1) | 5244 | (when todo (todos-update-count 'todo (- todo) cat1)) |
| 5208 | (todos-update-count 'diary (- count-diary) cat1) | 5245 | (when diary (todos-update-count 'diary (- diary) cat1)) |
| 5246 | (when done (todos-update-count 'done (- done) cat1)) | ||
| 5209 | (todos-update-categories-sexp)) | 5247 | (todos-update-categories-sexp)) |
| 5210 | (set-window-buffer (selected-window) | 5248 | (set-window-buffer (selected-window) |
| 5211 | (set-buffer (find-file-noselect file2 'nowarn))) | 5249 | (set-buffer (find-file-noselect file2 'nowarn))) |
| 5212 | (setq todos-category-number (todos-category-number cat2)) | 5250 | (setq todos-category-number (todos-category-number cat2)) |
| 5213 | (todos-category-select) | 5251 | (let ((todos-show-with-done (or done-items done-item))) |
| 5252 | (todos-category-select)) | ||
| 5214 | (goto-char nmark) | 5253 | (goto-char nmark) |
| 5215 | ;; If item is moved to end of category, make sure the | 5254 | ;; If item is moved to end of category, make sure the |
| 5216 | ;; items above it are displayed in the window. | 5255 | ;; items above it are displayed in the window. |
| 5217 | (recenter)) | 5256 | (recenter)) |
| 5218 | ;; User quit before moving, so return to starting category. | 5257 | ;; User quit before setting priority of todo item(s), so |
| 5258 | ;; return to starting category. | ||
| 5219 | (t | 5259 | (t |
| 5220 | (todos-category-number cat1) | 5260 | (todos-category-number cat1) |
| 5221 | (todos-category-select) | 5261 | (todos-category-select) |