If you want to spell-check TeX or *roff documents with Ispell, you need to arrange for a filter program that understands how to strip TeX or *roff formatting commands to be run. In the TeX distribution, there are several different programs named `detex', all with incompatible options, and a very old pair of programs named `detex' and `delatex', which should probably be avoided. The most useful one for Ispell is `detex' by Daniel Trinkle. A more recent version is available via FTP:
Raphael Cerf <email@example.com> recently released a program for this named `xetal':
There is a program that comes with Unix named `deroff' for stripping formatting commands from *roff files.
Here is an example of code you can put in a .emacs file to use these programs:
;; Based on suggestions by David G. Grubbs <firstname.lastname@example.org> and Paul Palmer ;; <email@example.com>.
;; Assuming the use of detex 2.3 by Daniel Trinkle: ;; -w means one word per line. ;; -n means don't expand \input or \include commands. ;; -l means force LaTeX mode.
(require 'ispell) ; for the make-variable-buffer-local statements (setq plain-TeX-mode-hook (function (lambda () (setq ispell-filter-hook "detex") (setq ispell-filter-hook-args '("-nw"))))) (setq LaTeX-mode-hook (function (lambda () (setq ispell-filter-hook "detex") (setq ispell-filter-hook-args '("-lnw"))))) (setq nroff-mode-hook (function (lambda () (setq ispell-filter-hook "deroff") (setq ispell-filter-hook-args '("-w")))))
You will have to adjust the arguments for programs other than Trinkle's detex or for other versions of deroff. Experiment running the command from the shell to find the correct options. If you don't have a filter that knows how to output one word per line, you must pipe its output through another filter to break up the output.