branch: externals/org commit b84018633eaebb08b90fca12237b0b892d19a528 Author: TEC <g...@tecosaur.net> Commit: Ihor Radchenko <yanta...@posteo.net>
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'. --- lisp/ox-latex.el | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 330007eba9..156940703a 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -4301,25 +4301,32 @@ produced." (outfile (org-compile-file texfile process "pdf" (format "See %S for details" log-buf-name) log-buf spec))) - (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 ".")))))) + (org-latex-compile--postprocess outfile log-buf snippet) ;; Return output file name. 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) "Collect some warnings from \"pdflatex\" command output. BUFFER is the buffer containing output. Return collected