Function: todo-insert-with-overlays

todo-insert-with-overlays is a byte-compiled function defined in todo-mode.el.gz.

Signature

(todo-insert-with-overlays ITEM)

Documentation

Insert ITEM at point and update prefix and header overlays.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-insert-with-overlays (item)
  "Insert ITEM at point and update prefix and header overlays."
  (todo-item-start)
  (let ((ov (todo-get-overlay 'prefix))
	(marked (todo-marked-item-p)))
    (insert item "\n")
    ;; Insertion pushes item down but not its prefix overlay.  When
    ;; the overlay includes a mark, this would now mark the inserted
    ;; ITEM, so move it to the pushed down item.
    (when marked (move-overlay ov (point) (point)))
    (todo-backward-item)
    ;; With hidden headers, todo-backward-item puts point on first
    ;; visible character after header, so we have to search backward.
    (when todo--item-headers-hidden
      (re-search-backward (concat todo-item-start
                                 "\\( " diary-time-regexp "\\)?"
                                 (regexp-quote todo-nondiary-end) "? ")
                         nil t)
              (setq ov (make-overlay (match-beginning 0) (match-end 0) nil t))
              (overlay-put ov 'todo 'header)
              (overlay-put ov 'display "")))
  (todo-prefix-overlays))