Function: todo-add-item-non-interactively

todo-add-item-non-interactively is a byte-compiled function defined in otodo-mode.el.gz.

Signature

(todo-add-item-non-interactively NEW-ITEM CATEGORY)

Documentation

Insert NEW-ITEM in TODO list as a new entry in CATEGORY.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/otodo-mode.el.gz
;;;###autoload
(defun todo-add-item-non-interactively (new-item category)
  "Insert NEW-ITEM in TODO list as a new entry in CATEGORY."
  (save-excursion
    (todo-show))
  (save-excursion
    (if (string= "" category)
        (setq category (nth todo-category-number todo-categories)))
    (let ((cat-exists (member category todo-categories)))
      (setq todo-category-number
            (if cat-exists
                (- (length todo-categories) (length cat-exists))
              (todo-add-category category))))
    (todo-show)
    (setq todo-previous-line 0)
    (let ((top 1)
	  (bottom (1+ (count-lines (point-min) (point-max)))))
      (while (> (- bottom top) todo-insert-threshold)
	(let* ((current (/ (+ top bottom) 2))
	       (answer (if (< current bottom)
			   (todo-more-important-p current) nil)))
	  (if answer
	      (setq bottom current)
	    (setq top (1+ current)))))
      (setq top (/ (+ top bottom) 2))
      ;; goto-line doesn't have the desired behavior in a narrowed buffer.
      (goto-char (point-min))
      (forward-line (1- top)))
    (insert new-item "\n")
    (todo-backward-item)
    (todo-save)
    (message "")))