Subject: bug#25276: Typeset LaTeX files with non-ascii file name in TeXLive 2018

From: Ikumi Keita <[email-masked]>
Date: Mon, 28 May 2018 16:48:36 +0900

Hi all,

As discussed earlier in messages separately, I made out a fix much
better than the previous proposal.  Any opinions are welcome for this
new proposal.

It keeps the ability to let the users to have their own TeX codes on the
command line while it doesn't use \input when it isn't necessary.
Therefore, the bugs
- LaTeX version banner is missing in the log file [1]
- first line parsing is not effective [2]
- file name with space doesn't typeset with w32 xelatex (Bug#25276)
disappear except when TeX codes are present on the command line.

Standard LaTeX without e-TeX extension, which exists in only very old
distribution at least for TeXLive, will no longer work in the
following cases:
- region compilation of non-ascii file name
- preview-latex (even when file name doesn't contain non-ascii chars)

I found out that the current AUCTeX has a basic functionality of such
on-demand supply of \input already implemented, but it isn't activated
accidentally by a subtle inconsistency.  It can be released by the
following tiny change:
----------------------------------------------------------------------
diff --git a/tex.el b/tex.el
--- a/tex.el
+++ b/tex.el
@@ -499,7 +499,8 @@
     ("%s" file nil t)
     ("%t" file t t)
     ("%`" (lambda nil
-	    (setq TeX-command-pos t TeX-command-text "")))
+	    (setq TeX-command-pos t TeX-command-text nil)
+	    ""))
     (" \"\\" (lambda nil
 	       (if (eq TeX-command-pos t)
 		   (setq TeX-command-pos pos
----------------------------------------------------------------------
With this change, the command line becomes
     pdflatex -someoption FILENAME
for most cases, but if some TeX codes are requested (by users' intention
through `TeX-command-extra-options' or expansion of %(PDFout) to
" \"\\pdfoutput=0 \"", or run in preview-latex), the form
     pdflatex -someoption \TeX_code \input FILENAME
is retained.

My new patches extend this functionality naturally to supply \detokenize
in the latter case, necessary to typeset non-ascii FILENAME.  It also
adds codes to support first line parsing in region compilation.

Although each changes are small, they accumlate to some amount in
total.  Thus I split the changes into three patches.  They are attached
below.

The first patch fixes the bug which has been there even before TL 2018.
If \usepackage[utf8]{inputenc} is present in standard LaTeX, non-ascii
file names in \message{} didn't work as expected in region compilations.

The second patch is the main fix.  It implements most of the changes
mentioned above.  As a minor additional improvement, the users will be
able to put their own TeX codes through `TeX-command-extra-options' for
not only "LaTeX" but also "TeX" and "AmSTeX".

The third patch is a fix for preview-latex to support non-ascii file
names in TL2018.  The TeX codes that enables preamble caching was
crafted by Jean-François.  I deeply thank him for his remarkable skill.

Regards,
Ikumi Keita

[1] https://lists.gnu.org/archive/html/auctex/2018-05/msg00003.html
[2] https://lists.gnu.org/archive/html/auctex/2018-05/msg00004.html