Function: todo-toggle-mark-item

todo-toggle-mark-item is an interactive and byte-compiled function defined in todo-mode.el.gz.

Signature

(todo-toggle-mark-item &optional N)

Documentation

Mark item with todo-item-mark if unmarked, otherwise unmark it.

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 last todo items and the first done items.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-toggle-mark-item (&optional n)
  "Mark item with `todo-item-mark' if unmarked, otherwise unmark it.
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 last todo items and the first done items."
  (interactive "p")
  (when (todo-item-string)
    (let ((cat (todo-current-category)))
      (unless (> n 1) (setq n 1))
      (catch 'end
        (dotimes (_ n)
          (let* ((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))))))))