Subject: bug#35363: 12.1.2; Generation of previews fails under Windows 10

From: Ikumi Keita <[email-masked]>
Date: Sun, 28 Apr 2019 22:19:48 +0900

Hi Bernt and Arash,

>>>>> Arash Esbati <[email-masked]> writes:
> Bernt Guldbrandtsen <[email-masked]> writes:
>> Recently, generating previews under AUCTeX started to fail. Until some months ago,
>> I had a working setup.  The OS is Windows 10 (updated). A minimal working
>> example is shown below. Running LaTeX on _region_.tex works and the PDF
>> file produced contains the expected content. However, running gs fails
>> with no diagnostics.
>> 
>> The machine has MiKTeX's mgs and "normal" gswin64 installed. At the
>> Cygwin command prompt both can run the conversion successfully. MiKTeX
>> (64 bit version) is updated and has mgs version 9.25. Ghostscript (64
>> bit version) is updated and is version 9.27.
>> 
>> In Emacs,
>> 
>> M-! mgs
>> 
>> and
>> 
>> M-! gswin64
>> 
>> find mgs and gswin64 respectively as expected.
>> 
>> A command such as
>> 
>> mgs -dDELAYSAFER -sDEVICE=png16m -dPrinter -dNOPLATFONTS
>> -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -o 'pic-%d.png'
>> _region_.pdf
>> 
>> produces the expected png output file.
>> 
>> It looks like mgs fails to run at all despite that Emacs is able
>> to find mgs.exe correctly.
>> 
>> Any pointers?

> Hi Bernt,

> thanks for the report.  I tried your example and it works for me:

I think that the reason of the fail is due to, at least partially, the
log format which MiKTeX produces.

-------- Bernt's log (by MikTeX) --------
...
region_.tex:9: Preview: Snippet 1 started
Preview: Tightpage -32891 -32891 32891 32891
_region_.tex:11: Preview: Snippet 1 ended.(1609687+0x22609920)
...
-----------------------------------------

-------- my log (by TeXLive) ------------
...
./tst-prv.tex:6: Preview: Snippet 1 started.
<-><->
      
l.6 \begin{displaymath}
                       
Preview: Tightpage -32891 -32891 32891 32891
./tst-prv.tex:8: Preview: Snippet 1 ended.(1609687+0x22609920).
<-><->
...
-----------------------------------------

Compare the absence and presence of periods at the end of line of the
sentences "Snippet 1 {started,ended}".  Preview-latex searches in the
log message, in the function `preview-parse-messages', with the
following regular expression, which requires the period at the end of
line:
\\(?:Preview\\|Package Preview Error\\): Snippet \\([---0-9]+\\) \\(started\\|ended\\(\
\\.? *(\\([---0-9]+\\)\\+\\([---0-9]+\\)x\\([---0-9]+\\))\\)?\\)\\."

In addition, Bernt's log lacks the information where to put the image in
the latex document buffer, which is embedded in my log as the line
l.6 \begin{displaymath}

Due to these two, at least, reasons, preview-latex cannot pick up
necessary information from the log messages.  I guess that MikTeX
costomizes the log output format of latex.  If this guess is correct, it
would necessary for MikTeX to discard that customize in order to use
preview-latex with MikTeX.

Best regards,
Ikumi Keita