Hi Keita
(still top-posting)
I have an "in principle" solution, although it will look a bit complicated.
First I will explain proof of principle, then concrete implementation.
I hope you can incorporate that in AUCTeX.
STEP I: generation of format.
I will explain first the proof of principle and later how to make in practice.
Imagine we can make sure the preamble of our document is like
in this file :
---- primárias.tex
\documentclass{article}
\catcode`/ 0
\def\AUCTEXINPUT#1{\catcode`/ 12\relax\input{\detokenize{#1}}}
\begin{document}
Hello
\end{document}
----
Generate format via this kind of invocation: (bash shell)
etex -ini \&pdflatex mylatex.ltx {\\detokenize{testmylátex.tex}}
STEP II. Use of format.
This will go via this kind of invocation: (bash shell)
pdflatex \&mylatex /AUCTEXINPUT{testmylátex.tex}
It works in my testing.
Now this was proof of principle.
How to insert the special code
\catcode`/ 0
\def\AUCTEXINPUT#1{\catcode`/ 12\relax\input{\detokenize{#1}}}
?
We need it to make it into the format. This is where the kind of
hack you reported as already present in AUCTeX can be used.
It was
\ifx\pdfoutput\undefined\else\let\PREVIEWdump\dump\def\dump{%
\edef\next{{\catcode`\ 9
\pdfoutput=\the\pdfoutput\relax\the\everyjob}}\everyjob\next\catcode`\ 10
\let\dump\PREVIEWdump\dump}\fi\input mylatex.ltx \relax
I am not sure why this, but anyway the point is that \dump is the last thing
executed by \begin{document} when mylatex.ltx is in use to generate a format.
So the above hacks \dump. We can hack it too to insert what we want from above.
Putting altogether :
1. We need file prv_testmylátex.ini to be
\ifx\pdfoutput\undefined\else\let\PREVIEWdump\dump\def\dump{%
\edef\next{{\catcode`\ 9 \pdfoutput=\the\pdfoutput\relax\the\everyjob}}%
\everyjob\next\catcode`\ 10 %
\catcode`/ 0 %
\def\AUCTEXINPUT##1{\catcode`/ 12\relax\input{\detokenize{##1}}}%
\let\dump\PREVIEWdump\dump}\fi\input mylatex.ltx \relax%
REMARK: the above hack of \dump is conditional on \pdfoutput being
defined which I think is good anyhow. \pdfoutput is defined for
pdflatex whether dvi or pdf output.
2. We create the format with this incantation
etex -ini -jobname prv_testmylátex "&pdflatex" "\input{\detokenize{prv_testmylátex.ini}}"
"\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}"
"\input{\detokenize{testmylátex.tex}}"
the following less paranoid version (I don't wrap the name of ini file in
\detokenize) seems to work too
etex -ini -jobname prv_testmylátex "&pdflatex" prv_testmylátex.ini
"\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}"
"\input{\detokenize{testmylátex.tex}}"
The detokenize at the end is really needed. (Or we could play the other games
with \UseRawInputEncoding)
3. We then use the format with this incantation
pdflatex -fmt="prv_testmylátex.fmt" /AUCTEXINPUT{testmylátex.tex}
It works in my testing in Terminal on Mac OS X (bash shell)
(I tested it with /AUCTEXINPUT{some other file with non-ascii filename}
to check macros defined in the preamble of testmylátex.tex are actually
used, proving the created format was indeed used).
And by the way, yes you were right about mylatex.ltx \relax, then it
uses .tex with no extra setting needed.
Best
Jean-François
Le 23/05/2018 à 21:38, jfbu a écrit :
Hi Keita
first-off let me apologize for my numerous posts,
originating from someone like myself who
- does not know preview,
- does not know elisp,
- does not know auctex,
- does not know mylatex.ltx...
- ... and is going to top-post
I appreciate a lot your detailed explanations,
which avoid me plunging into auctex sources.
I have now made some experiments which show there
is a problem to solve at "mylatex.ltx" level.
Consider this source
----
\documentclass{article}
\def\foo{foo}
\begin{document}
Checking format was used:
\ttfamily\meaning\foo
\end{document}
----
### Experiment One:
1. save above as testmylatex.tex
2. execute etex -ini \&pdflatex mylatex.ltx testmylatex.tex
3. execute pdftex -fmt=mylatex testmylatex
everything should go fine, and then testmylatex.pdf will contain
Checking format was used:
macro:->foo
### Experiment Two
1. save above file as testmylátex.tex
2a. Try pdflatex testmylátex.tex : it works
2b. Try now: etex -ini \&pdflatex mylatex.ltx testmylátex.tex
It fails with
! I can't find file `testmyl'.
<to be read again>
\global
<*> &pdflatex mylatex.ltx testmylá
tex.tex
(Press Enter to retry, or Control-D to exit)
(attention that á especially on Mac OS may be with a combining character
so your mileage my vary in the error report)
3a. The format file mylatex.fmt from Experiment one should still be there
so we try
pdflatex -fmt=mylatex testmylátex.tex
(recall that pdflatex testmylátex.tex worked out of the box)
It fails with
! I can't find file `testmyl'.
<to be read again>
\unhbox
<*> testmylá
tex.tex
(Press Enter to retry, or Control-D to exit)
Now try
pdflatex -fmt=mylatex "\input{\detokenize{testmylátex.tex}}"
It fails with the kind of error message you reported
$ pdflatex -fmt=mylatex "\input{\detokenize{testmylátex.tex}}"
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded
format=mylatex)
restricted \write18 enabled.
entering extended mode
(/usr/local/texlive/2018/texmf-dist/tex/latex/tools/.tex
LaTeX2e <2018-04-01> patch level 4
CUSTOMISED FORMAT. Preloaded files:
.
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
.
)
Runaway argument?
! File ended while scanning use of ^^M.
<inserted text>
\par
<*> \
input{\detokenize{testmylátex.tex}}
?
All of the above problems are with "mylatex.ltx".
I think creating a file and using `\input` form might help
The doc says
%%% If you are on a Mac or using some shell that makes it inconvenient
%%% to use a command line such as the above examples then you may
%%% make a file `mylatex.tex' with the single line
%%% \input mylatex.ltx abc
%%% and then pass the file mylatex.tex to your (ini)tex shell to produce
%%% the format, ie something equivalent to initex &latex mylatex.tex.
and perhaps this can be used to solve our problems.
I can't work immediately on this but will later,
(or David Carlisle will show up and explain what to do)
Best,
Jean-François
Le 23/05/2018 à 20:12, Ikumi Keita a écrit :
Hi Jean,
jfbu <j...@free.fr> writes:
no bothering at all!
Perhaps I should give up this particular case (non-ascii file name +
preview-latex preamble cache) and commit the patch which fixes other
issues.
surely not!
Thank you!
What would helped me is to see the exact content of an ini file.
It is designed to be deleted automatically after the format file dump,
so I modified `preview-cache-preamble' temporarily not to delete it.
The content thus obtained is:
\ifx\pdfoutput\undefined\else\let\PREVIEWdump\dump\def\dump{%
\edef\next{{\catcode`\ 9
\pdfoutput=\the\pdfoutput\relax\the\everyjob}}\everyjob\next\catcode`\ 10
\let\dump\PREVIEWdump\dump}\fi\input mylatex.ltx \relax
Then it is intriguing that the comment says
"mylatex.ltx expects a file name to follow. Bad."
and refers to empty file ".tex" but I see mylatex.ltx \relax not mylatex.ltx
.tex ??
I don't know well, but the log at the dumping says
(/usr/local/texlive/2018/texmf-dist/tex/latex/carlisle/mylatex.ltx)
(/usr/local/texlive/2018/texmf-dist/tex/latex/tools/.tex File ignored))
so I think it really reads ".tex".
----
about this ".tex" it was missing from TeXLive for a while due to a LaTeX
packaging
error but is since fixed
https://github.com/latex3/latex2e/issues/30
----
Yes, I had updated with tlmgr and restored ".tex" already.
It might take some time until I can say something about preview's
mechanism, as I am not even that familiar to its usage. I hope
David can kick in, that would be so much faster.
I hope so as well.
I anticipate the role of the format is to catch up some common preamble,
These two paragraphs are quotes from preview-latex.info:
----------------------------------------------------------------------
'C-c C-p C-f'
'preview-cache-preamble'
Preview/Turn preamble cache on
Dump a pregenerated format file. For the rest of the session, this
file is used when running on the same master file. Use this if you
know your LaTeX takes a long time to start up, the speedup will be
most noticeable when generating single or few previews. If you
change your preamble, do this again. preview-latex will try to
detect the necessity of that automatically when editing changes to
the preamble are done from within Emacs, but it will not notice if
the preamble effectively changes because some included file or
style file is tampered with.
----------------------------------------------------------------------
* Automatically cache preambles
Currently preview-latex asks you whether you want to cache the
document preamble (everything before '\begin{document}') before it
generates previews for a buffer the first time. Caching the
preamble will significantly speed up regeneration of previews. The
larger your preamble is, the more this will be apparent. Once a
preamble is cached, preview-latex will try to keep track of when it
is changed, and dump a fresh format in that case. If you
experience problems with this, or if you want it to happen without
asking you the first time, you can customize the variable
'preview-auto-cache-preamble'.
----------------------------------------------------------------------
I hope these help.
and the file primárias.tex should not be used here.
I think the basic idea is to "embed" the particular document's preamble
in the format file for efficiency, so I suppose that it is essential to
input the document file (primárias.tex here).
And "\input" "\detokenize{primárias.tex}" should be either
"\expandafter\input" "\detokenize{primárias.tex}"
or
"\input" "{\detokenize{primárias.tex}}"
OK, I'll change the relavant code accordingly.
PS: I am CCing to auctex-dev but it seems my messages get bounced
Sorry, I misspelled the address in my previous message. The right
address is "auctex-de...@gnu.org", not "auctex-dev@...".
Best regards,
Ikumi Keita
_______________________________________________
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex
_______________________________________________
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex