[comp.sys.next] Spellchecking LaTeX files in emacs

lastole@athena.mit.edu (Lars A Stole) (02/10/91)

I currently use emacs to write my LaTeX files.  In the past (when I used
a VAXstation3100) I used ispell (a program on MIT's athena system) to
spellcheck my latex files, using "-t" as an option so that commands
beginning with a backslash would be ignored.  Does such a program exist
on the NeXT?  I am currently using "spell" which is on the NeXT machine
to do my spell checking, but there doesn't seem to be a simple option to
ignore TeX commands as in ispell.  Is there a simple way get around this?
Is there a way to get around this problem using the spell checking
command in Edit?

Lars.

tvz@phoenix.Princeton.EDU (Timothy Van Zandt) (02/12/91)

In article <1991Feb10.015245.29408@athena.mit.edu> lastole@athena.mit.edu (Lars A Stole) writes:
>I currently use emacs to write my LaTeX files.  In the past (when I used
>a VAXstation3100) I used ispell (a program on MIT's athena system) to
>spellcheck my latex files, using "-t" as an option so that commands
>beginning with a backslash would be ignored.  Does such a program exist
>on the NeXT?  I am currently using "spell" which is on the NeXT machine
>to do my spell checking, but there doesn't seem to be a simple option to
>ignore TeX commands as in ispell.  Is there a simple way get around this?
>Is there a way to get around this problem using the spell checking
>command in Edit?

I'm not sure about using ispell on the NeXT, but an alternative is to 
convert backslashes to <space>zzz or some other string that never appears
at the beginning a word in your files. You can then spell check not only
English words, but also tex commands. A command like \foobar appears as
zzzfoobar in your dictionary. This works with just about spell checker (that
I have tried at least); in particular, it works with Edit.

For example, the script "tspell" works like spell, but it produces a list
of misspelled words and tex commands, using a dictionary with filename
~/Library/Dict/TexHash (or whatever). Start by copying /usr/dict/hlista to
~/Library/Dict/TexHash. The dictionary is maintained with tspellin, described
below. One warning about "spell" on the Next: It chokes on
lines longer than 512K, whereas on the other systems I use, "spell" can
handle lines up to 1024K. "tspell" breaks lines so this is not a problem. You
can add a few lines to the script so that tspell uses tex as the 
default extension.

-----------------BEGIN tspell-------------------------------------
#!	/bin/sh
/bin/sed 's/\\/\ zzz/g' $infile |
tr -cs A-Za-z '\012' |
spell -d ~/Library/Dict/TexHash |
/bin/sed 's/zzz/\\/g'
-------------------END tspell-----------------------------------

"tspellin" is an adaptation of spellin. It takes a list of words,
including tex commands beginning with backslash, and adds them
to ~/Library/Dict/TexWords and the hashed list ~/Library/Dict/TexHash for use
with "tspell". The unix command "spellout" could also be used in
the script below. You should start by running "tspell" on your favorite
tex macro files to get a list of tex commands to add to your dictionary
using "tspellin."

------------------BEGIN tspellin --------------------------------
#! 	/bin/sh
/bin/sed 's/[\\]/zzz/g' $1 >> ~/Library/Dict/TexWords
spellin < ~/Library/Dict/TexWords /usr/dict/hlista > \
		~/Library/Dict/TexHash
--------------------END tspellin-----------------------------------


In Edit, use the pipe
    sed 's/\\/\ zzz/g'
to convert \ to <space>zzz, then spell check, and then convert the
file back using the pipe
	sed 's/\ zzz/\\/g'
	
For some reason, you cannot just add these pipes to .pipedict. Instead,
define them as shell scripts. I added the lines

TeX2Spell	>	tex2spell
Spell2TeX	<	spell2tex

to .pipedict, where tex2spell and spell2tex are the shell scripts, so that
command-> and command-< do the conversions. Real simple.

Edit and Mail use a user dictionary ~/.NeXT/LocalDictionary. Words are
separated by null rather then newline, which makes it hard to add a list
of words. I took my list TexWords, converted newlines to null with some
difficulty, appended it to my LocalDictionary, and since then, I have
no idea what local dictionary Edit and Mail are using, but its not 
~/.NeXT/LocalDictionary anymore (and it is something). Weird! You can
always just add tex commands to the dictionary as you go along, and avoid
any hassle.

You can use a similar technique with emacs.

weigele@bosun1.informatik.uni-hamburg.de (Martin Weigele) (02/12/91)

Don't have the time to look at this more closely right now,
but I remember I have seen a "delatex" utility for emacs
in the TeX distribution 3.0.

Martin

geoff@ITcorp.com (Geoff Kuenning) (02/16/91)

In article <1991Feb10.015245.29408@athena.mit.edu> lastole@athena.mit.edu
(Lars A Stole) writes:

> I currently use emacs to write my LaTeX files.  In the past (when I used
> a VAXstation3100) I used ispell (a program on MIT's athena system) to
> spellcheck my latex files, using "-t" as an option so that commands
> beginning with a backslash would be ignored.  Does such a program exist
> on the NeXT?  I am currently using "spell" which is on the NeXT machine
> to do my spell checking, but there doesn't seem to be a simple option to
> ignore TeX commands as in ispell.  Is there a simple way get around this?

Ispell works just fine on the NeXT.  In fact, I maintain ispell on a
NeXT, using emacs as my editor.  Ispell sources are available via ftp
from uunet.uu.net, among other places.  Be certain that "ispell -v"
reports "Ispell 2.0.02, May 1987 Beta Posting" so that you have the
most up-to-date copy.  Also keep an eye on comp.sources.* for a new
version of ispell, to be released someday when I have time to get the
last details of the posting arranged (and when I figure out what to do
about the cosmetic bug I am working on in my other Stuart window.
-- 
	Geoff Kuenning   geoff@ITcorp.com   uunet!desint!geoff