Function: ispell-word
ispell-word is an autoloaded, interactive and byte-compiled function
defined in ispell.el.gz.
Signature
(ispell-word &optional FOLLOWING QUIETLY CONTINUE REGION)
Documentation
Check spelling of word under or before the cursor.
If the word is not found in dictionary, display possible corrections in a window allowing you to choose one.
If optional argument FOLLOWING is non-nil or if ispell-following-word
is non-nil when called interactively, then the following word
(rather than preceding) is checked when the cursor is not over a word.
When the optional argument QUIETLY is non-nil or ispell-quietly is non-nil
when called interactively, non-corrective messages are suppressed.
With a prefix argument (or if CONTINUE is non-nil), resume interrupted spell-checking of a buffer or region.
Interactively, in Transient Mark mode when the mark is active, call
ispell-region to check the active region for spelling errors.
Non-interactively, this happens if REGION is non-nil.
Word syntax is controlled by the definition of the chosen dictionary,
which is in ispell-local-dictionary-alist or ispell-dictionary-alist.
This will check or reload the dictionary. Use M-x ispell-change-dictionary (ispell-change-dictionary)
or M-x ispell-region (ispell-region) to update the Ispell process.
Return values:
nil word is correct or spelling is accepted.
0 word is inserted into buffer-local definitions.
"word" word corrected from word list.
("word" arg) word is hand entered.
quit spell session exited.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/ispell.el.gz
;;;###autoload
(defun ispell-word (&optional following quietly continue region)
"Check spelling of word under or before the cursor.
If the word is not found in dictionary, display possible corrections
in a window allowing you to choose one.
If optional argument FOLLOWING is non-nil or if `ispell-following-word'
is non-nil when called interactively, then the following word
\(rather than preceding) is checked when the cursor is not over a word.
When the optional argument QUIETLY is non-nil or `ispell-quietly' is non-nil
when called interactively, non-corrective messages are suppressed.
With a prefix argument (or if CONTINUE is non-nil),
resume interrupted spell-checking of a buffer or region.
Interactively, in Transient Mark mode when the mark is active, call
`ispell-region' to check the active region for spelling errors.
Non-interactively, this happens if REGION is non-nil.
Word syntax is controlled by the definition of the chosen dictionary,
which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.
This will check or reload the dictionary. Use \\[ispell-change-dictionary]
or \\[ispell-region] to update the Ispell process.
Return values:
nil word is correct or spelling is accepted.
0 word is inserted into buffer-local definitions.
\"word\" word corrected from word list.
\(\"word\" arg) word is hand entered.
quit spell session exited."
(interactive (list ispell-following-word ispell-quietly current-prefix-arg t))
(cond
((and region (use-region-p))
(ispell-region (region-beginning) (region-end)))
(continue (ispell-continue))
(t
(ispell-set-spellchecker-params) ; Initialize variables and dicts alists
(ispell-accept-buffer-local-defs) ; use the correct dictionary
(let ((cursor-location (point)) ; retain cursor location
(word (ispell-get-word following))
start end poss new-word replace)
;; De-structure return word info list.
(setq start (car (cdr word))
end (car (cdr (cdr word)))
word (car word))
;; At this point it used to ignore 2-letter words.
;; But that is silly; if the user asks for it, we should do it. - rms.
(or quietly
(message "Checking spelling of %s..."
(funcall ispell-format-word-function word)))
(setq poss (ispell--run-on-word word))
(cond ((eq poss t)
(or quietly
(message "%s is correct"
(funcall ispell-format-word-function word))))
((stringp poss)
(or quietly
(message "%s is correct because of root %s"
(funcall ispell-format-word-function word)
(funcall ispell-format-word-function poss))))
((null poss)
(message "Error checking word %s using %s with %s dictionary"
(funcall ispell-format-word-function word)
(file-name-nondirectory ispell-program-name)
(or ispell-current-dictionary "default")))
(ispell-check-only ; called from ispell minor mode.
(progn
(beep)
(message "%s is incorrect"
(funcall ispell-format-word-function word))))
(t ; prompt for correct word.
(save-window-excursion
(setq replace (ispell-command-loop
(car (cdr (cdr poss)))
(car (cdr (cdr (cdr poss))))
(car poss) start end)))
(cond ((equal 0 replace)
(ispell-add-per-file-word-list (car poss)))
(replace
(setq new-word (if (atom replace) replace (car replace))
cursor-location (+ (- (length word) (- end start))
cursor-location))
(if (not (equal new-word (car poss)))
(progn
(goto-char start)
;; Insert first and then delete,
;; to avoid collapsing markers before and after
;; into a single place.
(insert new-word)
(delete-region (point) end)
;; It is meaningless to preserve the cursor position
;; inside a word that has changed.
(setq cursor-location (point))
(setq end (point))))
(if (not (atom replace)) ;recheck spelling of replacement
(progn
(if (car (cdr replace)) ; query replace requested
(save-window-excursion
(query-replace word new-word t)))
(goto-char start)
;; single word could be split into multiple words
(setq ispell-quit (not (ispell-region start end)))
))))
;; keep if rechecking word and we keep choices win.
(if (get-buffer ispell-choices-buffer)
(kill-buffer ispell-choices-buffer))))
(ispell-pdict-save ispell-silently-savep)
;; NB: Cancels ispell-quit incorrectly if called from ispell-region
(if ispell-quit (setq ispell-quit nil replace 'quit))
(goto-char cursor-location) ; return to original location
replace))))