org-e-latex: "%b" really means base filename

* contrib/lisp/org-e-latex.el (org-e-latex-pdf-process): Update
  docstring.
(org-e-latex-compile): "%b" is replaced with base filename, that is
filename without directory and extension.
This commit is contained in:
Nicolas Goaziou 2012-10-25 14:52:25 +02:00
parent 44ad106d69
commit 4bb5a06b15

View file

@ -753,8 +753,8 @@ string defines the replacement string for this quote."
"Commands to process a LaTeX file to a PDF file. "Commands to process a LaTeX file to a PDF file.
This is a list of strings, each of them will be given to the This is a list of strings, each of them will be given to the
shell as a command. %f in the command will be replaced by the shell as a command. %f in the command will be replaced by the
full file name, %b by the file base name \(i.e. without full file name, %b by the file base name (i.e. without directory
extension) and %o by the base directory of the file. and extension parts) and %o by the base directory of the file.
The reason why this is a list is that it usually takes several The reason why this is a list is that it usually takes several
runs of `pdflatex', maybe mixed with a call to `bibtex'. Org runs of `pdflatex', maybe mixed with a call to `bibtex'. Org
@ -2667,11 +2667,12 @@ TEXFILE is the name of the file being compiled. Processing is
done through the command specified in `org-e-latex-pdf-process'. done through the command specified in `org-e-latex-pdf-process'.
Return PDF file name or an error if it couldn't be produced." Return PDF file name or an error if it couldn't be produced."
(let* ((texfile (file-truename texfile)) (let* ((base-name (file-name-sans-extension (file-name-nondirectory texfile)))
(base (file-name-sans-extension texfile)) (full-name (file-truename texfile))
(out-dir (file-name-directory texfile))
;; Make sure `default-directory' is set to TEXFILE directory, ;; Make sure `default-directory' is set to TEXFILE directory,
;; not to whatever value the current buffer may have. ;; not to whatever value the current buffer may have.
(default-directory (file-name-directory texfile)) (default-directory (file-name-directory full-name))
errors) errors)
(message (format "Processing LaTeX file %s ..." texfile)) (message (format "Processing LaTeX file %s ..." texfile))
(save-window-excursion (save-window-excursion
@ -2683,15 +2684,14 @@ Return PDF file name or an error if it couldn't be produced."
;; values in each command before applying it. Output is ;; values in each command before applying it. Output is
;; redirected to "*Org PDF LaTeX Output*" buffer. ;; redirected to "*Org PDF LaTeX Output*" buffer.
((consp org-e-latex-pdf-process) ((consp org-e-latex-pdf-process)
(let* ((out-dir (file-name-directory texfile)) (let ((outbuf (get-buffer-create "*Org PDF LaTeX Output*")))
(outbuf (get-buffer-create "*Org PDF LaTeX Output*")))
(mapc (mapc
(lambda (command) (lambda (command)
(shell-command (shell-command
(replace-regexp-in-string (replace-regexp-in-string
"%b" (shell-quote-argument base) "%b" (shell-quote-argument base-name)
(replace-regexp-in-string (replace-regexp-in-string
"%f" (shell-quote-argument texfile) "%f" (shell-quote-argument full-name)
(replace-regexp-in-string (replace-regexp-in-string
"%o" (shell-quote-argument out-dir) command t t) t t) t t) "%o" (shell-quote-argument out-dir) command t t) t t) t t)
outbuf)) outbuf))
@ -2699,7 +2699,7 @@ Return PDF file name or an error if it couldn't be produced."
;; Collect standard errors from output buffer. ;; Collect standard errors from output buffer.
(setq errors (org-e-latex--collect-errors outbuf)))) (setq errors (org-e-latex--collect-errors outbuf))))
(t (error "No valid command to process to PDF"))) (t (error "No valid command to process to PDF")))
(let ((pdffile (concat base ".pdf"))) (let ((pdffile (concat out-dir base-name ".pdf")))
;; Check for process failure. Provide collected errors if ;; Check for process failure. Provide collected errors if
;; possible. ;; possible.
(if (not (file-exists-p pdffile)) (if (not (file-exists-p pdffile))
@ -2709,7 +2709,7 @@ Return PDF file name or an error if it couldn't be produced."
;; process to user, along with any error encountered. ;; process to user, along with any error encountered.
(when org-e-latex-remove-logfiles (when org-e-latex-remove-logfiles
(dolist (ext org-e-latex-logfiles-extensions) (dolist (ext org-e-latex-logfiles-extensions)
(let ((file (concat base "." ext))) (let ((file (concat out-dir base-name "." ext)))
(when (file-exists-p file) (delete-file file))))) (when (file-exists-p file) (delete-file file)))))
(message (concat "Process completed" (message (concat "Process completed"
(if (not errors) "." (if (not errors) "."