Function: rst-Ttl--validate-match

rst-Ttl--validate-match is a byte-compiled function defined in rst.el.gz.

Signature

(rst-Ttl--validate-match MATCH ADO)

Documentation

Return valid MATCH matching ADO or signal error.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-Ttl--validate-match (match ado)
  ;; testcover: ok.
  "Return valid MATCH matching ADO or signal error."
  (cl-check-type ado (or null rst-Ado))
  (cl-check-type match list)
  (cl-check-type match (satisfies (lambda (m)
				    (equal (length m) 8)))
		 "Match data must consist of exactly 8 buffer positions.")
  (dolist (pos match)
    (cl-check-type pos (or null integer-or-marker)))
  (cl-destructuring-bind (all-beg all-end
			  ovr-beg ovr-end
			  txt-beg txt-end
			  und-beg und-end) match
    (unless (and (integer-or-marker-p all-beg) (integer-or-marker-p all-end))
      (signal 'args-out-of-range
	      '("First two elements of match data must be buffer positions.")))
    (cond
     ((null ado)
      (unless (and (null ovr-beg) (null ovr-end)
		   (integer-or-marker-p txt-beg) (integer-or-marker-p txt-end)
		   (null und-beg) (null und-end))
	(signal 'args-out-of-range
		'("For a title candidate exactly the third match pair must be set."))))
     ((rst-Ado-is-transition ado)
      (unless (and (null ovr-beg) (null ovr-end)
		   (integer-or-marker-p txt-beg) (integer-or-marker-p txt-end)
		   (null und-beg) (null und-end))
	(signal 'args-out-of-range
		'("For a transition exactly the third match pair must be set."))))
     ((rst-Ado-is-simple ado)
      (unless (and (null ovr-beg) (null ovr-end)
		   (integer-or-marker-p txt-beg) (integer-or-marker-p txt-end)
		   (integer-or-marker-p und-beg) (integer-or-marker-p und-end))
	(signal 'args-out-of-range
		'("For a simple section adornment exactly the third and fourth match pair must be set."))))
     (t ; over-and-under
      (unless (and (integer-or-marker-p ovr-beg) (integer-or-marker-p ovr-end)
		   (integer-or-marker-p txt-beg) (integer-or-marker-p txt-end)
		   (or (null und-beg) (integer-or-marker-p und-beg))
		   (or (null und-end) (integer-or-marker-p und-end)))
	(signal 'args-out-of-range
		'("For an over-and-under section adornment all match pairs must be set."))))))
  match)