Subject: bug#31684: 12.1.1; Preview-DviPNG fails with filename having spaces (DviPS is used as fallback)

From: jfbu <[email-masked]>
Date: Sat, 2 Jun 2018 13:53:21 +0200

Hi,

consider this file

---- start
\documentclass{article}
\def\abc{abc}
\begin{document}
$\abc$
\end{document}
---- stop

With default engine (pdftex):

Experience 1: name it as abcdefghi.tex.
Switch to DVI mode. (C-cC-tC-p as PDF mode is ON by default)
Ask to generate previews for all document.
Answer YES to "Cache preamble?"
It works.

Experience 2: name it as abc def ghi.tex (so it includes spaces in filename)
Switch to DVI mode
Ask to generate previews for all document.
Answer YES to "Cache preamble?"
It **appears to work** but in fact it doesn't: 

....
Running `Preview-DviPNG' with ``dvipng -picky -noghostscript abc\ def\ ghi.dvi -o "abc\ def\ ghi.prv/tmp14749czs/prev%03d.png"  -D186 ''
This is dvipng (dvipng (TeX Live)) 1.15 Copyright 2002-2015 Jan-Ake Larsson
[1 (preview-latex version 12.1) (preview-latex tightpage option detected, will use its bounding box)
dvipng: Fatal error, cannot open output file abc\ def\ ghi.prv/tmp14749czs/prev001.png

Preview-DviPNG exited abnormally with code 2 at Sat Jun  2 13:44:48
Running `Preview-DviPS' with ``dvips -Pwww abc\ def\ ghi.dvi -o abc\ def\ ghi.prv/tmp14749p9y/preview.ps''
...

So the preview was generated but using ghostscript as a fallback.

In the case with no spaces the process output buffer contains this

....
TeX Output exited as expected with code 1 at Sat Jun  2 13:50:37
Running `Preview-DviPNG' with ``dvipng -picky -noghostscript abcdefghi.dvi -o "abcdefghi.prv/tmp14749bHC/prev%03d.png"  -D186 ''
This is dvipng (dvipng (TeX Live)) 1.15 Copyright 2002-2015 Jan-Ake Larsson
[1 (preview-latex version 12.1) (preview-latex tightpage option detected, will use its bounding box)] 

Preview-DviPNG finished at Sat Jun  2 13:50:37
....

This is with stock AUCTeX 12.1.1.

Jean-François