Function: todo-delete-item
todo-delete-item is an interactive and byte-compiled function defined
in todo-mode.el.gz.
Signature
(todo-delete-item)
Documentation
Delete at least one item in this category.
If there are marked items, delete all of these; otherwise, delete the item at point.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-delete-item ()
"Delete at least one item in this category.
If there are marked items, delete all of these; otherwise, delete
the item at point."
(interactive)
(let (ov)
(unwind-protect
(let* ((cat (todo-current-category))
(marked (assoc cat todo-categories-with-marks))
(item (unless marked (todo-item-string)))
(answer (if marked
(todo-y-or-n-p
"Permanently delete all marked items? ")
(when item
(setq ov (make-overlay
(save-excursion (todo-item-start))
(save-excursion (todo-item-end))))
(overlay-put ov 'face 'todo-search)
(todo-y-or-n-p "Permanently delete this item? "))))
(inhibit-read-only t))
(when answer
(and marked (goto-char (point-min)))
(catch 'done
(while (not (eobp))
(if (or (and marked (todo-marked-item-p)) item)
(progn
(if (todo-done-item-p)
(todo-update-count 'done -1)
(todo-update-count 'todo -1 cat)
(and (todo-diary-item-p)
(todo-update-count 'diary -1)))
(if ov (delete-overlay ov))
(todo-remove-item)
;; Don't leave point below last item.
(and item (bolp) (eolp) (< (point-min) (point-max))
(todo-backward-item))
(when item
(throw 'done (setq item nil))))
(todo-forward-item))))
(when marked
(setq todo-categories-with-marks
(assq-delete-all cat todo-categories-with-marks)))
(todo-update-categories-sexp)
(todo-prefix-overlays)
(when (and (zerop (todo-get-count 'diary))
(save-excursion
(goto-char (point-min))
(re-search-forward
(concat "^" (regexp-quote todo-category-done))
nil t)))
(let (todo-show-with-done) (todo-category-select)))))
(if ov (delete-overlay ov)))))