[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] GNU AUCTeX branch, tex-build-only, created. 094c298621902
From: |
Al Haji-Ali |
Subject: |
[AUCTeX-diffs] GNU AUCTeX branch, tex-build-only, created. 094c29862190290832e60872c2ab1442a27bdba5 |
Date: |
Wed, 17 Mar 2021 15:44:56 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".
The branch, tex-build-only has been created
at 094c29862190290832e60872c2ab1442a27bdba5 (commit)
- Log -----------------------------------------------------------------
commit 094c29862190290832e60872c2ab1442a27bdba5
Author: Al Haji-Ali <a.hajiali@hw.ac.uk>
Date: Tue Mar 16 18:54:21 2021 +0000
Implement the user option TeX-output-dir
* doc/auctex.texi (Control/Controlling the output): Document the
new TeX-output-dir user option.
* preview.el.in (preview-pdf2dsc-command): Replace concatenated output
file names with the new expansions.
(preview-LaTeX-command): Use an expansion for filename only.
(preview-create-subdirectory): Retrieve prv path from
TeX-active-master.
(preview-dump-replacements, preview-undump-replacements): Do not
discard --output-directory from the command arguments.
(preview-cache-preamble, preview-document): Call TeX-save-document
with file function instead of filename.
(TeX-inline-preview-internal): Retrieve prv path from TeX-master-file.
* tex-bar.el (TeX-bar-TeX-button-alist, TeX-bar-LaTeX-button-alist):
Call TeX-save-document with file function instead of filename.
* tex-buf.el (TeX-save-document, TeX-command-default)
(TeX-command-query): Change implementation to accept file function as
well as filename as argument.
(TeX--concat-ext): New helper function.
(TeX-command-master, TeX-command-region): Call TeX-command-query with
file function instead of filename.
(TeX-command): Update documentation.
(TeX-active-master-with-quotes): Add new argument for pre-processing
filename.
(TeX-command-sequence): Pass file function to TeX-command-default.
(TeX-run-TeX, TeX-run-index, TeX-LaTeX-sentinel): Call
TeX-active-master instead of concatenating extension to filename.
(TeX-region-file): Change to return paths in TeX-output-dir when
non-nil.
* tex.el (TeX-command-list, LaTeX-command-style): Change commands to
pass output-directory as an argument.
(TeX-print-command, TeX-printer-list): Use "%d" for dvi files.
(TeX-expand-list-builtin): Add expansions for output files and
directories.
(TeX-clean): Refactor to use the new TeX--clean-extensions-regexp.
(TeX-master-file): Change to return output files inside
TeX-output-file.
(TeX-output-dir): New user option.
(TeX--master-output-dir, TeX--output-dir-arg)
(TeX--clean-extensions-regexp): New function.
(TeX-split-string): Correct a spelling mistake.
diff --git a/doc/auctex.texi b/doc/auctex.texi
index fad97d6..4342b56 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -3905,6 +3905,39 @@ the current buffer, or if already there, to the file
where the current
process was started.
@end deffn
+Additionally, output files produced by @AUCTeX{} can be placed in a
+separate directory.
+
+@defopt TeX-output-dir
+Set this option to the path of a directory where output files will be
+placed. The output files include those that are produced by applications
+running under @AUCTeX{}, temporary files related to region processing and
+the @previewlatex{} files. If a relative path is specified, it is
+interpreted as being relative to the master file in a mutlifile document.
+
+This is a buffer local variable and must be set separately for all
+documents and all files in a multifile document. For example,
+
+@example
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-output-dir: "build"
+%%% End:
+@end example
+
+Alternatively, you may use @code{setq-default} to set the default value of
+this option or set it as a directory local variable (see
+@code{add-dir-local-variable}).
+
+Note that a non-nil value of @code{TeX-output-dir} might be incompatible
+with some @TeX{} commands and macros. In particular, the @LaTeX{} macro
+@samp{\include} is known to not work with this option. Some @TeX{}
+packages which produce intermediary files might also be incompatible. A
+possible workaround for those packages is to append the value of
+@code{TeX-output-dir} to the environment variables @samp{TEXINPUTS} and
+@samp{BIBINPUTS}.
+@end defopt
+
@node Cleaning
@section Cleaning intermediate and output files
@cindex Cleaning
diff --git a/preview.el.in b/preview.el.in
index ba10ee8..c24c1c5 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -552,7 +552,7 @@ if you customize this."
:type 'string)
(defcustom preview-pdf2dsc-command
- "pdf2dsc %s.pdf %m/preview.dsc"
+ "pdf2dsc %(O?pdf) %m/preview.dsc"
"Command used for generating dsc from a PDF file."
:group 'preview-latex
:type 'string)
@@ -2771,7 +2771,7 @@ list of LaTeX commands is inserted just before
\\begin{document}."
(defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\
\\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\
\\AtBeginDocument{\\ifx\\ifPreview\\undefined"
-preview-default-preamble "\\fi}\"%' \"\\detokenize{\" %t \"}\"")
+preview-default-preamble "\\fi}\"%' \"\\detokenize{\" %(t-filename-only)
\"}\"")
;; Since TeXLive 2018, the default encoding for LaTeX files has been
;; changed to UTF-8 if used with classic TeX or pdfTeX. I.e.,
;; \usepackage[utf8]{inputenc} is enabled by default in (pdf)latex.
@@ -3155,7 +3155,10 @@ later while in use."
topdir
0))
(shell-quote-argument
- (concat (file-name-as-directory (file-name-nondirectory topdir))
+ (concat (file-name-as-directory
+ ;; Don't use topdir, because %m expects the path to be
+ ;; relative to master
+ (TeX-active-master "prv" t))
(file-name-nondirectory (nth 0 TeX-active-tempdir))))))
(defun preview-parse-counters (string)
@@ -3911,8 +3914,8 @@ This is passed through `preview-do-replacements'."
;; If -kanji option exists, pick it up as the second match.
;; Discard all other options.
("\\`\\([^ ]+\\)\
-\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*\\(.*\\)\\'"
- . ("\\1 -ini \\2 -interaction=nonstopmode \"&\\1\" " preview-format-name
".ini \\3")))
+\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|\\(--?output-directory[= ][^
]+\\)\\|-\\(?:[^ \\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*\\(.*\\)\\'"
+ . ("\\1 -ini \\2 \\3 -interaction=nonstopmode \"&\\1\" "
preview-format-name ".ini \\4")))
"Generate a dump command from the usual preview command."
:group 'preview-latex
:type '(repeat
@@ -3923,10 +3926,10 @@ This is passed through `preview-do-replacements'."
;; If -kanji option exists, pick it up as the second match.
;; Discard all other options.
'(("\\`\\([^ ]+\\)\
-\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.*\
+\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|\\(--?output-directory[= ][^
]+\\)\\|-\\(?:[^ \\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.*\
\"\\\\input\" \"\\\\detokenize{\" \\(.*\\) \"}\"\\'"
- . ("\\1 \\2 -interaction=nonstopmode -file-line-error "
- preview-format-name " \"/AUCTEXINPUT{\" \\3 \"}\"")))
+ . ("\\1 \\2 \\3 -interaction=nonstopmode -file-line-error "
+ preview-format-name " \"/AUCTEXINPUT{\" \\4 \"}\"")))
;; See the ini file code below in `preview-cache-preamble' for the
;; weird /AUCTEXINPUT construct. In short, it is crafted so that
;; dumped format file can read file of non-ascii name.
@@ -3978,7 +3981,7 @@ If FORMAT-CONS is non-nil, a previous format may get
reused."
\\catcode`/ 0 %
\\def\\AUCTEXINPUT##1{\\catcode`/ 12\\relax\\catcode`\\
9\\relax\\input\\detokenize{##1}\\relax}%
\\let\\dump\\PREVIEWdump\\dump}\\input mylatex.ltx \\relax%\n" nil dump-file)
- (TeX-save-document master)
+ (TeX-save-document #'TeX-master-file)
(prog1 (preview-generate-preview master command)
(add-hook 'kill-emacs-hook #'preview-cleanout-tempfiles t)
(setq TeX-sentinel-function
@@ -4065,7 +4068,7 @@ stored in `preview-dumped-alist'."
(defun preview-document ()
"Run preview on master document."
(interactive)
- (TeX-save-document (TeX-master-file))
+ (TeX-save-document #'TeX-master-file)
(setq TeX-current-process-region-p nil)
(preview-generate-preview
(TeX-master-file)
@@ -4160,7 +4163,12 @@ internal parameters, STR may be a log to insert into the
current log."
((preview-format-name (shell-quote-argument
(concat "&"
(preview-dump-file-name
- (file-name-nondirectory master)))))
+ ;; Get the filename from
+ ;; `TeX-master-file' with prv to
+ ;; get the correct path but then
+ ;; strip the extension
+ (file-name-sans-extension
+ (TeX-master-file "prv" t))))))
(process-environment (copy-sequence process-environment))
(process
(progn
diff --git a/tex-bar.el b/tex-bar.el
index 9866cc5..4f90384 100644
--- a/tex-bar.el
+++ b/tex-bar.el
@@ -136,13 +136,13 @@ the argument BUTTON-ALIST in function
`toolbarx-install-toolbar'."
(defcustom TeX-bar-TeX-button-alist
'((tex :image (lambda nil (if TeX-PDF-mode "pdftex" "tex"))
:command (progn
- (TeX-save-document (TeX-master-file))
+ (TeX-save-document #'TeX-master-file)
(TeX-command "TeX" 'TeX-master-file -1))
:help (lambda (&rest ignored)
(TeX-bar-help-from-command-list "TeX")))
(pdftex :image "pdftex"
:command (progn
- (TeX-save-document (TeX-master-file))
+ (TeX-save-document #'TeX-master-file)
(TeX-command "PDFTeX" 'TeX-master-file -1))
:help (lambda (&rest ignored)
(TeX-bar-help-from-command-list "PDFTeX")))
@@ -277,13 +277,13 @@ the argument BUTTON-ALIST in function
`toolbarx-install-toolbar'."
(defcustom TeX-bar-LaTeX-button-alist
'((latex :image (lambda nil (if TeX-PDF-mode "pdftex" "tex"))
:command (progn
- (TeX-save-document (TeX-master-file))
+ (TeX-save-document #'TeX-master-file)
(TeX-command "LaTeX" 'TeX-master-file -1))
:help (lambda (&rest ignored)
(TeX-bar-help-from-command-list "LaTeX")))
(pdflatex :image "pdftex"
:command (progn
- (TeX-save-document (TeX-master-file))
+ (TeX-save-document #'TeX-master-file)
(TeX-command "PDFLaTeX" 'TeX-master-file -1))
:help (lambda (&rest ignored)
(TeX-bar-help-from-command-list "PDFLaTeX")))
diff --git a/tex-buf.el b/tex-buf.el
index e13a211..9f174f0 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -75,24 +75,36 @@
;; THEN ``the'' process is the region process
;; ELSE ``the'' process is the master file (of the current buffer) process
-(defun TeX-save-document (name)
+(defun TeX-save-document (name-or-file-fn)
"Save all files belonging to the current document.
Return non-nil if document needs to be re-TeX'ed."
- (interactive (list (TeX-master-file)))
- (if (string-equal name "")
- (setq name (TeX-master-file)))
-
- (TeX-check-files (concat name "." (TeX-output-extension))
- (cons name (TeX-style-list))
+ (interactive (list #'TeX-master-file))
+ (TeX-check-files (TeX--concat-ext name-or-file-fn (TeX-output-extension))
+ (cons (TeX--concat-ext name-or-file-fn) (TeX-style-list))
TeX-file-extensions))
+(defun TeX--concat-ext (name-or-file-fn &optional extension)
+ "Append EXTENSION to a filename specified by NAME-OR-FILE-FN.
+
+If NAME-OR-FILE-FN is a string, interpret it as the filename.
+Otherwise, assume it is a callable function and call it with
+EXTENSION as an argument and return the result without
+modification. EXTENSION is a string which should not start with
+'.'."
+ (if (stringp name-or-file-fn)
+ (if extension
+ (concat name-or-file-fn "." extension)
+ name-or-file-fn)
+ (funcall name-or-file-fn extension)))
+
(defun TeX-command-master (&optional override-confirm)
"Run command on the current document.
If a prefix argument OVERRIDE-CONFIRM is given, confirmation will
depend on it being positive instead of the entry in `TeX-command-list'."
(interactive "P")
- (TeX-command (TeX-command-query (TeX-master-file nil nil t))
+ (TeX-master-file nil nil t) ;; call to ask if necessary
+ (TeX-command (TeX-command-query #'TeX-master-file)
'TeX-master-file override-confirm))
(defvar TeX-command-region-begin nil)
@@ -185,7 +197,7 @@ all text after `TeX-trailer-start'."
;; `nondirectory' argument, otherwise `TeX-command-default' called
;; within `TeX-command-query' won't work in included files not
;; placed in `TeX-master-directory'.
- (TeX-command (TeX-command-query (TeX-region-file)) 'TeX-region-file
+ (TeX-command (TeX-command-query #'TeX-region-file) #'TeX-region-file
override-confirm))
(defun TeX-command-buffer (&optional override-confirm)
@@ -468,7 +480,7 @@ Do you want to select one of these engines? "
FILE-FN is the symbol of a function returning a file name. The
function has one optional argument, the extension to use on the
-file.
+file. Valid choices are `TeX-master-file' and `TeX-region-file'
Use the information in `TeX-command-list' to determine how to run
the command.
@@ -569,7 +581,7 @@ without further expansion."
TeX-expand-command))
(defun TeX-active-master-with-quotes
- (&optional extension nondirectory ask extra)
+ (&optional extension nondirectory ask extra preprocess-fn)
"Return the current master or region file name with quote for shell.
Pass arguments EXTENSION NONDIRECTORY ASK to `TeX-active-master'.
If the returned file name contains space, enclose it within
@@ -581,7 +593,9 @@ the following three conditions are met:
2. \" \\input\" is supplemented
3. EXTRA is non-nil (default when expanding \"%T\")
Adjust dynamically bound variable `TeX-expand-pos' to avoid possible
-infinite loop in `TeX-command-expand'.
+infinite loop in `TeX-command-expand'. If PREPROCESS-FN is non-nil then
+it is called with the filename as an argument and the results is
+enclosed instead of the filename.
Helper function of `TeX-command-expand'. Use only within entries in
`TeX-expand-list-builtin' and `TeX-expand-list'."
@@ -608,7 +622,11 @@ Helper function of `TeX-command-expand'. Use only within
entries in
;; recognize non-ascii characters in the file name
;; when \input precedes.
"\\detokenize{ %s }" "%s")
- (concat quote-for-space raw quote-for-space)))))
+ (concat quote-for-space
+ (if preprocess-fn
+ (funcall preprocess-fn raw)
+ raw)
+ quote-for-space)))))
;; Advance past the file name in order to
;; prevent expanding any substring of it.
(setq TeX-expand-pos
@@ -743,15 +761,11 @@ omitted) and `TeX-region-file'."
(setq cmd (funcall command)
TeX-command-sequence-command command))
(t
- (setq cmd (TeX-command-default
- ;; File function should be called with nil `nondirectory'
- ;; argument, otherwise `TeX-command-sequence' won't work in
- ;; included files not placed in `TeX-master-directory'. In
- ;; addition, `TeX-master-file' is called with the third
- ;; argument (`ask') set to t, so that the master file is
- ;; properly set. This is also what `TeX-command-master'
- ;; does.
- (funcall TeX-command-sequence-file-function nil nil t))
+ ;; We first call `TeX-master-file' with the third argument
+ ;; (`ask') set to t, so that the master file is properly set.
+ ;; This is also what `TeX-command-master' does.
+ (funcall TeX-command-sequence-file-function nil nil t)
+ (setq cmd (TeX-command-default TeX-command-sequence-file-function)
TeX-command-sequence-command t)))
(TeX-command cmd TeX-command-sequence-file-function 0)
(when reset
@@ -793,25 +807,23 @@ omitted) and `TeX-region-file'."
(defvar TeX-command-history nil)
-(defun TeX-command-default (name)
+(defun TeX-command-default (name-or-file-fn)
"Guess the next command to be run on NAME."
- (let ((command-next nil))
- (cond (;; name might be absolute or relative, so expand it for
- ;; comparison.
- (if (string-equal (expand-file-name name)
- (expand-file-name (TeX-region-file)))
- (TeX-check-files (concat name "." (TeX-output-extension))
+ (let ((command-next nil)
+ (name (TeX--concat-ext name-or-file-fn)))
+ (cond ((if (eq name-or-file-fn #'TeX-region-file)
+ (TeX-check-files (TeX-region-file (TeX-output-extension))
;; Each original will be checked for all dirs
;; in `TeX-check-path' so this needs to be just
;; a filename without directory.
- (list (file-name-nondirectory name))
+ (list (file-relative-name name))
TeX-file-extensions)
- (TeX-save-document (TeX-master-file)))
+ (TeX-save-document name-or-file-fn))
TeX-command-default)
((and (memq major-mode '(doctex-mode latex-mode))
;; Want to know if bib file is newer than .bbl
;; We don't care whether the bib files are open in emacs
- (TeX-check-files (concat name ".bbl")
+ (TeX-check-files (TeX--concat-ext name-or-file-fn "bbl")
(mapcar #'car
(LaTeX-bibliography-list))
(append BibTeX-file-extensions
@@ -833,15 +845,15 @@ omitted) and `TeX-region-file'."
(or (and TeX-PDF-mode (TeX-PDF-from-DVI))
TeX-command-Show)))
(list "Dvips" "Dvipdfmx" TeX-command-Show))
- (cdr (assoc (expand-file-name (concat name ".idx"))
+ (cdr (assoc (expand-file-name (TeX--concat-ext name-or-file-fn
"idx"))
LaTeX-idx-changed-alist)))
"Index")
(command-next)
(TeX-command-Show))))
-(defun TeX-command-query (name)
+(defun TeX-command-query (name-or-file-fn)
"Query the user for what TeX command to use."
- (let* ((default (TeX-command-default name))
+ (let* ((default (TeX-command-default name-or-file-fn))
(completion-ignore-case t)
(answer (or TeX-command-force
(completing-read
@@ -1151,7 +1163,7 @@ run of `TeX-run-TeX', use
;; Store md5 hash of the index file before running LaTeX.
(and (memq major-mode '(doctex-mode latex-mode))
(prog1 (file-exists-p
- (setq idx-file (expand-file-name (concat file ".idx"))))
+ (setq idx-file (expand-file-name (TeX-active-master "idx"))))
;; In order to avoid confusion and pollution of
;; `LaTeX-idx-md5-alist', remove from this alist all md5 hashes of
;; the current index file. Note `assq-delete-all' doesn't work with
@@ -1233,7 +1245,7 @@ run of `TeX-run-TeX', use
;; `default-directory', then we have to expand `file'
file-name
;; in the same directory of `TeX-command-buffer'.
(assoc (with-current-buffer TeX-command-buffer
- (expand-file-name (concat file ".idx")))
+ (expand-file-name (TeX-active-master "idx")))
LaTeX-idx-changed-alist))
(setq LaTeX-idx-changed-alist (delq element LaTeX-idx-changed-alist)))
(if TeX-process-asynchronous
@@ -1681,17 +1693,18 @@ Rerun to get mark in right position\\." nil t)
(setq TeX-command-next TeX-command-default)))
;; Check whether the idx file changed.
- (let ((idx-file nil) (master nil))
+ (let (idx-file)
(and (file-exists-p
(setq idx-file
- (concat
- (setq master
- (with-current-buffer TeX-command-buffer
- (expand-file-name (TeX-active-master)))) ".idx")))
+ (with-current-buffer TeX-command-buffer
+ (expand-file-name (TeX-active-master "idx")))))
;; imakeidx package automatically runs makeindex, thus, we need to be
;; sure .ind file isn't newer than .idx.
- (TeX-check-files (concat master ".ind")
- (list (file-name-nondirectory master)) '("idx"))
+ (TeX-check-files (with-current-buffer TeX-command-buffer
+ (expand-file-name (TeX-active-master "ind")))
+ (with-current-buffer TeX-command-buffer
+ (list (file-name-nondirectory
(TeX-active-master))))
+ '("idx"))
(with-temp-buffer
(insert-file-contents idx-file)
(not (equal
@@ -2230,13 +2243,15 @@ The compatibility argument IGNORE is ignored."
;; third argument `ask'. For example, it's used in `TeX-command-sequence',
;; where we don't know which function has to be called. Keep this in mind
;; should you want to use another argument here.
- (concat (if nondirectory "" (TeX-master-directory))
- (cond ((eq extension t)
- (concat TeX-region "." TeX-default-extension))
- (extension
- (concat TeX-region "." extension))
- (t
- TeX-region))))
+ (let ((master-dir (TeX-master-directory)))
+ (concat (or (TeX--master-output-dir master-dir nondirectory)
+ (if nondirectory "" master-dir))
+ (cond ((eq extension t)
+ (concat TeX-region "." TeX-default-extension))
+ (extension
+ (concat TeX-region "." extension))
+ (t
+ TeX-region)))))
(defcustom TeX-region "_region_"
"Base name of temporary file for `TeX-command-region' and
`TeX-command-buffer'."
diff --git a/tex.el b/tex.el
index b59aee0..11540ee 100644
--- a/tex.el
+++ b/tex.el
@@ -89,6 +89,7 @@
(defvar LaTeX-optop)
(defvar TeX-Biber-global-files)
(defvar TeX-global-input-files)
+(defvar TeX-output-dir)
;; tex-buf.el
(defvar TeX-current-process-region-p)
(defvar TeX-region)
@@ -182,18 +183,18 @@ If nil, none is specified."
;; `TeX-expand-list-builtin' for a description of the % escapes
(defcustom TeX-command-list
- '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts)
%S%(PDFout)%(mode)%' %t"
+ '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts)
%S%(PDFout)%(mode)%' %(output-dir) %t"
TeX-run-TeX nil
(plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX")
("LaTeX" "%`%l%(mode)%' %T"
TeX-run-TeX nil
(latex-mode doctex-mode) :help "Run LaTeX")
;; Not part of standard TeX.
- ("Makeinfo" "makeinfo %(extraopts) %t" TeX-run-compile nil
+ ("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil
(texinfo-mode) :help "Run Makeinfo with Info output")
- ("Makeinfo HTML" "makeinfo %(extraopts) --html %t" TeX-run-compile nil
+ ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t"
TeX-run-compile nil
(texinfo-mode) :help "Run Makeinfo with HTML output")
- ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %t"
+ ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t"
TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
;; support for ConTeXt --pg
;; first version of ConTeXt to support nonstopmode: 2003.2.10
@@ -202,11 +203,11 @@ If nil, none is specified."
("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
TeX-run-TeX nil
(context-mode) :help "Run ConTeXt until completion")
- ("BibTeX" "bibtex %s" TeX-run-BibTeX nil
+ ("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode
context-mode)
:help "Run BibTeX")
- ("Biber" "biber %s" TeX-run-Biber nil
+ ("Biber" "biber %s %(output-dir)" TeX-run-Biber nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Run Biber")
("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
@@ -219,20 +220,20 @@ If nil, none is specified."
("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Convert DVI file to PostScript")
- ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil
+ ("Dvipdfmx" "dvipdfmx %d -o %(O?pdf)" TeX-run-dvipdfmx nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Convert DVI file to PDF with dvipdfmx")
- ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil
+ ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Convert PostScript file to PDF")
- ("Glossaries" "makeglossaries %s" TeX-run-command nil
+ ("Glossaries" "makeglossaries %(O?aux)" TeX-run-command nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Run makeglossaries to create glossary
file")
- ("Index" "makeindex %s" TeX-run-index nil
+ ("Index" "makeindex %(O?idx)" TeX-run-index nil
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Run makeindex to create index file")
- ("upMendex" "upmendex %s" TeX-run-index t
+ ("upMendex" "upmendex %(O?idx)" TeX-run-index t
(plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
:help "Run upmendex to create index file")
("Xindy" "texindy %s" TeX-run-command nil
@@ -393,7 +394,7 @@ The executable `latex' is LaTeX version 2e."
(defcustom LaTeX-command-style
;; They have all been combined in LaTeX 2e.
- '(("" "%(PDF)%(latex) %(file-line-error) %(extraopts) %S%(PDFout)"))
+ '(("" "%(PDF)%(latex) %(file-line-error) %(extraopts) %(output-dir)
%S%(PDFout)"))
"List of style options and LaTeX commands.
If the first element (a regular expression) matches the name of one of
@@ -420,7 +421,7 @@ string."
;; TeX-print-command.
(defcustom TeX-print-command
- "{ test -e %s.dvi && %(o?)dvips -P%p %r %s; } || lpr -P%p %o"
+ "{ test -e %d && %(o?)dvips -P%p %r %s; } || lpr -P%p %o"
"Command used to print a file.
First `%p' is expanded to the printer name, then ordinary expansion is
@@ -448,7 +449,7 @@ the printer has no corresponding command."
;; Print to the (unnamed) default printer. If there is a DVI
;; file print via Dvips. If not, pass the output file (which
;; should then be a Postscript or PDF file) directly to lpr.
- "{ test -e %s.dvi && %(o?)dvips -f %r %s | lpr; } || lpr %o"
+ "{ test -e %d && %(o?)dvips -f %r %s | lpr; } || lpr %o"
;; Show the queue for the (unnamed) default printer.
"lpq"))
"List of available printers.
@@ -563,6 +564,8 @@ string."
("%(cntxcom)" ConTeXt-expand-command)
("%(execopts)" ConTeXt-expand-options)
("%(extraopts)" (lambda () TeX-command-extra-options))
+ ("%(output-dir)" (lambda () (TeX--output-dir-arg "--output-directory=")))
+ ("%(o-dir)" (lambda () (TeX--output-dir-arg "-o ")))
("%S" TeX-source-correlate-expand-options)
("%dS" TeX-source-specials-view-expand-options)
("%cS" TeX-source-specials-view-expand-client)
@@ -583,6 +586,7 @@ string."
;; adds suitable quotes for use in shell command line.
("%s" TeX-active-master-with-quotes nil t)
("%t" TeX-active-master-with-quotes t t)
+ ("%(t-filename-only)" TeX-active-master-with-quotes t t nil nil
file-name-nondirectory)
;; If any TeX codes appear in the interval between %` and %', move
;; all of them after the interval and supplement " \input". The
;; appearance is marked by leaving the bind to `TeX-command-text'
@@ -632,6 +636,9 @@ string."
("%n" TeX-current-line)
("%d" TeX-active-master-with-quotes "dvi" t)
("%f" TeX-active-master-with-quotes "ps" t)
+ ("%(O?aux)" TeX-active-master-with-quotes "aux" t)
+ ("%(O?idx)" TeX-active-master-with-quotes "idx" t)
+ ("%(O?pdf)" TeX-active-master-with-quotes "pdf" t)
("%o" (lambda nil (TeX-active-master-with-quotes (TeX-output-extension)
t)))
;; for source specials the file name generated for the xdvi
;; command needs to be relative to the master file, just in
@@ -2210,25 +2217,20 @@ Used as a default in TeX, LaTeX and docTeX mode.")
If prefix ARG is non-nil, not only remove intermediate but also
output files."
(interactive "P")
- (let* ((mode-prefix (TeX-mode-prefix))
- (suffixes (append (symbol-value
- (intern (concat mode-prefix
- "-clean-intermediate-suffixes")))
- (when arg
- (symbol-value
- (intern (concat mode-prefix
- "-clean-output-suffixes"))))))
- (master (TeX-active-master))
+ (let* (;; Call with output extension then remove it, to make sure we
+ ;; get the correct directory in cases TeX-output-dir is
+ ;; non-nil
+ (master (file-name-sans-extension (TeX-active-master
(TeX-output-extension))))
(master-dir (file-name-directory master))
(regexp (concat "\\("
(regexp-quote (file-name-nondirectory master)) "\\|"
- (regexp-quote (TeX-region-file nil t))
+ (regexp-quote (file-name-nondirectory
(TeX-region-file nil t)))
"\\)"
"\\("
- (mapconcat 'identity suffixes "\\|")
+ (TeX--clean-extensions-regexp arg)
"\\)\\'"
- "\\|" (regexp-quote (TeX-region-file t t))))
- (files (when regexp
+ "\\|" (regexp-quote (file-name-nondirectory
(TeX-region-file t t)))))
+ (files (when (and regexp (or (not master-dir) (file-exists-p
master-dir)))
(directory-files (or master-dir ".") nil regexp))))
(if files
(when (or (not TeX-clean-confirm)
@@ -2241,6 +2243,22 @@ output files."
(delete-file (concat master-dir file))))
(message "No files to be deleted"))))
+(defun TeX--clean-extensions-regexp (&optional arg)
+ "Return a regexp to match extensions that should be cleaned by `TeX-clean'.
+If the optional argument ARG is non-nil then output files are
+also included in the regexp."
+ (let* ((mode-prefix (TeX-mode-prefix))
+ (suffixes (and mode-prefix
+ (append (symbol-value
+ (intern (concat mode-prefix
+
"-clean-intermediate-suffixes")))
+ (when arg
+ (symbol-value
+ (intern (concat mode-prefix
+
"-clean-output-suffixes"))))))))
+ (when suffixes
+ (mapconcat 'identity suffixes "\\|"))))
+
;;; Master File
(defcustom TeX-master t
@@ -2406,10 +2424,19 @@ name of master file if it cannot be determined
otherwise."
;; Otherwise drop it.
(setq name (TeX-strip-extension name))))
- ;; Remove directory if needed.
- (if nondirectory
- (setq name (file-name-nondirectory name)))
-
+ (let* ((reg (TeX--clean-extensions-regexp t))
+ (is-output-ext (and reg
+ (or (string-match-p reg (concat "."
extension))
+ (string= "prv" extension))))
+ (output-dir (and is-output-ext
+ (TeX--master-output-dir
+ (file-name-directory name)
+ nondirectory))))
+ (if output-dir
+ (setq name (concat output-dir (file-name-nondirectory name)))
+ ;; Remove directory if needed.
+ (if nondirectory
+ (setq name (file-name-nondirectory name)))))
(if extension
(concat name "." extension)
name))))
@@ -2494,6 +2521,50 @@ be relative to that."
:group 'TeX-file
:type 'string)
+(defcustom TeX-output-dir nil
+ "The path of the directory where output files should be placed.
+
+A relative path is interpreted as being relative to the master
+file in `TeX-master'. The path cannot contain a directory that
+starts with '.'. If this variable is nil, the output directory is
+assumed to be the same as the directory of `TeX-master'."
+ :group 'TeX-file
+ :safe 'string-or-null-p
+ :type '(choice (const :tag "Directory of master file" nil)
+ (string :tag "Custom" "build")))
+(make-variable-buffer-local 'TeX-output-dir)
+
+(defun TeX--master-output-dir (master-dir relative-to-master)
+ "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."
+ (when TeX-output-dir
+ (let* ((master-dir (expand-file-name (or master-dir "")))
+ (out-dir (file-name-as-directory
+ (abbreviate-file-name
+ (substitute-in-file-name
+ (expand-file-name
+ TeX-output-dir
+ master-dir))))))
+ ;; Make sure the directory exists
+ (unless (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)
+ out-dir))))
+
+(defun TeX--output-dir-arg (argname)
+ "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)))
+ (if out-dir
+ (concat argname "\"" out-dir "\"")
+ "")))
+
(defcustom TeX-style-local "style"
"Directory containing hand generated TeX information.
@@ -2505,7 +2576,7 @@ be relative to that."
(defun TeX-split-string (regexp string)
"Return a list of strings.
Given REGEXP the STRING is split into sections which in string was
-seperated by REGEXP.
+separated by REGEXP.
Examples:
-----------------------------------------------------------------------
hooks/post-receive
--
GNU AUCTeX
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [AUCTeX-diffs] GNU AUCTeX branch, tex-build-only, created. 094c29862190290832e60872c2ab1442a27bdba5,
Al Haji-Ali <=