Function: preview-cache-preamble
preview-cache-preamble is an interactive and byte-compiled function
defined in preview.el.
Signature
(preview-cache-preamble &optional FORMAT-CONS)
Documentation
Dump a pregenerated format file.
For the rest of the session, this file is used when running on the same master file.
Return the process for dumping, nil if there is still a valid format available.
If FORMAT-CONS is non-nil, a previous format may get reused.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-cache-preamble (&optional format-cons)
"Dump a pregenerated format file.
For the rest of the session, this file is used when running
on the same master file.
Return the process for dumping, nil if there is still a valid
format available.
If FORMAT-CONS is non-nil, a previous format may get reused."
(interactive)
(setq TeX-current-process-region-p nil)
(let* ((dump-file
(expand-file-name (preview-dump-file-name (TeX-master-output-file "ini"))))
(master (TeX-master-file))
(format-name (expand-file-name master))
(preview-format-name (shell-quote-argument
(preview-dump-file-name
(TeX-master-output-file nil))))
(master-file (expand-file-name (TeX-master-file t)))
(master-output-file (expand-file-name (TeX-master-output-file nil)))
(command (preview-do-replacements
(TeX-command-expand
(preview-string-expand preview-LaTeX-command))
preview-dump-replacements))
(preview-auto-cache-preamble nil))
(unless (and (consp (cdr format-cons))
(string= command (caddr format-cons)))
(unless format-cons
(setq format-cons (assoc format-name preview-dumped-alist)))
(if format-cons
(preview-cache-preamble-off format-cons)
(setq format-cons (list format-name))
(push format-cons preview-dumped-alist))
;; mylatex.ltx expects a file name to follow. Bad.
;; The file `.tex' in the tools bundle is solely emitting
;; `File ignored', and `\input mylatex.ltx \relax' has the
;; same effect as `\input mylatex.ltx .tex '.
;; The \dump hacks accomplish, among others:
;; - let TeX not ignore spaces (despite instructions to the
;; contrary inserted into the format by mylatex.ltx)
;; as we may need to input a `file name with spaces'.
;; - work around the fact that the backslash `\' (as per
;; mylatex.ltx mandate) has lost its standard TeX status
;; once the format is loaded, and we could not use `\input'
;; as in e.g. `pdflatex &abc '\input' abc.tex'. We
;; configure TeX for `/' as substitute.
;; - in place of such `/input', we will use `/AUCTEXINPUT'
;; defined here in the dumped format to grab the file name,
;; sanitize it via `\detokenize', then
;; reset TeX to ignore spaces and execute `\input' which
;; will skip the preamble already dumped.
;; Prior to the patch adding `/AUCTEXINPUT', resetting the
;; spaces to be ignored was included as part of `\everyjob',
;; which was another way to delay this to after the filename
;; was seen by TeX.
(write-region "\\let\\PREVIEWdump\\dump\\def\\dump{%
\\edef\\next{{\\ifx\\pdfoutput\\undefined\\else\
\\pdfoutput=\\the\\pdfoutput\\relax\\fi\
\\the\\everyjob}}\\everyjob\\next\\catcode`\\ 10 %
\\catcode`/ 0 %
\\def\\AUCTEXINPUT##1{\\catcode`/ 12\\relax\\catcode`\\ 9\\relax\\input\\detokenize{##1}\\relax}%
\\let\\dump\\PREVIEWdump\\dump}\\input mylatex.ltx \\relax%\n" nil dump-file)
(TeX-save-document #'TeX-master-file)
(prog1 (preview-generate-preview master command)
(add-hook 'kill-emacs-hook #'preview-cleanout-tempfiles t)
(setq TeX-sentinel-function
(lambda (process _status)
(condition-case err
(progn
(if (and (eq (process-status process) 'exit)
(zerop (process-exit-status process)))
(preview-watch-preamble
master-file
command
format-cons
master-output-file)
(preview-format-kill format-cons))
(delete-file dump-file))
(error (preview-log-error err "Dumping" process)))
(preview-reraise-error process)))))))