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

Philipp Mathey pmathey at uwo.ca
Wed Apr 6 19:33:23 EDT 2005


Hello,

I thought it might be of interest to some if I described my current 
setup : I am using Gerben Wierda's teTeX together with Enrico 
Franconi's Carbon Enhanced Emacs. The emacs  major mode I am using is 
UltraTeX ( it provides a so-called lightning completion mode on latex 
commands and other useful features).  UltraTeX is probably intended for 
people doing math or physics.  In addition, I am using a minor mode  
called WHIZZYTEX . Whizzytex provides a flashmode for emacs ( I have 
never seen Textures so I don't know what it looks like).
I was able to get whizzytex to work together with TeXniscope as the 
previewer.

What exactly does whizzytex do ? The way it works is this. At the 
beginning of your emacs session you load whizzytex with "M-x 
whizzytex-mode" , afterwards you can reactivate it with "C-c w". 
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)

The nice thing about whizzytex is that no matter how large your 
document is and even with a fairly slow processor you don't have to 
wait any longer for the compilation to finish. My original motivation 
for using whizzytex was this : 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 ?)). I found this annoying. 
With whizzytex, it takes only a few seconds. Moreover, you don't have 
to save the document before recompilation.  However, every time you do 
save the emacs buffer, the whole document is automatically recompiled.
So for all of you who are not satisfied with the speed of 
tex-compilations on your machines, whizzytex might be of interest.  Two 
reasons for the dramatically shorter compile time I can think of are

(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;

(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.
I changed the default to 4 empty lines. In this way you can easily 
organize the text in your emacs-buffer into 'paragraphs' (separated by 
4 empty lines) such that each paragraph is not too long.
-
but there be may be other reasons having something to do with the 
specific way in which whizzytex analyzes the contents of the slice and 
keeps track of changes to the slice.


What kind of previewers are available ?

advi , xdvi, gv, xpdf and TeXniscope.


Using it with advi/xdvi/gv/xpdf :


The default previewer for which whizzytex was specifically written is 
advi (dvi-viewer)
It also works with  xdvi, gv and (this is new) xpdf.

If you want to use advi, gv or xpdf, you should install them before 
installing whizzytex.
For

- advi : install the ocaml library via fink or darwinports, then 
download the advi package from
http://pauillac.inria.fr/whizzytex/ and follow the instrcutions ( you 
need to use ocaml to compile certain libraries) ( you might have to use 
the unstable branch of fink to get the latest ocaml)

-xdvi : is already installed

-gv:  i-package

-xpdf: via fink or darwinports.


Then go to http://pauillac.inria.fr/whizzytex/  and download the latest 
experimental whizzytex version. cd to the whizzytex directory and look 
what's inside.
  Whizzytex was written for linux, so in order to install it on MacOsX 
one needs to modify the Makefile.config file. I am not quite sure but 
perhaps you first have to create the Makefile.config file out of the 
Makefile.config.in file by typing "make menuconfig" . Whizzytex will 
run a little test to see whether your environment is set up correctly. 
Since at this point it is not, whizzytex will issue an error message. 
This will create the desired Makefile.config file. Now you type "sudo 
pico Makefile.config" to manually edit the file ( I forgot whether the 
sudo is necessary). You only have to modify one line : the first. You 
should have "PREFIX = /usr/loca/teTeX" ( I am assuming that you are 
using Gerben Wierda's teTeX). Then type "make all" and then "sudo make 
install".

The INSTALL file mentions that one should type "umask 022 make 
install". I have not tried this, but this might help to avoid some of 
the permission problems that I ran into later and which I will mention 
below.

Type

cd  ~
ln -s whizzytex-*.*.* whizzytex

This will create symbolic link from the whizzytex-version 
whizzytex-*.*.* which you installed to a directory called 'whizzytex'.

Be default, whizzytex will install the "whizzytex.el" lisp file in 
/usr/local/teTeX/share/whizzytex/emacs/ , so you should add the 
following to your .emacs file :

(setq load-path (cons "/usr/local/teTeX/share/whizzytex/emacs"
                              load-path))
(require 'whizzytex)

In addition, you should add to the .emacs file the line

(setq-default whizzy-viewers '(("-pdf" "xpdf" )("-advi" "advi") 
("-xdvi" "xdvi")("-ps" "gv")))

( assuming that all these previewers are installed; otherwise, make an 
intelligent adjustment)

Next open up an xterm or Terminal and type
cd
cd /Applications/Emacs.app/Contents/MacOS/bin/
mkdir ATH
cd
cd whizzytex
You will find a subdirectory called ATH and inside the whizzytex shell 
script.
cd ATH
cp  whizzytex /Applications/Emacs.app/Contents/MacOS/bin/ATH

This way the shell script "whizzytex" is in your PATH but you do not 
need to become root to copy it into the above location. You could move 
ATH/whizzytex somewhere else, e.g. into /usr/local/bin, but then you 
cannot edit it without becoming root.  Doing this and then running 
whizzytex causes emacs to complain that it cannot find ATH/whizzytex.
This is the permission problem mentioned earlier.
( editing whizzytex is only necessary if you want to use TeXniscope, 
see below)


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 ..."

Of course, the options for, say xpdf, are mine and you can modify them. 
  Notice that the advi line begins  with only one %,  the others with 
more than one. In this case, when you activate whizzytex, whizzytex 
will choose the advi previewer. A simple addition of an % to advi and 
the removal of an % from the xpdf line, will make xpdf the previewer. 
This way you don't have to edit your .emacs file in order to switch 
previewers.

Now you should be ready, finally.

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.
If you open up emacs by clicking on the emacs symbol in the Finder or 
in the dock, whizzytex won't work ( but it does work with TeXniscope, 
see below).

Open up some latex document, with the "%; whizzy ..."  lines included 
in the preamble, and then load whizzytex with "M-x whizzytex-mode" ( by 
the way, M is the meta-key i.e. the comand key; C is the control-key; 
it might be necessary for you to go to "X11 Preferences" and un-check 
the box "Enable key equivalents under X11"; otherwise, I believe, the 
meta key would be the escape key which would be inconvenient).

Whizzytex should open and it should work.... (hopefully)..

Advi has some rather nice features including syncronicity between the 
advi preview window and the emacs buffer, also a cool way to toggle the 
view of the slice and the whole document by pressing 'w' while advi is 
active.  I should have mentioned earlier that whizzytex has a feature 
called "duplex" ( C-c d) which opens up a view of the whole document, 
in addition to the slice.
For example, if you are looking at the slice and click on a hyperlink 
to a theorem or something which is located outside of the slice, 
clicking the link will  cause advi to jump to the corresponding place 
in the whole-document-window.


This is how I was using whizzytex until recently. However, I find that 
pdf files simply look much better than dvi files. The latest (March 
2005, version 1.2.2 or higher) version of whizzytex makes it possible 
to use xpdf as a previewer. I don't like xpdf very much but I do like 
TeXniscope .

So now I come finally to ..

Using TeXniscope as a previewer :

-first of all, install TeXniscope.

- ( this first step is optional and only necessary if you wish to edit 
whizzytex.el; I did so, because I wanted paragraphs to be separated by 
4 empty lines rather than the default 2)

open an xterm and type:

cd
cd /usr/local/teTeX/share/whizzytex/emacs
cp whizzytex.el ~

(This will create a whizzytex shell script in my home directory which I 
own so I can edit it)


Open ~/whizzytex .el ( say in emacs) and edit it as follows :

- In line 221 you should have
(defvar whizzy-paragraph-regexp "\n *\n *\n *\n *\n"

- in line 1352 you should have
(defvar whizzy-load-factor 10

( I am not quite sure this helps; this is supposed to be the maximal 
value possible determining the speed of 'slicing' -perhaps it doesn't 
make much of a difference; default value is 0.6)


Next you need edit to your .emacs file so that it contains the lines

(setq load-path (cons "/Users/yourname/" load-path))
(require 'whizzytex)

(setq-default whizzy-viewers '(("-pdf" 
"Applications/TeXniscope.app/Contents/MacOS/TeXniscope" )("-advi" 
"advi") ("-xdvi" "xdvi")("-ps" "gv")))

( on one line)


(assuming that whizzytex.el was copied into  your home directory ( in 
order to edit it)
If you didn't edit whizzytex.el, you should have

(setq load-path (cons "/usr/local/teTeX/share/whizzytex/emacs"
                              load-path))
(require 'whizzytex)

(setq-default whizzy-viewers '(("-pdf" 
"Applications/TeXniscope.app/Contents/MacOS/TeXniscope" )("-advi" 
"advi") ("-xdvi" "xdvi")("-ps" "gv")))

( on one line)


Next the whizzytex shell script needs to be edited. ( I am assuming now 
that you read through all of the above and followed the instructions. 
In particular, I am assuming that you created a directory ATH in 
/Applications/Emacs.app/ Contents/MacOS/bin/  into which you copied 
whizzytex . This will allow you edit whizzytex without becoming root.  
Of course, you could become root and edit it anyway, but then running 
whizzytex causes whizzytex to complain that it can't  find 
ATH/whizzytex. At least, that's what happened to me.
This is the permission problem I mentioned earlier. Anyway, what I am 
describing works. Open up  /Applications/Emacs.app/ Contents/MacOS/bin/ 
whizzytex , best in emacs, and modify it as follows :


- around line 166, set DUPLEX to false
(maybe it was set to false by default- I don't remember)
I.e. you should have

-pdf)
      LEVEL=1
      DVI=pdf
.....
      FMT=fmt
      DUPLEX=false
   ....


-  in line 658 or thereabouts  you find a passage that looks like this :

....
echo '# End of command' ) >> "OUTPUT"/command

{  $VIEWCOMMAND $WHIZZY.$VIEW $CLIENTVIEW 2>"OUTPUT"/view &
    echo $! >> #TMP"/pids
    ID=$!
    .....

Modify this passage to

....
echo '# End of command' ) >> "OUTPUT"/command

{  cp $WHIZZY.$VIEW .pdf
    $VIEWCOMMAND $WHIZZY.pdf $CLIENTVIEW 2>"OUTPUT"/view &
    echo $! >> #TMP"/pids
    ID=$!
    .....

- in line 670 or so , you will find the function "xpdfreload"
You should comment out all lines and add
cp $WHIZZY.$VIEW $WHIZZY.pdf
i.e. you should have

xpdfreload () {
cp $WHIZZY.$VIEW $WHIZZY.pdf
}

immediately afterwards comes the function "whole".
Below the line "echo '<Whole document updated>'
add the line

cp $WHIZZY.$VIEW $WHIZZY.pdf

- around line 714 you will find the function "duplex"
comment out the line
$VIEWCOMMAND $NAME.$VIEW &
and replace it by
$VIEWCOMMAND $NAME.pdf &


Finally, in your document preamble the first line should be (on one 
line)

%; whizzy paragraph -pdf 
"/Applications/TeXniscope.app/Contents/MacOS/TeXniscope" -initex 
"pdflatex -ini" -latex  pdflatex

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

That's it ..... finally...

When using TeXniscope as the previewer, you don't need to be running 
X11. In particular, there is no need to open emacs from the command 
line of an xterm as before.
Just open up Emacs and open some latex document, with the %; whizzy 
.... -line included
in the first line of the preamble. Then load up whizzytex with "M-x 
whizzytex-mode".
TeXniscope should open up and display the current slice. Typing "C-c d" 
should open up a view of the whole document.

I apologize for this lengthy (first) post of mine. I don't intend to 
answer any  questions so I spelt it all out.

Finally, I became aware of the existence of whizzytex by doing a google 
search and stumbling over a post by Nathan Dunfield (July 2003) on this 
mailing list. The subject of the thread was something else. Nathan 
mentioned in his post the existence of Advi and whizzytex. I would like 
to thank him for bringing whizzytex to my attention.

Philipp Mathey

--------------------- 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 MacOSX-TeX mailing list