Function: rst-insert-list-continue

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

Signature

(rst-insert-list-continue IND TAG TAB PREFER-ROMAN)

Documentation

Insert a new list tag after the current line according to style.

Style is defined by indentation IND, TAG and suffix TAB. If PREFER-ROMAN roman numbering is preferred over using letters.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-insert-list-continue (ind tag tab prefer-roman)
  ;; testcover: ok.
  "Insert a new list tag after the current line according to style.
Style is defined by indentation IND, TAG and suffix TAB.  If
PREFER-ROMAN roman numbering is preferred over using letters."
  (end-of-line)
  (insert
   ;; FIXME: Separating lines must be possible.
   "\n"
   ind
   (save-match-data
     (if (not (string-match (rst-re 'cntexp-tag) tag))
	 tag
       (let ((pfx (substring tag 0 (match-beginning 0)))
	     (cnt (match-string 0 tag))
	     (sfx (substring tag (match-end 0))))
	 (concat
	  pfx
	  (cond
	   ((string-match (rst-re 'num-tag) cnt)
	    (number-to-string (1+ (string-to-number (match-string 0 cnt)))))
	   ((and
	     (string-match (rst-re 'rom-tag) cnt)
	     (save-match-data
	       (if (string-match (rst-re 'ltr-tag) cnt) ; Also a letter tag.
		   (save-excursion
		     ;; FIXME: Assumes one line list items without separating
		     ;;        empty lines.
		     ;; Use of `rst-forward-line-looking-at' is very difficult
		     ;; here so don't do it.
		     (if (and (rst-forward-line-strict -1)
			      (looking-at (rst-re 'enmexp-beg)))
			 (string-match
			  (rst-re 'rom-tag)
			  (match-string 0)) ; Previous was a roman tag.
		       prefer-roman)) ; Don't know - use flag.
		 t))) ; Not a letter tag.
	    (let* ((old (match-string 0 cnt))
		   (new (rst-arabic-to-roman
			 (1+ (rst-roman-to-arabic (upcase old))))))
	      (if (equal old (upcase old))
		  (upcase new)
		(downcase new))))
	   ((string-match (rst-re 'ltr-tag) cnt)
	    (char-to-string (1+ (string-to-char (match-string 0 cnt))))))
	  sfx))))
    tab))