Function: preview-dsc-parse
preview-dsc-parse is a byte-compiled function defined in preview.el.
Signature
(preview-dsc-parse FILE)
Documentation
Parse DSC comments of FILE.
Return a vector with offset/length pairs corresponding to the pages. Page 0 corresponds to the initialization section.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-dsc-parse (file)
"Parse DSC comments of FILE.
Return a vector with offset/length pairs corresponding to
the pages. Page 0 corresponds to the initialization section."
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally file)
(let ((last-pt (point-min))
trailer
pagelist
lastbegin
pt
case-fold-search
(level 0))
(while (search-forward-regexp "\
%%\\(?:\\(BeginDocument:\\)\\|\
\\(EndDocument[\n\r]\\)\\|\
\\(Page:\\)\\|\
\\(Trailer[\n\r]\\)\\)" nil t)
(setq pt (match-beginning 0))
(cond ((null (memq (char-before pt) '(?\C-j ?\C-m nil))))
(trailer (error "Premature %%%%Trailer in `%s' at offsets %d/%d"
file trailer pt))
((match-beginning 1)
(if (zerop level)
(setq lastbegin pt))
(setq level (1+ level)))
((match-beginning 2)
(if (zerop level)
(error "Unmatched %%%%EndDocument in `%s' at offset %d"
file pt)
(setq level (1- level))))
((> level 0))
((match-beginning 3)
(push (list last-pt (- pt last-pt)) pagelist)
(setq last-pt pt))
((match-beginning 4)
(setq trailer pt))))
(unless (zerop level)
(error "Unmatched %%%%BeginDocument in `%s' at offset %d"
file lastbegin))
(push (list last-pt
(- (or trailer (point-max)) last-pt)) pagelist)
(vconcat (nreverse pagelist)))))