[OS X TeX] Flashmode for Emacs : Whizzytex + Enrico Franconi's Carbon Enhanced Emacs + TeXniscope

Joachim Kock jkock at ya.com
Sat Apr 9 11:19:01 CEST 2005


And here are some comments on the whizzytex instructions, with some
technical comparison to the Alpha script.


> Whizzytex opens up a previewer and compiles a certain region of your
> document, the so-called "slice" on-the-fly. In other words, every word
> or symbol that you enter into your emacs buffer appears in the
> previewer - almost instantaneously. On my outdated 800 Mhz i-book the
> delay is about 3-4 seconds ( when using TeXnscope; with advi, it's a
> little faster)

For the flashmode plugin for Alpha, the delay is about 1 second for
TeXniscope, and around 0.7 seconds for xdvi.  This is measured on an
iBook 500MHz G3.


> a compilation of a large document of about 70 pages with lots of 
> commutative diagrams (xypic) took at least 15 seconds (when 
> issuing the command to compile from an xterm; from within emacs, 
> it took even longer ( why ?)).

This is strange.  The terminal is known for having slow graphics, so that
one bottle-neck is actually writing the tex messages on the screen!
This is particularly articulate on computers without Quartz Extreme.
On this iBook 500 MHz, running tex from within Alpha is 10-20 percent
faster than running in the terminal.  There have been several 
testimonies of this sort on this list and on the AlphaTcl-users list.

> (1) usually tetex has to load all the packages etc specified in the
> preamble each time you compile the document; whizyytex has to read/load
>   the preamble at the beginning of the whizzytex-run only once;

The Alpha flash script too uses initex to precompiles the preamble.  While
this is not important for long documents, it's an important time saver for
short documents or fragments of documents.

> (2) whizzytex compiles only the current "slice" of the document; the
> slice can be the whole document, the chapter, section, subsection,
> paragraph ... I am using the paragraph mode : one paragraph ends and a
> new one begins where there are two empty lines in the emacs buffer.

(Two empty lines?  Usually tex needs only one empty line to delimit a
paragraph.)  The Alpha script uses paragraphs as slices when the 
partial-flash flag is set.  There is currently no support for other
slice sizes, but that's just because the script was proposed as a proof of 
concept.  It would be easy to implement support for other slice sizes.


> What kind of previewers are available ?
> advi , xdvi, gv, xpdf and TeXniscope.

The Alpha script works with xdvi or with TeXniscope.  It's a slightly
different script for TeXniscope: 
http://mat.uab.es/~kock/alpha-tcl/flashTeXniscope.tcl.gz


> Next, you need to install whizzytex.

...  followed by descriptions of setting compile parameters and doing
'make' and 'make install'.  And instructions for handling PATH, and
execute permissions and so on.  About one page of instructions...

All this is unnecessary with the Alpha script which is interpreted, not
compiled.  And it is run by Alpha's embedded Tcl interpreter, where it has
access to all sorts of internal variables and can react directly on
internal events, e.g. a character typed in the tex source window.

The fact that it is interpreted and not compiled doesn't seem to make 
a difference in speed -- in fact it seems to be faster.  The main speed
gain comes from relying on notification instead of polling.  (For more 
technical details, see the comments in the script itself.)


> Now add the following to your default preamble :
> The first lines should be ( each should be on one line) :
> 
> %%; whizzy paragraph -pdf "xpdf -bg black -fg blue -g 1025x900 -z 170
> -remote $$" -initex "pdflatex -ini" -latex  pdflatex
> %; whizzy paragraph -advi advi -A -html Start-Document -(perhaps you
> like -rv) -geometry 1025x900 -initex "pdflatex -ini" ( or just "latex
> -ini") -latex pdflatex (or just latex)
> %%; whizzy paragraph -dvi xdvi -expert -rv -s 5 -fullscreen -offsets 0
> %%; whizzy paragraph -ps "gv ..."

An important principle of the flash script in Alpha is that no alterations
are required in the tex documents, and that the script never writes to your
tex document or saves it for you or anything.  In this way the document
remains *yours* and you have complete control over it.


> Since all of the previewers (advi,xdvi,gv,xpdf) use X11, and since
> somehow whizzytex requires communication between X11 and emacs back and
> forth, it seems that the only way for whizzytex to work is by doing the
> following :
> 
> -open an xterm.
> -type "/Applications/Emacs.app/Contents/Resources/sitelisp/emacs"
> 
> This will open up Enrico Franconi's Carbon Enhanced Emacs but - this is
> crucial- this emacs process will be a "child process" of the xterm
> shell.

This looks like a strange shortcoming.  Does it mean that if you suddenly
decide to use flash for some minutes you have to restart emacs from the 
xterm?!  In Alpha, the viewer is the child process, but this does not mean
that you cannot have xdvi open in advance, because as explained the new
view job is completely independent of what else you might be doing with
your tex and dvi files.


> If you want, you can change the AutoRefresh Interval of TeXniscope to
> 1.0 seconds by opening a Terminal and typing
> 
> defaults write TeXniscope AutoRefreshInterval 1.0

An important speed feature of the Alpha script is that it does not work by
polling but by notification.  This means that the various involved
components do not have to ask each other at intervals if it is their turn
to do their job.  These waiting times quickly add up.  Instead each
component notifies the relevant next component, so that there is never any
unnecessary waiting time.  So for example, instead of having TeXniscope
autorefresh at every 0.6 second (this means an average waste of time of 0.3
seconds for every flash cycle!), send it an explicit 'refresh' Apple Event
when the pdf file is ready.  And instead of checking at intervals if the
buffer has been modified (or running a new tex run blindly on a file that
has not been modified) set up a hook that detects buffer modification, and
activate the next flash cycle precisely when needed.


Cheers,
Joachim.


--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list