[net.text] M-x spell buffer with TeX files

agw@garfield.columbia.edu (Art Werschulz) (02/20/86)

**********************************************************

Does anybody know how to check spelling of TeX files with GNUmacs?
The problem is with TeX control sequences.  The spelling checker
interprets a control sequence such as \input as being  nput ---that is,
it strips off the leading backslash and the next character, interpreting
it as an escaped character (a la C?).  I would be happy to have a
version of the spelling checker that merely ignores TeX control sequences,
since I can find out about misspelled control sequences merely by
looking at either the logfile or the finished output.

Thanks.

	Art Werschulz

	ARPAnet:  werschulz@columbia 
		  (forwarded to agw@lexington.columbia.edu, which most people
		   can't seem to easily reach)
	USEnet:   ... seismo!columbia!lexington!agw  (I think)
	ATTnet:   (212) 280-3610 280-2736 841-5323 841-5396

bzs@bu-cs.UUCP (Barry Shein) (02/22/86)

The easiest thing to do for checking spelling of TeX files is to
get the detex command which I believe should have been on the
TeX distribution tape (thanks to Howard Trickey) and add it to
the spell pipeline (spell is a shell file so this is quite easy.)

Adding it *before* deroff seemed to work better as deroff will remove
\a-little-bit whilst detex will remove \word-to-delimiter more or less
which should happen first. I suspect there are cases where this may
not be ideal in which case someone might want to just make an xspell
or some such which only detex's and leave the other alone and teach
GNU emacs about the new command (I would just copy spell.el to
xspell.el and change the relevant shell command in that file.) Or
maybe it should check an environment variable and automagically do the
right thing, or maybe GNU emacs should check if you are in some sort
of TeX input mode and/or the file ends in .tex and choose which
command seems best, or perhaps 'file' should be taught about TeX files
and that could be used to decide, or maybe we should build an expert
system to see if the content of your paper is even worthwhile to
bother checking the spelling on, or...

	-Barry Shein, Boston University

chris@umcp-cs.UUCP (Chris Torek) (02/22/86)

Our solution to the various spell problems was to write a local
version of the `spell' shell script.  Here are the diffs from a
vanilla 4.2 spell to our local version, /usr/local/bin/spell, and
then from that to spelltex and to spelllatex.  The local script
also handles local dictionaries as specified by the environment
variable $SPELL_LISTS.

Note that the script below will only work on 4.2 systems and
derivatives due to long file names.

: Run this shell script with "sh" not "csh"
PATH=/bin:/usr/bin:/usr/ucb:/etc:$PATH
export PATH
all=FALSE
if [ x$1 = x-a ]; then
	all=TRUE
fi
echo 'Extracting spell.diff'
sed 's/^X//' <<'//go.sysin dd *' >spell.diff
*** /usr/4.2/usr/bin/spell	Tue Sep 27 12:49:27 1983
--- spell.sh	Mon Jan 13 04:18:40 1986
***************
*** 2,11 ****
  #
  #	@(#)spell.sh	1.3	(Berkeley)	83/09/10
  #
  : V data for -v, B flags, D dictionary, S stop, H history, F files, T temp
  V=/dev/null		B=			F= 
  S=/usr/dict/hstop	H=/dev/null		T=/tmp/spell.$$
  next="F=$F@"
! trap "rm -f $T ${T}a ; exit" 0
  for A in $*
  do
--- 2,22 ----
  #
  #	@(#)spell.sh	1.3	(Berkeley)	83/09/10
+ #	@(#)spell.sh	(U of M Hacked: 10-Aug-84)
  #
  : V data for -v, B flags, D dictionary, S stop, H history, F files, T temp
+ 
+ PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin
+ 
  V=/dev/null		B=			F= 
  S=/usr/dict/hstop	H=/dev/null		T=/tmp/spell.$$
+ T1=/tmp/spell1.$$
+ 
+ # next two are so that spell, spelltex, and spelllatex are almost identical,
+ # except of course for these lines:
+ ME=spell
+ DE="deroff@-w"	# @ is IFS when this is eval'd
+ 
  next="F=$F@"
! trap "rm -f $T $T1 ${T}a ; exit" 0
  for A in $*
  do
***************
*** 19,25 ****
  	-s)	next="S=" ;;
  	-h)	next="H=" ;;
! 	-*)	echo "Bad flag for spell: $A"
! 		echo "Usage:  spell [ -v ] [ -b ] [ -d hlist ] [ -s hstop ] [ -h spellhist ]"
! 		exit ;;
  	*)	eval $next"$A"
  		next="F=$F@" ;;
--- 30,36 ----
  	-s)	next="S=" ;;
  	-h)	next="H=" ;;
! 	-*)	echo "Bad flag for $ME: $A" 1>&2
! 		echo "Usage: $ME [ -v ] [ -b ] [ -d hlist ] [ -s hstop ] [ -h spellhist ]" 1>&2
! 		exit 1;;
  	*)	eval $next"$A"
  		next="F=$F@" ;;
***************
*** 27,39 ****
  done
  IFS=@
! case $H in
! /dev/null)	deroff -w $F | sort -u | /usr/lib/spell $S $T |
! 		/usr/lib/spell ${D-/usr/dict/hlista} $V $B |
! 		sort -u +0f +0 - $T ;;
! *)		deroff -w $F | sort -u | /usr/lib/spell $S $T |
! 		/usr/lib/spell ${D-/usr/dict/hlista} $V $B |
! 		sort -u +0f +0 - $T | tee -a $H
! 		who am i >> $H 2> /dev/null ;;
! esac
  case $V in
  /dev/null)	exit ;;
--- 38,92 ----
  done
  IFS=@
! 
! # Cull out any words appearing in any file named in the environment
! # variable ``SPELL_LISTS''. Note that ``comm'' can't be instructed to
! # ignore case, so we must lower-caseify everything. (18-Jan-83 FLB)
! 
! if
! 	private_lists=`printenv SPELL_LISTS`
! then
! 
! #	Handle as in default, but dump output to T1
! 	case $H in
! 	/dev/null)	$DE $F | sort -u | /usr/lib/spell $S $T |
! 			/usr/lib/spell ${D-/usr/dict/hlista} $V $B |
! 			sort -u +0f +0 - $T > $T1 ;;
! 	*)		$DE $F | sort -u | /usr/lib/spell $S $T |
! 			/usr/lib/spell ${D-/usr/dict/hlista} $V $B |
! 			sort -u +0f +0 - $T | tee -a $H > $T1
! 			who am i >> $H 2> /dev/null ;;
! 	esac
! 
! #	Lower-caseify everything (ugh!)
! 	mv $T1 $T
! 	tr '[A-Z]' '[a-z]' < $T | sort -u +0f +0 > $T1
! 
! #	Comb out words appearing in user's private lists.
! 	for list in $private_lists
! 	do
! 		if
! 			[ -r "$list" ]
! 		then
! 			mv $T1 $T
! 			comm -23 $T "$list" > $T1
! 		else
! 			echo "$0: $list unreadable"
! 		fi
! 	done
! 	cat $T1
! 
! else
! #	Default case: handle as distributed by Berkeley
! 	case $H in
! 	/dev/null)	$DE $F | sort -u | /usr/lib/spell $S $T |
! 			/usr/lib/spell ${D-/usr/dict/hlista} $V $B |
! 			sort -u +0f +0 - $T ;;
! 	*)		$DE $F | sort -u | /usr/lib/spell $S $T |
! 			/usr/lib/spell ${D-/usr/dict/hlista} $V $B |
! 			sort -u +0f +0 - $T | tee -a $H
! 			who am i >> $H 2> /dev/null ;;
! 	esac
! fi
! 
  case $V in
  /dev/null)	exit ;;
//go.sysin dd *
if [ `wc -c < spell.diff` != 3322 ]; then
	made=FALSE
	echo 'error transmitting "spell.diff" --'
	echo 'length should be 3322, not' `wc -c < spell.diff`
else
	made=TRUE
fi
if [ $made = TRUE ]; then
	chmod 644 spell.diff
	echo -n '	'; ls -ld spell.diff
fi
echo 'Extracting spell.vs.spelllatex.diff'
sed 's/^X//' <<'//go.sysin dd *' >spell.vs.spelllatex.diff
*** spell.sh	Mon Jan 13 04:18:40 1986
--- spelllatex.sh	Sun Jan  5 16:54:24 1986
***************
*** 14,19 ****
  # next two are so that spell, spelltex, and spelllatex are almost identical,
  # except of course for these lines:
! ME=spell
! DE="deroff@-w"	# @ is IFS when this is eval'd
  
  next="F=$F@"
--- 14,19 ----
  # next two are so that spell, spelltex, and spelllatex are almost identical,
  # except of course for these lines:
! ME=spelllatex
! DE=delatex
  
  next="F=$F@"
//go.sysin dd *
if [ `wc -c < spell.vs.spelllatex.diff` != 485 ]; then
	made=FALSE
	echo 'error transmitting "spell.vs.spelllatex.diff" --'
	echo 'length should be 485, not' `wc -c < spell.vs.spelllatex.diff`
else
	made=TRUE
fi
if [ $made = TRUE ]; then
	chmod 644 spell.vs.spelllatex.diff
	echo -n '	'; ls -ld spell.vs.spelllatex.diff
fi
echo 'Extracting spell.vs.spelltex.diff'
sed 's/^X//' <<'//go.sysin dd *' >spell.vs.spelltex.diff
*** spell.sh	Mon Jan 13 04:18:40 1986
--- spelltex.sh	Sun Jan  5 16:54:39 1986
***************
*** 14,19 ****
  # next two are so that spell, spelltex, and spelllatex are almost identical,
  # except of course for these lines:
! ME=spell
! DE="deroff@-w"	# @ is IFS when this is eval'd
  
  next="F=$F@"
--- 14,19 ----
  # next two are so that spell, spelltex, and spelllatex are almost identical,
  # except of course for these lines:
! ME=spelltex
! DE=detex
  
  next="F=$F@"
//go.sysin dd *
if [ `wc -c < spell.vs.spelltex.diff` != 479 ]; then
	made=FALSE
	echo 'error transmitting "spell.vs.spelltex.diff" --'
	echo 'length should be 479, not' `wc -c < spell.vs.spelltex.diff`
else
	made=TRUE
fi
if [ $made = TRUE ]; then
	chmod 644 spell.vs.spelltex.diff
	echo -n '	'; ls -ld spell.vs.spelltex.diff
fi
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu