Function: TeX-active-master-with-quotes
TeX-active-master-with-quotes is a byte-compiled function defined in
tex.el.
Signature
(TeX-active-master-with-quotes &optional EXTENSION NONDIRECTORY ASK EXTRA PREPROCESS-FN)
Documentation
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
quotes " when " \\input" is supplemented (indicated by
dynamically bound variable TeX-command-text having string
value.) Also enclose the file name within \detokenize{} when
the following three conditions are met:
1. compiling with standard (pdf)LaTeX or upLaTeX
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.
If PREPROCESS-FN is non-nil then it is called with the filename
as an argument and the result 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(var)/TeX-expand-list(fun).
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-active-master-with-quotes
(&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
quotes `\"' when \" \\input\" is supplemented (indicated by
dynamically bound variable `TeX-command-text' having string
value.) Also enclose the file name within \\detokenize{} when
the following three conditions are met:
1. compiling with standard (pdf)LaTeX or upLaTeX
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'.
If PREPROCESS-FN is non-nil then it is called with the filename
as an argument and the result 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'."
(let* ((raw (TeX-active-master extension nondirectory ask))
;; String `TeX-command-text' means that the file name is
;; given through \input command.
(quote-for-space (if (and (stringp TeX-command-text)
(string-match " " raw))
"\"" ""))
(res
(shell-quote-argument
(format
(if (and extra
(stringp TeX-command-text)
(memq major-mode '(LaTeX-mode docTeX-mode))
(memq TeX-engine '(default uptex)))
;; 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.
;; c.f. LaTeX News issue 28
;; Due to this change, \detokenize is required to
;; recognize non-ascii characters in the file name
;; when \input precedes.
"\\detokenize{ %s }" "%s")
(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
(+ TeX-expand-pos (length res)))
res))