diff --git a/tex-buf.el b/tex-buf.el index 975c6fc9..49b53c81 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -551,15 +551,6 @@ without further expansion." "%")) (or list (TeX-expand-list))) pat (regexp-opt (mapcar #'car list))) - ;; `TeX-command-expand' is called with `file-fn' argument being one - ;; of `TeX-master-file', `TeX-region-file' and - ;; `TeX-active-master'. The return value of these functions - ;; sometimes needs suitable "decorations" for an argument for - ;; underlying shell or latex executable, or both, when the - ;; relavant file-fn name involves some special characters such as - ;; space and multibyte characters. Hence embed that function in a - ;; template prepared for that purpose. - (setq file-fn #'TeX--master-or-region-file-with-extra-quotes) (while (setq TeX-expand-pos (string-match pat TeX-expand-command TeX-expand-pos)) (setq string (match-string 0 TeX-expand-command) entry (assoc string list) @@ -567,9 +558,9 @@ without further expansion." arguments (cdr (cdr entry)) ;Remaining elements string (save-match-data (cond - ((memq expansion (list 'TeX-active-master - #'TeX-active-master)) - (let ((res (apply file-fn arguments))) + ((eq expansion #'TeX-active-master) + (let ((res (apply #'TeX--master-or-region-file-with-extra-quotes + file-fn arguments))) ;; Advance past the file name in order to ;; prevent expanding any substring of it. (setq TeX-expand-pos @@ -587,20 +578,29 @@ without further expansion." TeX-expand-command)) (defun TeX--master-or-region-file-with-extra-quotes - (&optional extension nondirectory ask extra) - "Return the current master or region file name with quote for shell. -I.e. it encloses the file name with space within quotes `\"' -first when \" \\input\" is supplemented (indicated by dynamically -binded variable `TeX-command-text' having string value.) It also -encloses 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\") - -Helper function of `TeX-command-expand'." + (file-fn &optional extension nondirectory ask extra) + "Return file name with quote for shell. +Helper function of `TeX-command-expand'. + +This is a kind of template. How to use: +Fix, by `apply-partially', the first argument FILE-FN as one of +the three functions `TeX-master-file', `TeX-region-file' or +`TeX-active-master'. Then the result is just a wrapper for that +function suitable in `TeX-command-expand'. + +As a wrapper described above, it passes EXTENSION, NONDIRECTORY +and ASK to the \"bare\" function as-is, and arranges the returned +file name for use with command shell. I.e. it encloses the file +name with space within quotes `\"' first when \" \\input\" is +supplemented (indicated by dynamically binded variable +`TeX-command-text' having string value.) It also encloses 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\")" (shell-quote-argument - (let* ((raw (funcall #'TeX-active-master extension nondirectory ask)) + (let* ((raw (funcall file-fn 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)