diff --git a/tex.el b/tex.el index d964940..0dd3c5d 100644 --- a/tex.el +++ b/tex.el @@ -2520,13 +2520,14 @@ assumed to be the same as the directory of `TeX-master'." (string :tag "Custom" "build"))) (make-variable-buffer-local 'TeX-output-dir) -(defun TeX--master-output-dir (master-dir relative-to-master) +(defun TeX--master-output-dir (master-dir relative-to-master &optional ensure) "Return the directory path where output files should be placed. If `TeX-output-dir' is nil, then return nil. MASTER-DIR is the directory path where the master file is located. If RELATIVE-TO-MASTER is non-nil, make the returned path -relative to the directory in MASTER-DIR." +relative to the directory in MASTER-DIR. If ENSURE is non-nil, +the output directory is created if it does not exist." (when TeX-output-dir (let* ((master-dir (expand-file-name (or master-dir ""))) (out-dir (file-name-as-directory @@ -2536,7 +2537,7 @@ relative to the directory in MASTER-DIR." TeX-output-dir master-dir)))))) ;; Make sure the directory exists - (unless (file-exists-p out-dir) + (unless (or (not ensure) (file-exists-p out-dir)) (make-directory (file-name-as-directory out-dir) t)) (if relative-to-master (file-relative-name out-dir master-dir) @@ -2546,7 +2547,7 @@ relative to the directory in MASTER-DIR." "Format the output directory as a command argument. ARGNAME is prepended to the quoted output directory. If `TeX-output-dir' is nil then return an empty string." - (let ((out-dir (TeX--master-output-dir (TeX-master-directory) t))) + (let ((out-dir (TeX--master-output-dir (TeX-master-directory) t t))) (if out-dir (concat argname "\"" out-dir "\"") "")))