home *** CD-ROM | disk | FTP | other *** search
- /*
- * QAD hack to use the ispell ARexx port to check the spelling of the
- * word you just typed, or are pointing at. Type a ? to get a list of possible
- * replacements, and then either type the word, or the number of the
- * replacement in the list.
- *
- * Copyright (c) 1990, Mike Meyer
- */
-
- options results
-
- /* Get the word & and a running IRexx... */
- if ~show(ports, 'IRexxSpell') then address command 'run ispell -r >nil:'
- word = getword()
- if word = "" then exit 2
- address command 'waitforport IRexxSpell'
-
- /* Check it, exiting if it's in the dictionary */
- address 'IRexxSpell' 'check' word
- list = result
- type = left(list, 1)
- if type = '*' then exit
-
- /* otherwise, offer to let the user replace it */
- do forever
- 'rexx-request "`'word''' not recognized; replacement: "'
- if rc > 0 then exit
- if result ~= "?" then leave
- if type = '#' then iterate
- else do
- 'rexx-request "'substr(list, 3)': "'
- if rc = 0 then do
- if datatype(result, 'Numeric') then
- result = word(list, result + 1)
- leave
- end
- end
- end
- replace = result
-
- /* We have a replacement from the user - go install it... */
- 'forward-char'
- 'backward-word'
- 'kill-word'
- 'rexx-insert "'replace'"'
- exit
-
-
- /* Old version - replaces everything in the buffer */
- 'rexx-point' point
- if point.0 < 2 then exit 2
- 'beginning-of-buffer'
- 'search-forward "'word'"'
-
- /* Really need to make query-replace work inside of rexx... */
- do while rc = 0
- 'backward-kill-word'
- 'rexx-insert "'replace'"'
- 'search-forward "'word'"'
- end
-
- /* Put things back... */
- 'goto-line' point.1
- 'beginning-of-line'
- 'search-forward "'replace'"'
-