Function: ispell-filter
ispell-filter is a byte-compiled function defined in ispell.el.gz.
Signature
(ispell-filter PROCESS OUTPUT)
Documentation
Output filter function for ispell, grep, and look.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/ispell.el.gz
;; "ispell-filter" is a list of output lines from the generating function.
;; Each full line (ending with \n) is a separate item on the list.
;; "output" can contain multiple lines, part of a line, or both.
;; "start" and "end" are used to keep bounds on lines when "output" contains
;; multiple lines.
;; "ispell-filter-continue" is true when we have received only part of a
;; line as output from a generating function ("output" did not end with \n)
;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
;; This is the case when a process dies or fails. The default behavior
;; in this case treats the next input received as fresh input.
(defun ispell-filter (_process output)
"Output filter function for ispell, grep, and look."
(let ((start 0)
(continue t)
end)
(while continue
(setq end (string-search "\n" output start)) ; get text up to the newline.
;; If we get out of sync and ispell-filter-continue is asserted when we
;; are not continuing, treat the next item as a separate list. When
;; ispell-filter-continue is asserted, ispell-filter *should* always be a
;; list!
;; Continue with same line (item)?
(if (and ispell-filter-continue ispell-filter (listp ispell-filter))
;; Yes. Add it to the prev item
(setcar ispell-filter
(concat (car ispell-filter) (substring output start end)))
;; No. This is a new line and item.
(setq ispell-filter
(cons (substring output start end) ispell-filter)))
(if (null end)
;; We've completed reading the output, but didn't finish the line.
(setq ispell-filter-continue t continue nil)
;; skip over newline, this line complete.
(setq ispell-filter-continue nil end (1+ end))
(if (= end (length output)) ; No more lines in output
(setq continue nil) ; so we can exit the filter.
(setq start end)))))) ; else move start to next line of input