ox-latex: Small refactor

* ox-latex.el (org-latex-compile): Use format-spec.
This commit is contained in:
Rasmus 2015-09-13 16:45:48 +02:00
parent 74da3bc10f
commit f6187deca5
1 changed files with 18 additions and 16 deletions

View File

@ -3502,24 +3502,26 @@ Return PDF file name or an error if it couldn't be produced."
((functionp org-latex-pdf-process) ((functionp org-latex-pdf-process)
(funcall org-latex-pdf-process (shell-quote-argument texfile))) (funcall org-latex-pdf-process (shell-quote-argument texfile)))
;; A list is provided: Replace %b, %f and %o with appropriate ;; A list is provided: Replace %b, %f and %o with appropriate
;; values in each command before applying it. Output is ;; values in each command before applying it. Note that while
;; redirected to "*Org PDF LaTeX Output*" buffer. ;; "%latex" and "%bibtex" is used in `org-latex-pdf-process',
;; they are replaced with "%L" and "%B" to adhere to
;; format-spec. Output is redirected to "*Org PDF LaTeX
;; Output*" buffer.
((consp org-latex-pdf-process) ((consp org-latex-pdf-process)
(let ((outbuf (and (not snippet) (let ((outbuf (and (not snippet)
(get-buffer-create "*Org PDF LaTeX Output*")))) (get-buffer-create "*Org PDF LaTeX Output*")))
(dolist (command org-latex-pdf-process) (spec (list (cons ?B (shell-quote-argument org-latex-bib-compiler))
(shell-command (cons ?L (shell-quote-argument compiler))
(replace-regexp-in-string (cons ?b (shell-quote-argument base-name))
"%bib" (shell-quote-argument org-latex-bib-compiler) (cons ?f (shell-quote-argument full-name))
(replace-regexp-in-string (cons ?o (shell-quote-argument out-dir)))))
"%latex" (shell-quote-argument compiler) (mapc (lambda (command)
(replace-regexp-in-string (shell-command (format-spec command spec) outbuf))
"%b" (shell-quote-argument base-name) (mapcar (lambda (command)
(replace-regexp-in-string (replace-regexp-in-string "%\\(latex\\|bibtex\\)\\>"
"%f" (shell-quote-argument full-name) (lambda (str) (upcase (substring str 0 2)))
(replace-regexp-in-string command))
"%o" (shell-quote-argument out-dir) command t t) t t) t t) t) t) org-latex-pdf-process))
outbuf))
;; Collect standard errors from output buffer. ;; Collect standard errors from output buffer.
(setq warnings (and (not snippet) (setq warnings (and (not snippet)
(org-latex--collect-warnings outbuf))))) (org-latex--collect-warnings outbuf)))))