aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2013-03-15 13:04:16 +0100
committerStephen Berman2013-03-15 13:04:16 +0100
commit2cb953327c29bb1c168565a87906e28d87b82e48 (patch)
tree8643902677d7b69de8c3ade5221b35a55ffcc88f
parentaa91082d36437059223f0bf9aaefb45ff34a4e8c (diff)
downloademacs-2cb953327c29bb1c168565a87906e28d87b82e48.tar.gz
emacs-2cb953327c29bb1c168565a87906e28d87b82e48.zip
* calendar/todos.el (todos-reset-prefix): Don't remove overlays,
since it's superfluous and also wrongly removes items marks. (todos-category-completions): Select current category on visiting file, to ensure category is properly displayed if user switches to file via a non-Todos command. (todos-mark-category): Make implementation cleaner. (todos-unmark-category): Improve implementation. Get overlay property only when there is an overlay.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/calendar/todos.el72
2 files changed, 47 insertions, 36 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c1ea8b81e30..fe66ff93267 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12013-03-15 Stephen Berman <stephen.berman@gmx.net>
2
3 * calendar/todos.el (todos-reset-prefix): Don't remove overlays,
4 since it's superfluous and also wrongly removes items marks.
5 (todos-category-completions): Select current category on visiting
6 file, to ensure category is properly displayed if user switches to
7 file via a non-Todos command.
8 (todos-mark-category): Make implementation cleaner.
9 (todos-unmark-category): Improve implementation. Get overlay
10 property only when there is an overlay.
11
12013-03-14 Stephen Berman <stephen.berman@gmx.net> 122013-03-14 Stephen Berman <stephen.berman@gmx.net>
2 13
3 * calendar/todos.el (todos-insert-item): Fix last change to make 14 * calendar/todos.el (todos-insert-item): Fix last change to make
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index aab5b1ac12a..b3e867d4b63 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -217,7 +217,6 @@ These reflect the priorities of the items in each category."
217 (when (not (equal value oldvalue)) 217 (when (not (equal value oldvalue))
218 (dolist (f files) 218 (dolist (f files)
219 (with-current-buffer (find-file-noselect f) 219 (with-current-buffer (find-file-noselect f)
220 (remove-overlays 1 (1+ (buffer-size)) 'todos 'prefix)
221 ;; Activate the new setting in the current category. 220 ;; Activate the new setting in the current category.
222 (save-excursion (todos-category-select))))))) 221 (save-excursion (todos-category-select)))))))
223 222
@@ -1209,6 +1208,9 @@ Todos files named in `todos-category-completions-files'."
1209 (add-to-list 'files curfile) 1208 (add-to-list 'files curfile)
1210 (dolist (f files listall) 1209 (dolist (f files listall)
1211 (with-current-buffer (find-file-noselect f 'nowarn) 1210 (with-current-buffer (find-file-noselect f 'nowarn)
1211 ;; Ensure category is properly displayed in case user
1212 ;; switches to file via a non-Todos command.
1213 (todos-category-select)
1212 (save-excursion 1214 (save-excursion
1213 (save-restriction 1215 (save-restriction
1214 (widen) 1216 (widen)
@@ -3820,37 +3822,35 @@ marking of the next N items."
3820(defun todos-mark-category () 3822(defun todos-mark-category ()
3821 "Mark all visiblw items in this category with `todos-item-mark'." 3823 "Mark all visiblw items in this category with `todos-item-mark'."
3822 (interactive) 3824 (interactive)
3823 (save-excursion 3825 (let* ((cat (todos-current-category))
3824 (goto-char (point-min)) 3826 (marks (assoc cat todos-categories-with-marks)))
3825 (while (not (eobp)) 3827 (save-excursion
3826 (let* ((cat (todos-current-category)) 3828 (goto-char (point-min))
3827 (marks (assoc cat todos-categories-with-marks)) 3829 (while (not (eobp))
3828 (ov (todos-get-overlay 'prefix)) 3830 (let* ((ov (todos-get-overlay 'prefix))
3829 (pref (overlay-get ov 'before-string))) 3831 (pref (overlay-get ov 'before-string)))
3830 (unless (todos-marked-item-p) 3832 (unless (todos-marked-item-p)
3831 (overlay-put ov 'before-string (concat todos-item-mark pref)) 3833 (overlay-put ov 'before-string (concat todos-item-mark pref))
3832 (if marks 3834 (if marks
3833 (setcdr marks (1+ (cdr marks))) 3835 (setcdr marks (1+ (cdr marks)))
3834 (push (cons cat 1) todos-categories-with-marks)))) 3836 (push (cons cat 1) todos-categories-with-marks))))
3835 (todos-forward-item)))) 3837 (todos-forward-item)))))
3836 3838
3837(defun todos-unmark-category () 3839(defun todos-unmark-category ()
3838 "Remove `todos-item-mark' from all visible items in this category." 3840 "Remove `todos-item-mark' from all visible items in this category."
3839 (interactive) 3841 (interactive)
3840 (save-excursion 3842 (let* ((cat (todos-current-category))
3841 (goto-char (point-min)) 3843 (marks (assoc cat todos-categories-with-marks)))
3842 (while (not (eobp)) 3844 (save-excursion
3843 (let* ((cat (todos-current-category)) 3845 (goto-char (point-min))
3844 (marks (assoc cat todos-categories-with-marks)) 3846 (while (not (eobp))
3845 (ov (todos-get-overlay 'prefix)) 3847 (let* ((ov (todos-get-overlay 'prefix))
3846 (pref (overlay-get ov 'before-string))) 3848 ;; No overlay on empty line between todo and done items.
3847 (when (todos-marked-item-p) 3849 (pref (when ov (overlay-get ov 'before-string))))
3848 (overlay-put ov 'before-string (substring pref 1)) 3850 (when (todos-marked-item-p)
3849 (setq todos-categories-with-marks 3851 (overlay-put ov 'before-string (substring pref 1)))
3850 (delq (assoc (todos-current-category) 3852 (todos-forward-item))))
3851 todos-categories-with-marks) 3853 (setq todos-categories-with-marks (delq marks todos-categories-with-marks))))
3852 todos-categories-with-marks))))
3853 (todos-forward-item))))
3854 3854
3855;; --------------------------------------------------------------------------- 3855;; ---------------------------------------------------------------------------
3856;;; Item filtering commands 3856;;; Item filtering commands
@@ -4688,14 +4688,14 @@ the priority is not given by HERE but by prompting."
4688 (and done-only (todos-show-done-only))) 4688 (and done-only (todos-show-done-only)))
4689 (set-window-buffer (selected-window) (set-buffer obuf))) 4689 (set-window-buffer (selected-window) (set-buffer obuf)))
4690 (goto-char opoint)) 4690 (goto-char opoint))
4691 ;; If todos section is not visible when insertion 4691 ;; If the todo items section is not visible when the
4692 ;; command is called (either because only done items 4692 ;; insertion command is called (either because only done
4693 ;; were shown or because category was not in current 4693 ;; items were shown or because the category was not in the
4694 ;; buffer), then if item is inserted at end of category, 4694 ;; current buffer), then if the item is inserted at the
4695 ;; point is at eob and eob at window-start, so that that 4695 ;; end of the category, point is at eob and eob at
4696 ;; higher priority todo items are out of view. So we 4696 ;; window-start, so that higher priority todo items are
4697 ;; recenter to make sure the todo items are displayed in 4697 ;; out of view. So we recenter to make sure the todo
4698 ;; the window. 4698 ;; items are displayed in the window.
4699 (when item-added (recenter))) 4699 (when item-added (recenter)))
4700 (todos-update-count 'todo 1) 4700 (todos-update-count 'todo 1)
4701 (if (or diary todos-include-in-diary) (todos-update-count 'diary 1)) 4701 (if (or diary todos-include-in-diary) (todos-update-count 'diary 1))