home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
495a.lha
/
ISpell_v3.1ljr
/
mgStuff
/
spell-region.mg
< prev
next >
Wrap
Text File
|
1991-04-06
|
2KB
|
95 lines
/*
* Use the ispell ARexx port to check the spelling of every word in the region.
* Same interface as spell-word.
*/
options results
options failat 1
bufname = "*speller*"
tmpfile = 'ram:'address()'-speller'
if ~show(ports, 'IRexxSpell') then address command 'run ispell -r >nil:'
/* Clean out the test buffer, and copy the region to it, and save it */
'switch-to-buffer "'bufname'"'
'beginning-of-buffer'
'end-of-buffer'
'kill-region'
'switch-to-buffer ""' /* Null string -> goes to previous buffer */
'copy-region-as-kill' /* Paranoid - we'll not delete it till we're done */
'switch-to-buffer "'bufname'"'
'yank'
'write-file' tmpfile
/* Go check the tmp file, then delete it */
address command 'waitforport IRexxSpell'
address 'IRexxSpell' 'filecheck' tmpfile
errorfile = result
address command 'delete quiet' tmpfile
if ~open(errors, errorfile, 'Read') then do
'rexx-display "Can''t open error file"'
exit
end
/* Get the buffer name after the write */
'rexx-buffer' buffer
if buffer.0 < 1 then do
'rexx-display "Can''t get buffer information"'
exit
end
bufname = buffer.1
badword = readln(errors)
if wordlist = "" then do
'rexx-display "No errors found"'
exit
end
/* Loop over bad words, fixing them if needed */
do while ~eof(errors)
address 'IRexxSpell' 'check' badword
parse var result '&' wordlist
replace = getreplace("`"badword"' not recognized; replacement: ")
if replace = "" then iterate
if replace = "?" then do
if wordlist = "" then iterate
replace = getreplace(wordlist': ')
if replace = "" then iterate
if datatype(replace, 'Numeric') then
replace = word(wordlist, result)
end
/* Got a replacement, put it in everywhere (probably a bad idea) */
'beginning-of-buffer'
'search-forward "'badword'"'
do while rc = 0
'backward-kill-word'
'rexx-insert "'replace'"'
'search-forward "'badword'"'
end
badword = readln(errors)
end
call close errors
address command 'delete quiet' errorfile
/* Ok, put the new text back in place... */
'switch-to-buffer ""'
'kill-region'
'insert-buffer "'bufname'"'
'kill-buffer "'bufname'"'
exit
getreplace: procedure expose errorfile
parse arg line
options failat 3
'rexx-request "'line'"'
if rc > 1 then do
address command 'delete quiet' errorfile
exit
end
if rc > 0 then return ""
return result