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

From: jfbu <[email-masked]>
Date: Fri, 8 Jun 2018 11:04:00 +0200

Hi Keita

Le 08/06/2018 à 07:02, Ikumi Keita a écrit :
> Hi Jean and all,
> 
>>>>>> jfbu <[email-masked]> writes:
>> 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
> 
> Confirmed.  It seems the reason is that `preview-dvipng-command'
> contains spurious quotes.  Various `preview-*-command' are defined as:
> (defcustom preview-dvipng-command
>    "dvipng -picky -noghostscript %d -o \"%m/prev%%03d.png\""
>    ...
> (defcustom preview-dvips-command
>    "dvips -Pwww -i -E %d -o %m/preview.000"
>    ...
> (defcustom preview-fast-dvips-command
>    "dvips -Pwww %d -o %m/preview.ps"
>    ...
> (defcustom preview-pdf2dsc-command
>    "pdf2dsc %s.pdf %m/preview.dsc"
>    ...
> .  They don't have quotes around %m except `preview-dvipng-command'.
> Removing the quotes makes dvipng works with file name with space on my
> side.
> 
> In addition, I noticed during test runs that single quotes in
> `preview-dvipng-color-string' choke dvipng on w32 platform because
> single quotes are not consumed by w32 shell (cmd.exe).
> 
> Could you please test the following patch?  (It is for preview.el.in in
> the source files, not for preview.el.)

I confirm problem is fixed at my locale for the MWE I posted initially:

(mac os x 10.9.5)

Here is transcript:

> ...
> (see the transcript file for additional information)
> Output written on "abc def ghi.dvi" (1 page, 1584 bytes).
> Transcript written on "abc def ghi.log".
> 
> TeX Output exited as expected with code 1 at Fri Jun  8 10:57:23
> Running `Preview-DviPNG' with ``dvipng -picky -noghostscript abc\ def\ ghi.dvi -o abc\ def\ ghi.prv/tmpDOwfcQ/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 Fri Jun  8 10:57:23

My testing does not extend to that part of your patch dealing with options
but I trust it does the right thing...

Best,

Jean-François