diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-11-08 11:44:28 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-11-08 11:44:28 +0100 |
commit | 120f8c09f460c55131eb8d99685732ee88f538ae (patch) | |
tree | 405c80c360e26c1ade0b163bf11855827cf20ab0 | |
parent | 13dbea95af9ee7bd7db4695a384184ad3f537eab (diff) | |
download | org-mode-120f8c09f460c55131eb8d99685732ee88f538ae.tar.gz |
Fix file compilation in a different directory than current one
* lisp/org.el (org-compile-file): Do not set default directory.
(org-preview-latex-process-alist): Update since base-name may no be
located in current directory.
* lisp/ox-latex.el (org-latex-compile): Remove auxiliary files in
default directory instead of ".tex" file directory.
Reported-by: Alex Fenton <alex.fenton@pressure.to>
<http://permalink.gmane.org/gmane.emacs.orgmode/110078>
-rw-r--r-- | lisp/org.el | 39 | ||||
-rw-r--r-- | lisp/ox-latex.el | 9 |
2 files changed, 26 insertions, 22 deletions
diff --git a/lisp/org.el b/lisp/org.el index 4ce2498..9bf49f7 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4085,7 +4085,7 @@ All available processes and theirs documents can be found in :image-output-type "png" :image-size-adjust (1.0 . 1.0) :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f") - :image-converter ("dvipng -fg %F -bg %B -D %D -T tight -o %b.png %f")) + :image-converter ("dvipng -fg %F -bg %B -D %D -T tight -o %o%b.png %f")) (dvisvgm :programs ("latex" "dvisvgm" "gs") :description "dvi > svg" @@ -4095,7 +4095,7 @@ All available processes and theirs documents can be found in :image-output-type "svg" :image-size-adjust (1.7 . 1.5) :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f") - :image-converter ("dvisvgm %f -n -b min -c %S -o %b.svg")) + :image-converter ("dvisvgm %f -n -b min -c %S -o %o%b.svg")) (imagemagick :programs ("latex" "convert" "gs") :description "pdf > png" @@ -4107,7 +4107,7 @@ All available processes and theirs documents can be found in :image-size-adjust (1.0 . 1.0) :latex-compiler ("pdflatex -interaction nonstopmode -output-directory %o %f") :image-converter - ("convert -density %D -trim -antialias %f -quality 100 %b.png"))) + ("convert -density %D -trim -antialias %f -quality 100 %o%b.png"))) "Definitions of external processes for LaTeX previewing. Org mode can use some external commands to generate TeX snippet's images for previewing or inserting into HTML files, e.g., \"dvipng\". This variable tells @@ -22756,28 +22756,27 @@ it for output. `default-directory' is set to SOURCE directory during the whole process." - (let* ((source-name (file-name-nondirectory source)) - (base-name (file-name-sans-extension source-name)) + (let* ((base-name (file-name-base source)) (full-name (file-truename source)) (out-dir (file-name-directory source)) (time (current-time)) (err-msg (if (stringp err-msg) (concat ". " err-msg) ""))) (save-window-excursion - (let ((default-directory (file-name-directory full-name))) - (pcase process - ((pred functionp) (funcall process (shell-quote-argument source))) - ((pred consp) - (let ((log-buf (and log-buf (get-buffer-create log-buf))) - (spec (append spec - `((?b . ,(shell-quote-argument base-name)) - (?f . ,(shell-quote-argument source-name)) - (?F . ,(shell-quote-argument full-name)) - (?o . ,(shell-quote-argument out-dir)))))) - (dolist (command process) - (shell-command (format-spec command spec) log-buf)))) - (_ (error "No valid command to process %S%s" source err-msg))))) - ;; Check for process failure. - (let ((output (concat out-dir base-name "." ext))) + (pcase process + ((pred functionp) (funcall process (shell-quote-argument source))) + ((pred consp) + (let ((log-buf (and log-buf (get-buffer-create log-buf))) + (spec (append spec + `((?b . ,(shell-quote-argument base-name)) + (?f . ,(shell-quote-argument source)) + (?F . ,(shell-quote-argument full-name)) + (?o . ,(shell-quote-argument out-dir)))))) + (dolist (command process) + (shell-command (format-spec command spec) log-buf)))) + (_ (error "No valid command to process %S%s" source err-msg)))) + ;; Check for process failure. Output file is expected to be + ;; located in the same directory as SOURCE. + (let ((output (expand-file-name (concat base-name "." ext) out-dir))) (unless (org-file-newer-than-p output time) (error (format "File %S wasn't produced%s" output err-msg))) output))) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index bdb239b..a17bd2a 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -3612,10 +3612,15 @@ produced." (when org-latex-remove-logfiles (mapc #'delete-file (directory-files - (file-name-directory texfile) t + ;; Assume auxiliary files are created in current + ;; directory instead of ".tex" file directory, which + ;; may differ. + default-directory + nil (concat (regexp-quote (file-name-base outfile)) "\\(?:\\.[0-9]+\\)?\\." - (regexp-opt org-latex-logfiles-extensions))))) + (regexp-opt org-latex-logfiles-extensions)) + t))) (let ((warnings (org-latex--collect-warnings log-buf))) (message (concat "PDF file produced" (cond |