aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/calendar/todos.el117
2 files changed, 74 insertions, 55 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a9412b3e6ed..c1ea8b81e30 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12013-03-14 Stephen Berman <stephen.berman@gmx.net>
2
3 * calendar/todos.el (todos-insert-item): Fix last change to make
4 sure calling insertion "here" from outside goal todo items section
5 gives new item top priority. With priority insertion, if user
6 cancels before setting priority, restore display.
7 (todos-find-item): Restore narrowing after searching.
8 (todos-item-done): Allow adding (same) comment to marked items.
9 Don't add empty comment to done item.
10
12013-03-13 Stephen Berman <stephen.berman@gmx.net> 112013-03-13 Stephen Berman <stephen.berman@gmx.net>
2 12
3 * calendar/todos.el (todos-quit): If quitting 13 * calendar/todos.el (todos-quit): If quitting
@@ -6,7 +16,7 @@
6 (todos-delete-category): Fix incorrect quotation mark. 16 (todos-delete-category): Fix incorrect quotation mark.
7 (todos-set-item-priority): Make prefix argument a no-op with 17 (todos-set-item-priority): Make prefix argument a no-op with
8 commands for raising or lowering item priority. Move mistakenly 18 commands for raising or lowering item priority. Move mistakenly
9 place right paren to end of defun, where it belongs. 19 placed right paren to end of defun, where it belongs.
10 20
112013-02-25 Stephen Berman <stephen.berman@gmx.net> 212013-02-25 Stephen Berman <stephen.berman@gmx.net>
12 22
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index fc43c8f3faa..aab5b1ac12a 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -2191,41 +2191,43 @@ priority has changed or its text was truncated or augmented, and
2191 todos-global-current-todos-file))) 2191 todos-global-current-todos-file)))
2192 (find-file-noselect file) 2192 (find-file-noselect file)
2193 (with-current-buffer (find-buffer-visiting file) 2193 (with-current-buffer (find-buffer-visiting file)
2194 (widen) 2194 (save-restriction
2195 (goto-char (point-min)) 2195 (widen)
2196 (let ((beg (re-search-forward 2196 (goto-char (point-min))
2197 (concat "^" (regexp-quote (concat todos-category-beg cat)) "$") 2197 (let ((beg (re-search-forward
2198 nil t)) 2198 (concat "^" (regexp-quote (concat todos-category-beg cat))
2199 (done (save-excursion 2199 "$")
2200 (re-search-forward 2200 nil t))
2201 (concat "^" (regexp-quote todos-category-done)) nil t))) 2201 (done (save-excursion
2202 (end (save-excursion 2202 (re-search-forward
2203 (or (re-search-forward 2203 (concat "^" (regexp-quote todos-category-done)) nil t)))
2204 (concat "^" (regexp-quote todos-category-beg)) 2204 (end (save-excursion
2205 nil t) 2205 (or (re-search-forward
2206 (point-max))))) 2206 (concat "^" (regexp-quote todos-category-beg))
2207 (setq found (when (search-forward str end t) 2207 nil t)
2208 (goto-char (match-beginning 0)))) 2208 (point-max)))))
2209 (when found 2209 (setq found (when (search-forward str end t)
2210 (setq found 2210 (goto-char (match-beginning 0))))
2211 (cons found (if (> (point) done) 2211 (when found
2212 'done 2212 (setq found
2213 (let ((cpriority 1)) 2213 (cons found (if (> (point) done)
2214 (save-excursion 2214 'done
2215 ;; Not top item in category. 2215 (let ((cpriority 1))
2216 (while (> (point) (1+ beg)) 2216 (save-excursion
2217 (let ((opoint (point))) 2217 ;; Not top item in category.
2218 (todos-backward-item) 2218 (while (> (point) (1+ beg))
2219 ;; Can't move backward beyond 2219 (let ((opoint (point)))
2220 ;; first item in file. 2220 (todos-backward-item)
2221 (unless (= (point) opoint) 2221 ;; Can't move backward beyond
2222 (setq cpriority (1+ cpriority)))))) 2222 ;; first item in file.
2223 (if (and (= tpriority cpriority) 2223 (unless (= (point) opoint)
2224 ;; Proper substring is not the same. 2224 (setq cpriority (1+ cpriority))))))
2225 (string= (todos-item-string) 2225 (if (and (= tpriority cpriority)
2226 str)) 2226 ;; Proper substring is not the same.
2227 'same 2227 (string= (todos-item-string)
2228 'changed)))))))) 2228 str))
2229 'same
2230 'changed)))))))))
2229 (list found file cat))) 2231 (list found file cat)))
2230 2232
2231(defun todos-check-top-priorities () 2233(defun todos-check-top-priorities ()
@@ -4580,8 +4582,9 @@ the priority is not given by HERE but by prompting."
4580 (let (use-empty-active-region) 4582 (let (use-empty-active-region)
4581 (unless (and todos-use-only-highlighted-region (use-region-p)) 4583 (unless (and todos-use-only-highlighted-region (use-region-p))
4582 (error "There is no active region")))) 4584 (error "There is no active region"))))
4583 (let* ((buf (current-buffer)) 4585 (let* ((obuf (current-buffer))
4584 (ocat (todos-current-category)) 4586 (ocat (todos-current-category))
4587 (opoint (point))
4585 (todos-mm (eq major-mode 'todos-mode)) 4588 (todos-mm (eq major-mode 'todos-mode))
4586 (cat+file (cond ((equal arg '(4)) 4589 (cat+file (cond ((equal arg '(4))
4587 (todos-read-category "Insert in category: ")) 4590 (todos-read-category "Insert in category: "))
@@ -4631,11 +4634,6 @@ the priority is not given by HERE but by prompting."
4631 (setq todos-current-todos-file file) 4634 (setq todos-current-todos-file file)
4632 (unless todos-global-current-todos-file 4635 (unless todos-global-current-todos-file
4633 (setq todos-global-current-todos-file todos-current-todos-file)) 4636 (setq todos-global-current-todos-file todos-current-todos-file))
4634 ;; When inserting into a file that was not being visited on
4635 ;; invoking this command, point is at bof.
4636 (when (= (point) 1)
4637 (todos-category-number cat)
4638 (todos-category-select))
4639 (let ((buffer-read-only nil) 4637 (let ((buffer-read-only nil)
4640 done-only item-added) 4638 done-only item-added)
4641 (setq new-item 4639 (setq new-item
@@ -4658,7 +4656,7 @@ the priority is not given by HERE but by prompting."
4658 (unwind-protect 4656 (unwind-protect
4659 (progn 4657 (progn
4660 ;; If only done items are displayed in category, 4658 ;; If only done items are displayed in category,
4661 ;; toggle to todo items. 4659 ;; toggle to todo items before inserting new item.
4662 (when (save-excursion 4660 (when (save-excursion
4663 (goto-char (point-min)) 4661 (goto-char (point-min))
4664 (looking-at todos-done-string-start)) 4662 (looking-at todos-done-string-start))
@@ -4666,8 +4664,15 @@ the priority is not given by HERE but by prompting."
4666 (todos-show-done-only)) 4664 (todos-show-done-only))
4667 (if here 4665 (if here
4668 (progn 4666 (progn
4669 (unless (and todos-mm (equal cat ocat) 4667 ;; If command was invoked with point in done
4670 (not (todos-done-item-section-p))) 4668 ;; items section or outside of the current
4669 ;; category, can't insert "here", so to be
4670 ;; useful give new item top priority.
4671 (when (or (todos-done-item-section-p)
4672 (prog1 (not (and todos-mm (equal cat ocat)))
4673 (todos-category-number cat)
4674 (todos-category-select))
4675 done-only)
4671 (goto-char (point-min))) 4676 (goto-char (point-min)))
4672 (todos-insert-with-overlays new-item)) 4677 (todos-insert-with-overlays new-item))
4673 (todos-set-item-priority new-item cat t)) 4678 (todos-set-item-priority new-item cat t))
@@ -4675,7 +4680,14 @@ the priority is not given by HERE but by prompting."
4675 ;; If user cancels before setting priority, restore 4680 ;; If user cancels before setting priority, restore
4676 ;; display. 4681 ;; display.
4677 (unless item-added 4682 (unless item-added
4678 (and done-only (todos-show-done-only))) 4683 (if ocat
4684 (progn
4685 (unless (equal cat ocat)
4686 (todos-category-number ocat)
4687 (todos-category-select))
4688 (and done-only (todos-show-done-only)))
4689 (set-window-buffer (selected-window) (set-buffer obuf)))
4690 (goto-char opoint))
4679 ;; If todos section is not visible when insertion 4691 ;; If todos section is not visible when insertion
4680 ;; command is called (either because only done items 4692 ;; command is called (either because only done items
4681 ;; were shown or because category was not in current 4693 ;; were shown or because category was not in current
@@ -5565,7 +5577,7 @@ visible."
5565 "")) 5577 ""))
5566 (done-prefix (concat "[" todos-done-string date-string time-string 5578 (done-prefix (concat "[" todos-done-string date-string time-string
5567 "] ")) 5579 "] "))
5568 (comment (and arg (not marked) (read-string "Enter a comment: "))) 5580 (comment (and arg (read-string "Enter a comment: ")))
5569 (item-count 0) 5581 (item-count 0)
5570 (diary-count 0) 5582 (diary-count 0)
5571 (show-done (save-excursion 5583 (show-done (save-excursion
@@ -5573,6 +5585,9 @@ visible."
5573 (re-search-forward todos-done-string-start nil t))) 5585 (re-search-forward todos-done-string-start nil t)))
5574 (buffer-read-only nil) 5586 (buffer-read-only nil)
5575 item done-item opoint) 5587 item done-item opoint)
5588 ;; Don't add empty comment to done item.
5589 (setq comment (unless (zerop (length comment))
5590 (concat " [" todos-comment-string ": " comment "]")))
5576 (and marked (goto-char (point-min))) 5591 (and marked (goto-char (point-min)))
5577 (catch 'done 5592 (catch 'done
5578 ;; Stop looping when we hit the empty line below the last 5593 ;; Stop looping when we hit the empty line below the last
@@ -5581,14 +5596,8 @@ visible."
5581 (if (or (not marked) (and marked (todos-marked-item-p))) 5596 (if (or (not marked) (and marked (todos-marked-item-p)))
5582 (progn 5597 (progn
5583 (setq item (todos-item-string)) 5598 (setq item (todos-item-string))
5584 (setq done-item (cond (marked 5599 (setq done-item (concat done-item done-prefix item
5585 (concat done-item done-prefix item "\n")) 5600 comment (and marked "\n")))
5586 (comment
5587 (concat done-prefix item " ["
5588 todos-comment-string
5589 ": " comment "]"))
5590 (t
5591 (concat done-prefix item))))
5592 (setq item-count (1+ item-count)) 5601 (setq item-count (1+ item-count))
5593 (when (todos-diary-item-p) 5602 (when (todos-diary-item-p)
5594 (setq diary-count (1+ diary-count))) 5603 (setq diary-count (1+ diary-count)))