Function: preview--skip-preamble-region

preview--skip-preamble-region is a byte-compiled function defined in preview.el.

Signature

(preview--skip-preamble-region REGION-TEXT REGION-OFFSET)

Documentation

Skip preamble for the sake of predumped formats.

Helper function of TeX-region-create.

If REGION-TEXT doesn't contain preamble, it returns nil. Otherwise, it returns cons (ALTERED-TEXT . ALTERED-OFFSET) where ALTERED-TEXT is REGION-TEXT without the preamble part and ALTERED-OFFSET is REGION-OFFSET increased by the number of lines of the preamble part of REGION-TEXT.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
;; We have a big problem: When we are dumping preambles, diagnostics
;; issued in later runs will not make it to the output when the
;; predumped format skips the preamble.  So we have to place those
;; after \begin{document}.  This we can only do if regions never
;; include the preamble.  We could do this in our own functions, but
;; that would not extend to the operation of C-c C-r g RET.  So we
;; make this preamble skipping business part of TeX-region-create.
;; This will fail if the region is to contain just part of the
;; preamble -- a bad idea anyhow.

(defun preview--skip-preamble-region (region-text region-offset)
  "Skip preamble for the sake of predumped formats.
Helper function of `TeX-region-create'.

If REGION-TEXT doesn't contain preamble, it returns nil.
Otherwise, it returns cons (ALTERED-TEXT . ALTERED-OFFSET) where
ALTERED-TEXT is REGION-TEXT without the preamble part and
ALTERED-OFFSET is REGION-OFFSET increased by the number of lines
of the preamble part of REGION-TEXT."
  (if (string-match TeX-header-end region-text)
      (cons (substring region-text (match-end 0))
            (with-temp-buffer
              (insert (substring region-text 0 (match-end 0)))
              (+ region-offset (TeX-current-offset))))))