Subject: Re: bug#39927: 12.2; preview-latex gs treatment off by one

From: [email-masked]
Date: Mon, 9 Mar 2020 13:11:58 +0100 (CET)

That doesn't seem right.  GS> means that Ghostscript is waiting for
input.  GS<1> means that Ghostscript is waiting for input and there is
one item left on its stack (which is where PostScript passes data
around).  I don't think that this should regularly be the case.

-- 
David Kastrup

[[[     Not sure if it is important, but I am using Debian, which sets preview-image-type to 'dvipng   ]]]

Well, I never pretended to understand the first thing about how gs operates, I am just making observations...
Here is the output of some debugging messages : printing the gs prompt and a directory listing for the preview dir.

Type ‘C-c C-l’ to display results of compilation.
locating previews...
Type ‘C-c C-l’ to display results of compilation.
GS>
("." ".." "preview.dsc")
GS>
("." ".." "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "pr1-7.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "pr1-7.png" "pr1-8.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "pr1-7.png" "pr1-8.png" "pr1-9.png" "preview.dsc")

This was with preview-gs-outstanding-limit = 2.  With 5 and preview-image-type set to 'png I get the same general behaviour :
Type ‘C-c C-l’ to display results of compilation.
locating previews...
Type ‘C-c C-l’ to display results of compilation.
GS>
("." ".." "preview.dsc")
GS>
("." ".." "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "pr1-7.png" "pr1-8.png" "pr1-9.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "pr1-7.png" "pr1-8.png" "pr1-9.png" "preview.dsc")
GS<1>
("." ".." "pr1-1.png" "pr1-2.png" "pr1-3.png" "pr1-4.png" "pr1-5.png" "pr1-6.png" "pr1-7.png" "pr1-8.png" "pr1-9.png" "preview.dsc")
Mark set

So notwithstanding what GS thinks its prompts mean, it looks from where I am that I can take GS<1> for "image is ready".

Of course if you have a better solution / understanding of what is happening I am eager to learn.  In any case the bug I reported is real and this looks like a solution.

All the best,
Itaï.