ox-latex: Split org-latex-compile into two funs

* lisp/ox-latex.el (org-latex-compile): Split off the postprocessing in
`org-latex-compile' into a new function,
`org-latex-compile--postprocess'.
This commit is contained in:
TEC 2022-12-25 00:57:59 +08:00 committed by Ihor Radchenko
parent 18d2f871c2
commit b84018633e
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -4301,25 +4301,32 @@ produced."
(outfile (org-compile-file texfile process "pdf" (outfile (org-compile-file texfile process "pdf"
(format "See %S for details" log-buf-name) (format "See %S for details" log-buf-name)
log-buf spec))) log-buf spec)))
(unless snippet (org-latex-compile--postprocess outfile log-buf snippet)
(when org-latex-remove-logfiles
(mapc #'delete-file
(directory-files
(file-name-directory outfile)
t
(concat (regexp-quote (file-name-base outfile))
"\\(?:\\.[0-9]+\\)?\\."
(regexp-opt org-latex-logfiles-extensions))
t)))
(let ((warnings (org-latex--collect-warnings log-buf)))
(message (concat "PDF file produced"
(cond
((eq warnings 'error) " with errors.")
(warnings (concat " with warnings: " warnings))
(t "."))))))
;; Return output file name. ;; Return output file name.
outfile)) outfile))
(defun org-latex-compile--postprocess (outfile log-buf &optional snippet)
"Process the results of creating OUTFILE via LaTeX compilation.
Warnings and errors are collected from LOG-BUF.
When SNIPPET is nil and `org-latex-remove-logfiles' non-nil,
log files (as specified by `org-latex-logfiles-extensions') are deleted."
(unless snippet
(when org-latex-remove-logfiles
(mapc #'delete-file
(directory-files
(file-name-directory outfile)
t
(concat (regexp-quote (file-name-base outfile))
"\\(?:\\.[0-9]+\\)?\\."
(regexp-opt org-latex-logfiles-extensions))
t)))
(let ((warnings (org-latex--collect-warnings log-buf)))
(message (concat "PDF file produced"
(cond
((eq warnings 'error) " with errors.")
(warnings (concat " with warnings: " warnings))
(t ".")))))))
(defun org-latex--collect-warnings (buffer) (defun org-latex--collect-warnings (buffer)
"Collect some warnings from \"pdflatex\" command output. "Collect some warnings from \"pdflatex\" command output.
BUFFER is the buffer containing output. Return collected BUFFER is the buffer containing output. Return collected