Subject: Re: bug#31685: 12.1.1; Preview with cached preamble fails with lualatex engine and filenames with spaces

From: Ikumi Keita <[email-masked]>
Date: Tue, 05 Jun 2018 03:01:39 +0900

Hi all,

>>>>> jfbu <[email-masked]> writes:

> 1. the cached format can not be generated

> Running `Preview-LaTeX' on `abc def ghi' with ``lualatex -ini -interaction=nonstopmode "&lualatex" prv_abc_def_ghi.ini \ def\ ghi  -file-line-error   "\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}" "\input" \"abc\ def\ ghi.tex\"''

> notice that the above is ill-formed (see \ def\ ghi -file-line-error) bit

During the personal correspondence between Jean and me, we reach a
resolution.  First of all, Jean kindly provided a new .ini code which
enables preamble cache with unusual file name for not only lualatex, but
also platex and uplatex!  This makes platex and uplatex to be able to
use preamble cache even with file names with space.  (This case caused
error before; That's independent of my recent commits.)

Next, he found out that an option -file-line-error is necessary in
`preview-undump-replacements' for lualatex to use preamble cache on file
name with space.

In addition, it turned out that -kanji option of platex cannot be
omitted even when dumping format file if the preamble contains Japanese
characters.

I combined the due change to cope with these issues and made up the
attached patch.  It dismisses the additional post process of
the command line string in `TeX-inline-preview-internal' to the effect
of not leaving unnecessary fragments in the command line string when
file name with space is used with lualatex.

----------------------------------------------------------------------
However, I'm puzzled now by very weird emacs 26 behavior.  Currently, I
cannot sort out regression test yet.  On my environment, simple test
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(require 'ert)

(ert-deftest weird-cond ()
  "check for `cond'"
  (should
   (equal (xyz t)
	  2)))

(defun xyz (arg)
  "dummy"
;    (cond ((eq arg nil) ; OK
;    (cond ((eq arg 'abc) ; OK
;    (cond ((eq arg 'def) ; OK
    (cond ((eq arg 'default) ; NG
;    (cond ((eq arg 'default1) ; OK
	   1)
	  (t
	   2)))

(byte-compile 'xyz)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fails; i.e., after evaluating these forms, M-x ert RET RET fails on
emacs 26.1.  Does this reproduce with others?
0. Because of this behavior, `LaTeX-includegraphics-extensions' in
   tests/latex/latex-test.el doesn't pass "make check" with emacs 26.1.
1. As the commens in the above suggests, only the symbol `default'
   triggers this behavior.
2. Emacs 25.3 doesn't have this problem.
3. If `xyz' is not byte compiled, the test does pass.
4. It seems that the following entry in NEWS is related:
** Certain cond/pcase/cl-case forms are now compiled using a faster jump
table implementation.  This uses a new bytecode op 'switch', which
isn't compatible with previous Emacs versions.  This functionality can
be disabled by setting 'byte-compile-cond-use-jump-table' to nil.
   If I replace the last line in the above example with
(let ((byte-compile-cond-use-jump-table nil))
  (byte-compile 'xyz))
, the test does pass.
----------------------------------------------------------------------

> 2. even the fallback of not using cached preamble fails  (see bug #31684)

Though I haven't examined this issue yet, I guess that preview-latex
assumes that fallback run always produces dvi file.  In actual, pdf
file is produced in this case:
> Output written on abc def ghi.pdf (1 page, 8584 bytes).
> Transcript written on "abc def ghi.log".

Therefore dvipng fails:
> TeX Output exited as expected with code 1 at Sat Jun  2 14:03:07
> Running `Preview-DviPNG' with ``dvipng -picky -noghostscript abc\ def\ ghi.dvi -o "abc\ def\ ghi.prv/tmp14898GFt/prev%03d.png"  -D186 ''
> Parser: End of Preview snippet 1 unexpected

> Preview-DviPNG killed: 9 at Sat Jun  2 14:03:07

Regards,
Ikumi Keita