[comp.editors] Spell checking in vi

lin@sixmile.inel.gov (Linn Hower) (04/17/91)

  Hello.  A few years ago there was a posting of some lines that
could be placed in an 'exrc file to interface with spell(1).  One function
key took all the editor buffer, piped it to spell, and appended the
output.  A second function key cycled through these words one at a time
and loaded the search buffer.  Your could then find and correct the
bad words easily.

  I've lost this.  Does anyone still have this... or a better spell-
checker interface for vi?

  Thanks...
  Linn Hower	lin@INEL.GOV		Phone: 208-526-9231
		at the Idaho National Engineering Laboratory, Idaho Falls, ID

========== long legal disclaimer follows, press n to skip ===========

Neither the United States Government or the Idaho National Engineering
Laboratory or any of their employees, makes any warranty, whatsoever,
implied, or assumes any legal liability or responsibility regarding any
information, disclosed, or represents that its use would not infringe
privately owned rights.  No specific reference constitutes or implies
endorsement, recommendation, or favoring by the United States
Government or the Idaho National Engineering Laboratory.  The views and
opinions expressed herein do not necessarily reflect those of the
United States Government or the Idaho National Engineering Laboratory,
and shall not be used for advertising or product endorsement purposes.

mullins@convex.com (Don Mullins) (04/17/91)

    I use this for an interface to ispell.  ispell is an interactive checker,
    thus the redirects in and out to /dev/tty.

    From my .exrc - this has been run thru 'cat -v' for mailing:

"
" write file, run ispell on file, re-edit file (k)sh version
"
map ^[i :w^M!!/usr/local/bin/ispell -x % </dev/tty >/dev/tty 2>&1^M:e!^M
"
" write file, run ispell on file, re-edit file csh version. I think the
" syntax is correct, it's been a while.
"
map ^[i :w^M!!/usr/local/bin/ispell -x % </dev/tty &>/dev/tty^M:e!^M
"

Don

--
Don Mullins          Convex Computer Corporation          Richardson, Texas USA
INTERNET: mullins@convex.COM -- UUCP: {uiucuxc, uunet, sun, ...}!convex!mullins

mck@hpcuhc.cup.hp.com (Doug McKenzie) (04/23/91)

>   Hello.  A few years ago there was a posting of some lines that
> could be placed in an 'exrc file to interface with spell(1).  One function
> key took all the editor buffer, piped it to spell, and appended the
> output.  A second function key cycled through these words one at a time
> and loaded the search buffer.  Your could then find and correct the
> bad words easily.
> 
>   I've lost this.  Does anyone still have this... or a better spell-
> checker interface for vi?

For what it's worth, here's one I wrote.  Invoke as: <script> file
It runs spell on the file, puts the misspelled words in a tmp file,
asks if you want to edit that file, then invokes vi on the orig. file.  with
the following mappings:  ctrl-N searches for bad words sequentially in the
file, ctrl-K (kind of slowly) re-checks an attempt at spelling a word.

This works on HP's hp-ux.  Other than the "tput" command, which just
produces bold on the screen, it looks pretty generic to me.  I don't see
anything that requires ksh rather than plain sh.

It's shar'ed up because there's <ctrl>-stuff in it.  Can you unpack it?

Doug McKenzie
HP HP-UX Support
mck@cup.hp.com  OR  ...!hplabs!hpda!mck


# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Doug McKenzie <mck@hpcuhc> on Tue Apr 23 09:20:21 1991
#
# This archive contains:
#	visp	
#

LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH


rm -f /tmp/uud$$
(echo "begin 777 /tmp/uud$$\n \nend" | uudecode) >/dev/null 2>&1
if [ -f /tmp/uud$$ ]
then
	rm -f /tmp/uud$$
	unpacker=uudecode
else
	echo Compiling unpacker for non-ascii files
	pwd=`pwd`; cd /tmp
	cat >unpack$$.c <<-'EOF'
	#include <stdio.h>
	#define DEC(c)	(((c) - ' ') & 077)
	main()
	{
		int n;
		char dest[128], a,b,c,d;

		scanf("begin %o ", &n);
		gets(dest);

		if (freopen(dest, "w", stdout) == NULL) {
			perror(dest);
			exit(1);
		}

		while ((n=getchar()) != EOF && (n=DEC(n))!=0)  {
			while (n>0) {
				a = DEC(getchar());
				b = DEC(getchar());
				c = DEC(getchar());
				d = DEC(getchar());
				if (n-- > 0) putchar(a << 2 | b >> 4);
				if (n-- > 0) putchar(b << 4 | c >> 2);
				if (n-- > 0) putchar(c << 6 | d);
			}
			n=getchar();
		}
		exit(0);
	}
	EOF
	cc -o unpack$$ unpack$$.c
	rm unpack$$.c
	cd $pwd
	unpacker=/tmp/unpack$$
fi

echo x - visp '[non-ascii]'
$unpacker <<'@eof'
begin 755 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]</!M<(GID
M9$!Z?"!<"@D)(" @(&UA<" D>T-(14-+7TU!4'T@>5PD,DQO&W P.BXA87=K
M("=[<')I;G0@7"0Q?2<-23HA)# @+7<@7"(;05PB&UPB>61D7&!<8$!Y(B D
M,0H)9FD*(" @(&5L<V4@96-H;R B3F\@<W!E;&QI;F<@97)R;W)S(&9O=6YD
M(&EN("0Q(@H@(" @9FD*(" @("]B:6XO<FT@+68@+W1M<"]V:7-P)"0*9FD*
 
end
@eof

chmod 755 visp

rm -f /tmp/unpack$$
exit 0

kal@cs.brown.edu (Keith Lewis (x1136)) (04/25/91)

In article <2360003@hpcuhc.cup.hp.com> mck@hpcuhc.cup.hp.com (Doug McKenzie) writes:
>>   Hello.  A few years ago there was a posting of some lines that
>> could be placed in an 'exrc file to interface with spell(1).  One function
>> key took all the editor buffer, piped it to spell, and appended the
>> output.  A second function key cycled through these words one at a time
>> and loaded the search buffer.  Your could then find and correct the
>> bad words easily.
>> 
>>   I've lost this.  Does anyone still have this... or a better spell-
>> checker interface for vi?

Here is something I have in my .exrc. The command \sp in vi runs spell
on the file and puts the output in a temporary file. Just move the
cursor to a line containing a word you want to change and type \/.
You get switched back to the original with the cursor underneath
the misspelled word. Type \\ to return to the temp file. When you
are done \$ removes the temp file.

map \sp :!spell % > %.sp^V^M:e %.sp^V^M^V^M
map \/ 0i/^V^[$a/^V^["wdd:w^V^M:e#^V^M@w
map \\ :w^V^M:e#^V^M
map \$ :!rm -f %.sp^V^M

-Keith Lewis

sanders@sanders.austin.ibm.com (Tony Sanders) (04/26/91)

map ^K :%!(tee /tmp/sp$$;echo -End Spell-;spell /tmp/sp$$;rm -f /tmp/sp$$)^V^M
map ^O Gi/\<^V^[A\>^V^["wdd@w

^x is control character of course.

^K runs spell
^O searches for next misspelled word.

Might I also suggest finding a copy of ispell.

-- sanders@cactus.org