Function: org-insert-item

org-insert-item is an interactive and byte-compiled function defined in org-list.el.gz.

Signature

(org-insert-item &optional CHECKBOX)

Documentation

Insert a new item at the current level.

If cursor is before first character after bullet of the item, the new item will be created before the current one.

If CHECKBOX is non-nil, add a checkbox next to the bullet.

Return t when things worked, nil when we are not in an item, or item is invisible.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-list.el.gz
(defun org-insert-item (&optional checkbox)
  "Insert a new item at the current level.
If cursor is before first character after bullet of the item, the
new item will be created before the current one.

If CHECKBOX is non-nil, add a checkbox next to the bullet.

Return t when things worked, nil when we are not in an item, or
item is invisible."
  (interactive "P")
  (let ((itemp (org-in-item-p))
	(pos (point)))
    ;; If cursor isn't is a list or if list is invisible, return nil.
    (unless (or (not itemp)
		(save-excursion
		  (goto-char itemp)
		  (org-invisible-p)))
      (if (save-excursion
	    (goto-char itemp)
	    (org-at-item-timer-p))
	  ;; Timer list: delegate to `org-timer-item'.
	  (progn (org-timer-item) t)
	(let* ((struct (save-excursion (goto-char itemp)
				       (org-list-struct)))
	       (prevs (org-list-prevs-alist struct))
	       ;; If we're in a description list, ask for the new term.
	       (desc (when (eq (org-list-get-list-type itemp struct prevs)
			       'descriptive)
		       " :: ")))
	  (setq struct (org-list-insert-item pos struct prevs checkbox desc))
	  (org-list-write-struct struct (org-list-parents-alist struct))
	  (when checkbox (org-update-checkbox-count-maybe))
          (forward-line 0)
	  (looking-at org-list-full-item-re)
	  (goto-char (if (and (match-beginning 4)
			      (save-match-data
				(string-match "[.)]" (match-string 1))))
			 (match-beginning 4)
		       (match-end 0)))
	  (when desc (backward-char 1))
	  t)))))