Function: ispell-send-string
ispell-send-string is a byte-compiled function defined in
ispell.el.gz.
Signature
(ispell-send-string STRING)
Documentation
Send the string STRING to the Ispell process.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/ispell.el.gz
(defun ispell-send-string (string)
"Send the string STRING to the Ispell process."
(if ispell-async-processp
(if (process-live-p ispell-process)
(process-send-string ispell-process string))
;; Asynchronous subprocesses aren't supported on this losing system.
;; We keep all the directives passed to Ispell during the entire
;; session in a buffer, and pass them anew each time we invoke
;; Ispell to process another chunk of text. (Yes, I know this is a
;; terrible kludge, and it's a bit slow, but it does get the work done.)
(let ((cmd (aref string 0))
;; The following commands are not passed to Ispell until
;; we have a *real* reason to invoke it.
(cmds-to-defer '(?* ?@ ?~ ?+ ?- ?! ?%))
(session-buf ispell-session-buffer)
(output-buf ispell-output-buffer)
(ispell-args ispell-cmd-args)
(defdir ispell-process-directory)
prev-pos)
(with-current-buffer session-buf
(setq prev-pos (point))
(setq default-directory defdir)
(insert string)
(if (not (memq cmd cmds-to-defer))
(let* ((coding-system-for-read (ispell-get-coding-system))
(coding-system-for-write coding-system-for-read)
status)
(set-buffer output-buf)
(erase-buffer)
(set-buffer session-buf)
(setq status
(apply 'ispell-call-process-region
(point-min) (point-max)
ispell-program-name nil
output-buf nil
"-a"
;; hunspell -m option means something different
(if ispell-really-hunspell "" "-m")
ispell-args))
(set-buffer output-buf)
(goto-char (point-min))
(save-match-data
(if (not (looking-at "@(#) "))
(error "Ispell error: %s"
(buffer-substring-no-properties
(point) (progn (end-of-line) (point)))))
;; If STRING is "^Z\n", we just started Ispell and need
;; to retain its version ID line in the output buffer.
;; Otherwise, remove the ID line, as it will confuse
;; `ispell-filter'.
(or (string= string "\032\n")
(progn
(forward-line)
(delete-region (point-min) (point))))
;; If STRING begins with ^ or any normal character, we need
;; to remove the last line from the session buffer, since it
;; was just spell-checked, and we don't want to check it again.
;; The same goes for the # command, since Ispell already saved
;; the personal dictionary.
(set-buffer session-buf)
(delete-region prev-pos (point))
;; Ispell run synchronously saves the personal dictionary
;; after each successful command. So we can remove any
;; lines in the session buffer that insert words into the
;; dictionary.
(if (memq status '(0 nil))
(let ((more-lines t))
(goto-char (point-min))
(while more-lines
(if (looking-at "^\\*")
(let ((start (point)))
(forward-line)
(delete-region start (point)))
(setq more-lines (= 0 (forward-line))))))))))))))