Function: flyspell-get-word
flyspell-get-word is a byte-compiled function defined in
flyspell.el.gz.
Signature
(flyspell-get-word &optional FOLLOWING EXTRA-OTHERCHARS)
Documentation
Return the word for spell-checking according to Ispell syntax.
Optional argument FOLLOWING non-nil means to get the following
(rather than preceding) word when the cursor is not over a word.
Optional second argument EXTRA-OTHERCHARS is a regexp of characters
that may be included as part of a word (see ispell-dictionary-alist).
This finds the word to spell-check by searching for CASECHARS defined
in ispell-dictionary-alist for the current dictionary. Thus, the
word could be far away from point if point is inside whitespace or
punctuation characters, or in text that belongs to a different
language.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/flyspell.el.gz
;;*---------------------------------------------------------------------*/
;;* flyspell-get-word ... */
;;*---------------------------------------------------------------------*/
(defun flyspell-get-word (&optional following extra-otherchars)
"Return the word for spell-checking according to Ispell syntax.
Optional argument FOLLOWING non-nil means to get the following
\(rather than preceding) word when the cursor is not over a word.
Optional second argument EXTRA-OTHERCHARS is a regexp of characters
that may be included as part of a word (see `ispell-dictionary-alist').
This finds the word to spell-check by searching for CASECHARS defined
in `ispell-dictionary-alist' for the current dictionary. Thus, the
word could be far away from point if point is inside whitespace or
punctuation characters, or in text that belongs to a different
language."
(let* ((flyspell-casechars (flyspell-get-casechars))
(flyspell-not-casechars (flyspell-get-not-casechars))
(ispell-otherchars (ispell-get-otherchars))
(ispell-many-otherchars-p (ispell-get-many-otherchars-p))
(word-regexp (concat flyspell-casechars
"+\\("
(if (not (string= "" ispell-otherchars))
(concat ispell-otherchars "?"))
(if extra-otherchars
(concat extra-otherchars "?"))
flyspell-casechars
"+\\)"
(if (or ispell-many-otherchars-p
extra-otherchars)
"*" "?")))
did-it-once prevpt
start end word)
;; find the word
(if (not (looking-at flyspell-casechars))
(if following
(re-search-forward flyspell-casechars nil t)
(re-search-backward flyspell-casechars nil t)))
;; move to front of word
(re-search-backward flyspell-not-casechars nil 'start)
(while (and (or (and (not (string= "" ispell-otherchars))
(looking-at ispell-otherchars))
(and extra-otherchars (looking-at extra-otherchars)))
(not (bobp))
(or (not did-it-once)
ispell-many-otherchars-p)
(not (eq prevpt (point))))
(if (and extra-otherchars (looking-at extra-otherchars))
(progn
(backward-char 1)
(if (looking-at flyspell-casechars)
(re-search-backward flyspell-not-casechars nil 'move)))
(setq did-it-once t
prevpt (point))
(backward-char 1)
(if (looking-at flyspell-casechars)
(re-search-backward flyspell-not-casechars nil 'move)
(backward-char -1))))
;; Now mark the word and save to string.
(if (not (re-search-forward word-regexp nil t))
nil
(progn
(setq start (match-beginning 0)
end (point)
word (buffer-substring-no-properties start end))
(list word start end)))))