changes to ispell
Grass Roots
root at bobkat.UUCP
Wed Jan 14 14:14:03 AEST 1987
With the Intergrated Solutions, they define the argument to the
TIOCGPGRP ioctl call to be an int and not a short. I do not know what
berkeley actually does. Also, they did not set ospeed which makes all
the padding not work (bad bad bad).
Last, I wrote an ispell-region. This attempts to be a happy marriage
of the ispell interface and an emacs interface. The I, A, and R
commands of the ispell interface are supported. The selections were
changed from A, B, ... to 1, 2, ... as they are with ispell. The only
way to quit is ^G. I do not pretend to be a lisp programmer nor an
emacs guru. This code may be written extremely ineffeceintly but with
no lisp documentation I did the best I could. On this machine it tends
to drag a bit so on a 750 it will probably be too slow to be usable.
Hopefully some bright guy will speed things up some and then repost the
code.
To get the I and A commands to work from a pipe, I changed a few minor
things about the way that askmode works. Of course I had to change the
way the Makefile works.
You should be able to feed this to patch.
Perry Smith
pedz at bobkat
*** Makefile.old Tue Jan 13 22:03:21 1987
--- Makefile Tue Jan 13 15:19:47 1987
***************
*** 1,5
# -*- Mode: Text -*-
CFLAGS = -O
BINDIR = /usr/local/bin
LIBDIR = /usr/local/lib
--- 1,13 -----
# -*- Mode: Text -*-
+ BINDIR = /usr/free
+ LIBDIR = /usr/free/lib
+ MANDIR = /usr/man
+ MANSUF = l
+ PROG=ispell
+ MANPAGE=${MANDIR}/man${MANSUF}/${PROG}.${MANSUF}
+ BINPROG=${BINDIR}/${PROG}
+ PROGLIB=${LIBDIR}/ispell.hash
CFLAGS = -O
all: buildhash ispell ispell.hash
***************
*** 1,8
# -*- Mode: Text -*-
CFLAGS = -O
- BINDIR = /usr/local/bin
- LIBDIR = /usr/local/lib
all: buildhash ispell ispell.hash
--- 9,14 -----
BINPROG=${BINDIR}/${PROG}
PROGLIB=${LIBDIR}/ispell.hash
CFLAGS = -O
all: buildhash ispell ispell.hash
***************
*** 9,18
ispell.hash: buildhash dict.191
buildhash
! install: buildhash ispell ispell.hash
! cp ispell ${BINDIR}/ispell
! cp ispell.hash ${LIBDIR}/ispell.hash
! chmod 755 ${BINDIR}/ispell ${LIBDIR}/ispell.hash
buildhash: buildhash.o hash.o
cc -o buildhash buildhash.o hash.o
--- 15,21 -----
ispell.hash: buildhash dict.191
buildhash
! install: buildhash ${BINPROG} ${PROGLIB} ${MANPAGE}
${BINPROG} : ${PROG}
install -c -m 755 ispell ${BINPROG}
***************
*** 14,19
cp ispell.hash ${LIBDIR}/ispell.hash
chmod 755 ${BINDIR}/ispell ${LIBDIR}/ispell.hash
buildhash: buildhash.o hash.o
cc -o buildhash buildhash.o hash.o
--- 17,31 -----
install: buildhash ${BINPROG} ${PROGLIB} ${MANPAGE}
+ ${BINPROG} : ${PROG}
+ install -c -m 755 ispell ${BINPROG}
+
+ ${PROGLIB} : ispell.hash
+ install -c -m 755 ispell.hash ${PROGLIB}
+
+ ${MANPAGE} : ispell.man
+ install -c ispell.man ${MANPAGE}
+
buildhash: buildhash.o hash.o
$(CC) $(CFLAGS) -o buildhash buildhash.o hash.o
***************
*** 15,21
chmod 755 ${BINDIR}/ispell ${LIBDIR}/ispell.hash
buildhash: buildhash.o hash.o
! cc -o buildhash buildhash.o hash.o
ispell: ispell.o term.o good.o lookup.o hash.o tree.o
cc $(CFLAGS) -o ispell ispell.o term.o good.o lookup.o \
--- 27,33 -----
install -c ispell.man ${MANPAGE}
buildhash: buildhash.o hash.o
! $(CC) $(CFLAGS) -o buildhash buildhash.o hash.o
ispell: ispell.o term.o good.o lookup.o hash.o tree.o
$(CC) $(CFLAGS) -o ispell ispell.o term.o good.o lookup.o \
***************
*** 18,24
cc -o buildhash buildhash.o hash.o
ispell: ispell.o term.o good.o lookup.o hash.o tree.o
! cc $(CFLAGS) -o ispell ispell.o term.o good.o lookup.o \
hash.o tree.o -ltermlib
clean:
--- 30,36 -----
$(CC) $(CFLAGS) -o buildhash buildhash.o hash.o
ispell: ispell.o term.o good.o lookup.o hash.o tree.o
! $(CC) $(CFLAGS) -o ispell ispell.o term.o good.o lookup.o \
hash.o tree.o -ltermlib
clean:
***************
*** 24,26
clean:
rm -f *.o buildhash ispell core a.out mon.out hash.out \
stats.191 count.191
--- 36,41 -----
clean:
rm -f *.o buildhash ispell core a.out mon.out hash.out \
stats.191 count.191
+
+ lookup.o : lookup.c Makefile
+ $(CC) $(CFLAGS) -DLIBDIR='"$(LIBDIR)"' -c lookup.c
*** ispell.c.old Tue Jan 13 22:03:27 1987
--- ispell.c Tue Jan 13 21:39:06 1987
***************
*** 640,646
setbuf (stdout, NULL);
while (gets (buf) != NULL) {
! if (good (buf)) {
if (rootword[0] == 0) {
printf ("*\n"); /* perfect match */
} else {
--- 640,651 -----
setbuf (stdout, NULL);
while (gets (buf) != NULL) {
! /* *line is like `i', @line is like `a' */
! if (buf[0] == '*' || buf[0] == '@') {
! treeinsert(buf + 1, buf[0] == '*');
! printf("*\n");
! treeoutput ();
! } else if (good (buf)) {
if (rootword[0] == 0) {
printf ("*\n"); /* perfect match */
} else {
*** ispell.el.old Tue Jan 13 22:03:29 1987
--- ispell.el Tue Jan 13 21:56:31 1987
***************
*** 5,10
;;; ARPA: Buehring%TI-CSL at CSNet-Relay
;;; UUCP: {smu, texsun, im4u, rice} ! ti-csl ! buehring
;;; Depends on the ispell program snarfed from MIT-PREP in early
;;; 1986. The only interactive command is "ispell-word" which should be
;;; bound to M-$. If someone writes an "ispell-region" command,
--- 5,15 -----
;;; ARPA: Buehring%TI-CSL at CSNet-Relay
;;; UUCP: {smu, texsun, im4u, rice} ! ti-csl ! buehring
+ ;;; ispell-region and associate routines added by
+ ;;; Perry Smith
+ ;;; pedz at bobkat
+ ;;; Tue Jan 13 20:18:02 CST 1987
+
;;; Depends on the ispell program snarfed from MIT-PREP in early
;;; 1986. The only interactive command is "ispell-word" which should be
;;; bound to M-$. If someone writes an "ispell-region" command,
***************
*** 33,40
(progn
(setq ispell-syntax-table (make-syntax-table))
;; Make certain characters word constituents
! (modify-syntax-entry ?' "w " ispell-syntax-table)
! (modify-syntax-entry ?- "w " ispell-syntax-table)
;; Get rid on existing word syntax on certain characters
(modify-syntax-entry ?$ ". " ispell-syntax-table)
(modify-syntax-entry ?% ". " ispell-syntax-table)))
--- 38,45 -----
(progn
(setq ispell-syntax-table (make-syntax-table))
;; Make certain characters word constituents
! ;; (modify-syntax-entry ?' "w " ispell-syntax-table)
! ;; (modify-syntax-entry ?- "w " ispell-syntax-table)
;; Get rid on existing word syntax on certain characters
(modify-syntax-entry ?0 ". " ispell-syntax-table)
(modify-syntax-entry ?1 ". " ispell-syntax-table)
***************
*** 36,41
(modify-syntax-entry ?' "w " ispell-syntax-table)
(modify-syntax-entry ?- "w " ispell-syntax-table)
;; Get rid on existing word syntax on certain characters
(modify-syntax-entry ?$ ". " ispell-syntax-table)
(modify-syntax-entry ?% ". " ispell-syntax-table)))
--- 41,56 -----
;; (modify-syntax-entry ?' "w " ispell-syntax-table)
;; (modify-syntax-entry ?- "w " ispell-syntax-table)
;; Get rid on existing word syntax on certain characters
+ (modify-syntax-entry ?0 ". " ispell-syntax-table)
+ (modify-syntax-entry ?1 ". " ispell-syntax-table)
+ (modify-syntax-entry ?2 ". " ispell-syntax-table)
+ (modify-syntax-entry ?3 ". " ispell-syntax-table)
+ (modify-syntax-entry ?4 ". " ispell-syntax-table)
+ (modify-syntax-entry ?5 ". " ispell-syntax-table)
+ (modify-syntax-entry ?6 ". " ispell-syntax-table)
+ (modify-syntax-entry ?7 ". " ispell-syntax-table)
+ (modify-syntax-entry ?8 ". " ispell-syntax-table)
+ (modify-syntax-entry ?9 ". " ispell-syntax-table)
(modify-syntax-entry ?$ ". " ispell-syntax-table)
(modify-syntax-entry ?% ". " ispell-syntax-table)))
***************
*** 71,77
(or quietly (message "Found it because of %s" (upcase poss))))
((null poss)
(or quietly (message "Could Not Find %s" (upcase word))))
! (t (setq replace (ispell-choose poss))
(if replace
(progn
(goto-char end)
--- 86,92 -----
(or quietly (message "Found it because of %s" (upcase poss))))
((null poss)
(or quietly (message "Could Not Find %s" (upcase word))))
! (t (setq replace (ispell-choose poss word))
(if replace
(progn
(goto-char end)
***************
*** 74,82
(t (setq replace (ispell-choose poss))
(if replace
(progn
! (goto-char end)
! (delete-region start end)
! (insert-string replace)))))
poss))
--- 89,97 -----
(t (setq replace (ispell-choose poss word))
(if replace
(progn
! (goto-char end)
! (delete-region start end)
! (insert-string replace)))))
poss))
***************
*** 80,88
poss))
! (defun ispell-choose (choices)
! "Display possible corrections from list CHOICES. Return chosen word or nil
! if none chosen."
(unwind-protect
(save-window-excursion
(let ((count 0)
--- 95,103 -----
poss))
! (defun ispell-choose (choices word)
! "Display possible corrections from list CHOICES. Return chosen word
! if one is chosen; Return nil to keep word"
(unwind-protect
(save-window-excursion
(let ((count 0)
***************
*** 87,94
(save-window-excursion
(let ((count 0)
(words choices)
! (pick -1)
! (window-min-height 2))
(overlay-window 3)
(switch-to-buffer "*Choices*") (erase-buffer)
(setq mode-line-format "-- %b --")
--- 102,109 -----
(save-window-excursion
(let ((count 0)
(words choices)
! (window-min-height 2)
! char num result)
(overlay-window 3)
(switch-to-buffer "*Choices*") (erase-buffer)
(setq mode-line-format "-- %b --")
***************
*** 95,101
(while words
(if (> (+ 7 (current-column) (length (car words))) (window-width))
(insert "\n"))
! (insert "(" (+ count ?a) ") " (car words) " ")
(setq words (cdr words)
count (1+ count)))
(select-window (next-window))
--- 110,116 -----
(while words
(if (> (+ 7 (current-column) (length (car words))) (window-width))
(insert "\n"))
! (insert "(" (+ count ?1) ") " (car words) " ")
(setq words (cdr words)
count (1+ count)))
(select-window (next-window))
***************
*** 99,112
(setq words (cdr words)
count (1+ count)))
(select-window (next-window))
! (while (eq pick -1)
! (message "Enter letter to replace word; Space to flush")
! (let* ((char (read-char))
! (num (1+ (- (upcase char) ?A))))
! (cond ((= char ? ) (setq pick 0))
! ((or (<= num 0) (> num count)) (ding))
! (t (setq pick num)))))
! (and (> pick 0) (nth (1- pick) choices))))
;; Protected forms...
(bury-buffer "*Choices*")))
--- 114,136 -----
(setq words (cdr words)
count (1+ count)))
(select-window (next-window))
! (while (eq t
! (setq result
! (progn
! (message "Enter letter to replace word; Space to flush")
! (setq char (upcase (read-char)))
! (setq num (- char ?1))
! (cond ((= char ? ) nil)
! ((= char ?I)
! (ispell-check (concat "*" word))
! nil)
! ((= char ?A)
! (ispell-check (concat "@" word))
! nil)
! ((= char ?R) (read-string "Replacement: " nil))
! ((and (>= num 0) (< num count)) (nth num choices))
! (t (ding) t))))))
! result))
;; Protected forms...
(bury-buffer "*Choices*")))
***************
*** 189,191
(process-kill-without-query ispell-process)
(sit-for 3))))
--- 213,273 -----
(process-kill-without-query ispell-process)
(sit-for 3))))
+ (defvar ispell-filter-hook "/bin/cat"
+ "Filter to pass a region through before sending it to ispell.
+ Typically this is set to cat, deroff, detex, etc.")
+ (make-variable-buffer-local 'ispell-filter-hook)
+
+ (defvar ispell-filter-hook-args nil
+ "Arguments to pass to ispell-filter-hook")
+ (make-variable-buffer-local 'ispell-filter-hook-args)
+
+ ; This routine has certain limitations brought about by the filter
+ ; hook. For example, deroff will take ``\fBcat\fR'' and spit out
+ ; ``cat''. This is hard to search for since word-search-forward will
+ ; not match at all and search-forward for ``cat'' will match
+ ; ``concatinate'' if it happens to occur before. I attempt to
+ ; minimize these problems by always searching for each word in the
+ ; original buffer even if it is not misspelled. This slows things
+ ; down.
+
+ (defun ispell-region (start end)
+ "Check a region for spelling errors interactively. The variable
+ which should be buffer or mode specific ispell-filter-hook is called
+ to filter out text processing commands."
+ (interactive "r")
+ (let ((this-buf (current-buffer))
+ (spell-buf (get-buffer-create "ispell-temp"))
+ (current-syntax (syntax-table))
+ word poss replace word-start word-end)
+ (unwind-protect
+ (save-excursion
+ (set-buffer spell-buf)
+ (erase-buffer)
+ (set-buffer this-buf)
+ (if ispell-filter-hook-args
+ (call-process-region start end ispell-filter-hook nil
+ spell-buf nil ispell-filter-hook-args)
+ (call-process-region start end ispell-filter-hook nil
+ spell-buf nil))
+ (goto-char start)
+ (set-buffer spell-buf)
+ (set-syntax-table ispell-syntax-table)
+ (goto-char (point-min))
+ (while (progn
+ (message "Looking for a misspelled word")
+ (re-search-forward "\\W*\\(\\w+\\)" nil t))
+ (setq word (buffer-substring (setq word-start (match-beginning 1))
+ (setq word-end (match-end 1))))
+ (setq poss (ispell-check word))
+ (set-buffer this-buf)
+ (or (search-forward word nil t)
+ (error "Can not find %s in original text" word))
+ (if (not (or (eq poss t) (stringp poss))) ;bad word
+ (progn
+ (sit-for 0)
+ (setq replace (ispell-choose poss word))
+ (if replace
+ (replace-match replace))))
+ (set-buffer spell-buf)))
+ (set-syntax-table current-syntax))))
*** ispell.h.old Tue Jan 13 22:03:30 1987
--- ispell.h Mon Jan 12 13:26:44 1987
***************
*** 1,7
/* -*- Mode: Text -*- */
- #define LIBDIR "/usr/local/lib"
-
struct dent {
struct dent *next;
char *word;
--- 1,5 -----
/* -*- Mode: Text -*- */
struct dent {
struct dent *next;
char *word;
*** ispell.man.old Tue Jan 13 22:03:19 1987
--- ispell.man Tue Jan 13 21:53:49 1987
***************
*** 46,52
is intended to be used from other programs through a pipe. In this
mode,
.I ispell
! expects the standard input to consist of single words. Each word is
read, and a single line is written to the standard output. If the word
was found in the main dictionary, or your personal dictionary, then the
line contains only a '*'. If the word was found through suffix removal,
--- 46,53 -----
is intended to be used from other programs through a pipe. In this
mode,
.I ispell
! expects the standard input to consist of lines containing single words.
! Each word is
read, and a single line is written to the standard output. If the word
was found in the main dictionary, or your personal dictionary, then the
line contains only a '*'. If the word was found through suffix removal,
***************
*** 59,64
is also suitable for interactive use when you want to figure out the
spelling of a single word. (These characters are the same as the codes
that the real spell program uses.)
.SH FILES
/usr/local/lib/ispell.hash
.br
--- 60,77 -----
is also suitable for interactive use when you want to figure out the
spelling of a single word. (These characters are the same as the codes
that the real spell program uses.)
+ .PP
+ When in the
+ .B \-a
+ mode,
+ .I ispell
+ will also accept lines of single words prefixed with either a '*' or a '@'.
+ A line starting with '*' tells
+ .I ispell
+ to insert the word into the user's dictionary (simular to the I command).
+ A line starting with '@' causes
+ .I ispell
+ to accept this word in the future (simular to the A command).
.SH FILES
/usr/local/lib/ispell.hash
.br
*** term.c.old Tue Jan 13 22:03:32 1987
--- term.c Tue Jan 13 15:18:15 1987
***************
*** 60,66
terminit ()
{
int done();
! short tpgrp;
int onstop();
retry:
--- 60,66 -----
terminit ()
{
int done();
! int tpgrp;
int onstop();
extern short ospeed;
***************
*** 62,67
int done();
short tpgrp;
int onstop();
retry:
sigsetmask(1<<SIGTSTP | 1<<SIGTTIN | 1<<SIGTTOU);
--- 62,68 -----
int done();
int tpgrp;
int onstop();
+ extern short ospeed;
retry:
sigsetmask(1<<SIGTSTP | 1<<SIGTTIN | 1<<SIGTTOU);
***************
*** 87,92
erasechar = sbuf.sg_erase;
killchar = sbuf.sg_kill;
signal (SIGINT, done);
--- 88,94 -----
erasechar = sbuf.sg_erase;
killchar = sbuf.sg_kill;
+ ospeed = sbuf.sg_ospeed;
signal (SIGINT, done);
*** tree.c.old Tue Jan 13 22:03:33 1987
--- tree.c Tue Jan 13 21:38:50 1987
***************
*** 75,81
char nword[BUFSIZ];
strcpy (nword, word);
root = tinsert (upcase (nword), root, keep);
! newwords = 1;
}
static
--- 75,81 -----
char nword[BUFSIZ];
strcpy (nword, word);
root = tinsert (upcase (nword), root, keep);
! newwords = newwords || keep;
}
static
***************
*** 150,156
}
toutput1 (root);
!
fclose (dictf);
}
--- 150,156 -----
}
toutput1 (root);
! newwords = 0;
fclose (dictf);
}
More information about the Comp.sources.unix
mailing list