diff options
| author | Stephen Berman <stephen.berman@gmx.net> | 2014-07-06 22:28:38 +0200 |
|---|---|---|
| committer | Stephen Berman <stephen.berman@gmx.net> | 2014-07-06 22:28:38 +0200 |
| commit | 41cd2704e2972a1aac00aa5d538d2f66c5f6f664 (patch) | |
| tree | ef5cbc33b39f21b64a59ed8190781970378657eb /lisp | |
| parent | b16a9348e471253f67ad4520f013184404c008a1 (diff) | |
| download | emacs-41cd2704e2972a1aac00aa5d538d2f66c5f6f664.tar.gz | |
* calendar/todo-mode.el: Fix wrong-type-argument error when
marking multiple consecutive items.
(todo-toggle-mark-item): Don't try to mark the empty lines at the
end of the todo and done items sections. Note in doc string that
items marked by passing a numeric prefix argument can include the
last todo and first done items.
(todo-mark-category): Don't try to mark the empty line between the
todo and done items sections.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/calendar/todo-mode.el | 60 |
2 files changed, 48 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 388adea5627..d97faa780c2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2014-07-06 Stephen Berman <stephen.berman@gmx.net> + + * calendar/todo-mode.el: Fix wrong-type-argument error when + marking multiple consecutive items. + (todo-toggle-mark-item): Don't try to mark the empty lines at the + end of the todo and done items sections. Note in doc string that + items marked by passing a numeric prefix argument can include the + last todo and first done items. + (todo-mark-category): Don't try to mark the empty line between the + todo and done items sections. + 2014-07-05 Stefan Monnier <monnier@iro.umontreal.ca> * emacs-lisp/edebug.el (edebug-eval-defun): Print result using diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index a1da75c20e8..d8bca81ed9b 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -1710,31 +1710,40 @@ means prompt user and omit comment only on confirmation." (defun todo-toggle-mark-item (&optional n) "Mark item with `todo-item-mark' if unmarked, otherwise unmark it. -With a positive numerical prefix argument N, change the -marking of the next N items." +With positive numerical prefix argument N, change the marking of +the next N items in the current category. If both the todo and +done items sections are visible, the sequence of N items can +consist of the the last todo items and the first done items." (interactive "p") (when (todo-item-string) (unless (> n 1) (setq n 1)) - (dotimes (i n) - (let* ((cat (todo-current-category)) - (marks (assoc cat todo-categories-with-marks)) - (ov (progn - (unless (looking-at todo-item-start) - (todo-item-start)) - (todo-get-overlay 'prefix))) - (pref (overlay-get ov 'before-string))) - (if (todo-marked-item-p) - (progn - (overlay-put ov 'before-string (substring pref 1)) - (if (= (cdr marks) 1) ; Deleted last mark in this category. - (setq todo-categories-with-marks - (assq-delete-all cat todo-categories-with-marks)) - (setcdr marks (1- (cdr marks))))) - (overlay-put ov 'before-string (concat todo-item-mark pref)) - (if marks - (setcdr marks (1+ (cdr marks))) - (push (cons cat 1) todo-categories-with-marks)))) - (todo-forward-item)))) + (catch 'end + (dotimes (i n) + (let* ((cat (todo-current-category)) + (marks (assoc cat todo-categories-with-marks)) + (ov (progn + (unless (looking-at todo-item-start) + (todo-item-start)) + (todo-get-overlay 'prefix))) + (pref (overlay-get ov 'before-string))) + (if (todo-marked-item-p) + (progn + (overlay-put ov 'before-string (substring pref 1)) + (if (= (cdr marks) 1) ; Deleted last mark in this category. + (setq todo-categories-with-marks + (assq-delete-all cat todo-categories-with-marks)) + (setcdr marks (1- (cdr marks))))) + (overlay-put ov 'before-string (concat todo-item-mark pref)) + (if marks + (setcdr marks (1+ (cdr marks))) + (push (cons cat 1) todo-categories-with-marks)))) + (todo-forward-item) + ;; Don't try to mark the empty lines at the end of the todo + ;; and done items sections. + (when (looking-at "^$") + (if (eobp) + (throw 'end nil) + (todo-forward-item))))))) (defun todo-mark-category () "Mark all visible items in this category with `todo-item-mark'." @@ -1751,7 +1760,12 @@ marking of the next N items." (if marks (setcdr marks (1+ (cdr marks))) (push (cons cat 1) todo-categories-with-marks)))) - (todo-forward-item))))) + (todo-forward-item) + ;; Don't try to mark the empty line between the todo and done + ;; items sections. + (when (looking-at "^$") + (unless (eobp) + (todo-forward-item))))))) (defun todo-unmark-category () "Remove `todo-item-mark' from all visible items in this category." |
