From: Stephen Berman Date: Sun, 6 Jul 2014 20:28:38 +0000 (+0200) Subject: * calendar/todo-mode.el: Fix wrong-type-argument error when X-Git-Tag: emacs-24.3.93~87 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=41cd2704e2972a1aac00aa5d538d2f66c5f6f664;p=emacs.git * 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. --- 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 + + * 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 * 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."