aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2012-06-25 00:53:02 +0100
committerStephen Berman2012-06-25 00:53:02 +0100
commit3160f2eb373462baf6bb2c224c74e83a9b37c537 (patch)
tree6c5e32e1f315c75654b6b1458a3ac5d99ff7f1c1
parent18aef8a33ebd85749b89dc6f9ecec09bc19cae01 (diff)
downloademacs-3160f2eb373462baf6bb2c224c74e83a9b37c537.tar.gz
emacs-3160f2eb373462baf6bb2c224c74e83a9b37c537.zip
* calendar/todos.el (todos-item-undo): Fix restoration on
cancelling; use buffer-substring-no-properties; comment out code removing mark overlay; fix insertion of undone items; display any remaining done items.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/calendar/todos.el34
2 files changed, 27 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fff7be6e20b..e2a7037e1a6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12012-09-23 Stephen Berman <stephen.berman@gmx.net> 12012-09-23 Stephen Berman <stephen.berman@gmx.net>
2 2
3 * calendar/todos.el (todos-item-undo): Fix restoration on
4 cancelling; use buffer-substring-no-properties; comment out code
5 removing mark overlay; fix insertion of undone items; display any
6 remaining done items.
7
82012-09-23 Stephen Berman <stephen.berman@gmx.net>
9
3 * calendar/todos.el: Further significant code rearrangement; 10 * calendar/todos.el: Further significant code rearrangement;
4 further comment revision. 11 further comment revision.
5 (todos-mode-display): New defgroup. 12 (todos-mode-display): New defgroup.
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index e5b9996d9b4..2d0dfdb10a8 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -4833,7 +4833,6 @@ With prefix ARG delete an existing comment."
4833 (todos-item-end) 4833 (todos-item-end)
4834 (insert " [" todos-comment-string ": " comment "]")))))) 4834 (insert " [" todos-comment-string ": " comment "]"))))))
4835 4835
4836;; FIXME: also with marked items
4837(defun todos-item-undo () 4836(defun todos-item-undo ()
4838 "Restore this done item to the todo section of this category. 4837 "Restore this done item to the todo section of this category.
4839If done item has a comment, ask whether to omit the comment from 4838If done item has a comment, ask whether to omit the comment from
@@ -4843,9 +4842,10 @@ the restored item."
4843 (marked (assoc cat todos-categories-with-marks))) 4842 (marked (assoc cat todos-categories-with-marks)))
4844 (when (or marked (todos-done-item-p)) 4843 (when (or marked (todos-done-item-p))
4845 (let ((buffer-read-only) 4844 (let ((buffer-read-only)
4846 (done-item (todos-item-string)) 4845 (bufmod (buffer-modified-p))
4847 (opoint (point)) 4846 (opoint (point))
4848 (orig-mrk (progn (todos-item-start) (point-marker))) 4847 (orig-mrk (progn (todos-item-start) (point-marker)))
4848 (orig-item (todos-item-string))
4849 (first 'first) 4849 (first 'first)
4850 (item-count 0) 4850 (item-count 0)
4851 (diary-count 0) 4851 (diary-count 0)
@@ -4878,19 +4878,20 @@ the restored item."
4878 (when (eq first 'omit) 4878 (when (eq first 'omit)
4879 (delete-region (match-beginning 0) (match-end 0)) 4879 (delete-region (match-beginning 0) (match-end 0))
4880 (setq end (point)))) 4880 (setq end (point))))
4881 (setq item (concat item (buffer-substring start end) 4881 (setq item (concat item
4882 (buffer-substring-no-properties start end)
4882 (when marked "\n"))) 4883 (when marked "\n")))
4883 (todos-remove-item) 4884 (todos-remove-item)
4884 (unless marked (throw 'done nil))) 4885 (unless marked (throw 'done nil)))
4885 (todos-forward-item)))) 4886 (todos-forward-item))))
4886 (if marked 4887 (if marked
4887 (progn 4888 (progn
4888 (remove-overlays (point-min) (point-max) 4889 ;; (remove-overlays (point-min) (point-max)
4889 'before-string todos-item-mark) 4890 ;; 'before-string todos-item-mark)
4890 (setq todos-categories-with-marks 4891 (setq todos-categories-with-marks
4891 (assq-delete-all cat todos-categories-with-marks)) 4892 (assq-delete-all cat todos-categories-with-marks))
4892 ;; Insert undone items that were marked at end of todo item list. 4893 ;; Insert undone items that were marked at end of todo item list.
4893 (widen) 4894 (goto-char (point-min))
4894 (re-search-forward (concat "^" (regexp-quote todos-category-done)) 4895 (re-search-forward (concat "^" (regexp-quote todos-category-done))
4895 nil t) 4896 nil t)
4896 (forward-line -1) 4897 (forward-line -1)
@@ -4898,7 +4899,9 @@ the restored item."
4898 (todos-update-count 'todo item-count) 4899 (todos-update-count 'todo item-count)
4899 (todos-update-count 'done (- item-count)) 4900 (todos-update-count 'done (- item-count))
4900 (when diary-count (todos-update-count 'diary diary-count)) 4901 (when diary-count (todos-update-count 'diary diary-count))
4901 (todos-update-categories-sexp)) 4902 (todos-update-categories-sexp)
4903 (let ((todos-show-with-done (> (todos-get-count 'done) 0)))
4904 (todos-category-select)))
4902 ;; With an unmarked undone item, prompt for its priority. If user 4905 ;; With an unmarked undone item, prompt for its priority. If user
4903 ;; cancels before setting new priority, then leave the done item 4906 ;; cancels before setting new priority, then leave the done item
4904 ;; unchanged. 4907 ;; unchanged.
@@ -4909,15 +4912,18 @@ the restored item."
4909 (todos-update-count 'todo 1) 4912 (todos-update-count 'todo 1)
4910 (todos-update-count 'done -1) 4913 (todos-update-count 'done -1)
4911 (and (todos-diary-item-p) (todos-update-count 'diary 1)) 4914 (and (todos-diary-item-p) (todos-update-count 'diary 1))
4912 (todos-update-categories-sexp)) 4915 (todos-update-categories-sexp)
4916 (let ((todos-show-with-done (> (todos-get-count 'done) 0)))
4917 (todos-category-select)))
4913 (unless undone 4918 (unless undone
4914 (widen)
4915 (goto-char orig-mrk)
4916 (todos-insert-with-overlays done-item)
4917 (let ((todos-show-with-done t)) 4919 (let ((todos-show-with-done t))
4918 (todos-category-select) 4920 (widen)
4919 (goto-char opoint))) 4921 (goto-char orig-mrk)
4920 (set-marker orig-mrk nil))))))) 4922 (todos-insert-with-overlays orig-item)
4923 (set-buffer-modified-p bufmod)
4924 (todos-category-select))
4925 (goto-char opoint))))
4926 (set-marker orig-mrk nil)))))
4921 4927
4922(defun todos-archive-done-item (&optional all) 4928(defun todos-archive-done-item (&optional all)
4923 "Archive at least one done item in this category. 4929 "Archive at least one done item in this category.