VI & spell

Dan Mercer mercer at ncrcce.StPaul.NCR.COM
Wed Nov 15 05:44:02 AEST 1989


In article <4525 at ski.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
:In article <740 at uc.msc.umn.edu> glex at uf.UUCP (Jeffrey Gleixner) writes:
:\I finally have gotten so sick of typo's that I want to run spell while in
:\vi, without exiting or suspending, the file.   So I wrote a small script (sp).
:\It takes the input from vi (:1,$!sp) and redirects it to a file, I run
:                             ^^^^^^^
:This command will overwrite the buffer with the output from sp.
:The following command will just feed the buffer to sp:
:
:   :w !sp
:
:Notice the space between the `w' and the `!'.
:
:\spell on the file, pulling up a window (Sun) displaying the output from spell.
:\The window waits for a <CR> and then exits.  Well that works just fine EXCEPT 
:\that I can't continue with vi until I exit the window, probably waiting for 
:\the !sp to finish.
:
:Indeed.  Try something like this for sp (without the indentation!):
:
:   #!/bin/sh
:
:   cat > /tmp/sp.$$
:   trap '' 2 18 21 22  # trap SIGINT, SIGTSTP, SIGTTIN and SIGTTOU
:   (
:       # do funny stuff here
:   ) & # maybe some redirections are appropriate
:
:sp exits while its child will continue processing in the background.
:If you don't trap the stop signals, something `funny' happens when you
:stop vi (^Z) while the background job is still running, so that it would
:be stopped too, implicitly: (relevant BSD kernel code)
:
:   case SIGTSTP:
:   case SIGTTIN:
:   case SIGTTOU:
:       /*
:        * Children of init aren't allowed to stop
:        * on signals from the keyboard.
:        */
:       if (p->p_pptr == &proc[1]) {
:           psignal(p, SIGKILL);
:           continue;
:       }
:
:The stop signal is changed to a kill signal!
:BTW, how about the following, Mr. Bourne?!
:
:   trap '' SIGINT SIGTSTP SIGTTIN SIGTTOU
:or
:   trap '' INT TSTP TTIN TTOU
:-- 
:"Richard Sexton is actually an AI program (or Construct, if you will) running
:on some AT&T (R) 3B" (Richard Brosseau) | maart at cs.vu.nl, mcsun!botter!maart

On our SYSV Towers,  spell is implemented as a very inefficient shell
script,  with /usr/lib/spell/spellprog as the actual program (although
it requires a word/line input).  I de-engineered it and turned it into
Spell,  designed not only to proofread,  but to mark errors

=======================CUT HERE============================
HLISTA="/usr/lib/spell/spellprog /usr/lib/spell/hlista"
TMP=/usr/tmp/Spell$$

SCRIPT=

for i in `tee $TMP | deroff -w | $HLISTA`
    do
    SCRIPT="${SCRIPT}s/$i/\/\/\/${i}\/\/\//g
"
    done

sed "$SCRIPT" $TMP

rm $TMP

exit 0
=======================CUT HERE============================

the following two command in my .exrc file invoke it:

map ^V<ESC>s !}Spell^V^M/\/\/\/^Mw
map! ^V<ESC>s ^V<ESC>!}Spell^V^M/\/\/\/^Mw

============================================================

Now is the winter of ourr discontemt made weerder
by the moment by trying to think up sammple paragrafs
to demo this shit.


================is replaced by==============================

Now is the winter of ///ourr/// ///discontemt/// made ///weerder///
by the moment by trying to think up ///sammple/// ///paragrafs///
to ///demo/// this ///shit///.

============================================================

Of course,  this cores on our old news machine (Tower 1650).


On our normal machines,  it works quite well and speedily.

Normal disclaimers apply.

Does anyone know how spellprog works - the format of the spell
databases?  If I knew I'd do this up right.


-- 

Dan Mercer
Reply-To: mercer at ncrcce.StPaul.NCR.COM (Dan Mercer)



More information about the Comp.unix.questions mailing list