Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!princeton!phoenix!tvz From: tvz@phoenix.Princeton.EDU (Timothy Van Zandt) Newsgroups: comp.sys.next Subject: Re: Spellchecking LaTeX files in emacs Keywords: Spellchecking LaTeX files in emacs Message-ID: <6169@idunno.Princeton.EDU> Date: 11 Feb 91 23:08:55 GMT References: <1991Feb10.015245.29408@athena.mit.edu> Sender: news@idunno.Princeton.EDU Organization: Princeton University, Princeton, New Jersey Lines: 77 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 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 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.