Function: rst-insert-list-new-item

rst-insert-list-new-item is a byte-compiled function defined in rst.el.gz.

Signature

(rst-insert-list-new-item)

Documentation

Insert a new list item.

User is asked to select the item style first, for example (a), i), +. Use TAB for completion and choices.

If user selects bullets or #, it's just added with position arranged by rst-insert-list-new-tag.

If user selects enumerations, a further prompt is given. User need to input a starting item, for example 'e' for 'A)' style. The position is also arranged by rst-insert-list-new-tag.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-insert-list-new-item ()
  ;; testcover: ok.
  "Insert a new list item.

User is asked to select the item style first, for example (a), i), +.
Use TAB for completion and choices.

If user selects bullets or #, it's just added with position arranged by
`rst-insert-list-new-tag'.

If user selects enumerations, a further prompt is given.  User need to
input a starting item, for example 'e' for 'A)' style.  The position is
also arranged by `rst-insert-list-new-tag'."
  (let* ((itemstyle (completing-read
		     (format-prompt "Select preferred item style" "#.")
		     rst-initial-items nil t nil nil "#."))
	 (cnt (if (string-match (rst-re 'cntexp-tag) itemstyle)
		  (match-string 0 itemstyle)))
	 (no
	  (save-match-data
	    (cond
	     ((equal cnt "a")
	      (let ((itemno (read-string
                             (format-prompt "Give starting value" "a")
			     nil nil "a")))
		(downcase (substring itemno 0 1))))
	     ((equal cnt "A")
	      (let ((itemno (read-string
                             (format-prompt "Give starting value" "A")
			     nil nil "A")))
		(upcase (substring itemno 0 1))))
	     ((equal cnt "I")
	      (let ((itemno (read-number "Give starting value: " 1)))
		(rst-arabic-to-roman itemno)))
	     ((equal cnt "i")
	      (let ((itemno (read-number "Give starting value: " 1)))
		(downcase (rst-arabic-to-roman itemno))))
	     ((equal cnt "1")
	      (let ((itemno (read-number "Give starting value: " 1)))
		(number-to-string itemno)))))))
    (if no
	(setq itemstyle (replace-match no t t itemstyle)))
    (rst-insert-list-new-tag itemstyle)))