Fix Flyspell mode when several languages are mixed in a buffer
* lisp/textmodes/flyspell.el (flyspell-external-point-words): Handle "misspelled" words that actually belong to a language unsupported by the current dictionary. (Bug#32280) Fix the test for Ispell the program.
This commit is contained in:
parent
cc233365a9
commit
a0ef733886
1 changed files with 31 additions and 6 deletions
|
@ -1420,10 +1420,20 @@ determined by `flyspell-large-region'."
|
||||||
The list of incorrect words should be in `flyspell-external-ispell-buffer'.
|
The list of incorrect words should be in `flyspell-external-ispell-buffer'.
|
||||||
\(We finish by killing that buffer and setting the variable to nil.)
|
\(We finish by killing that buffer and setting the variable to nil.)
|
||||||
The buffer to mark them in is `flyspell-large-region-buffer'."
|
The buffer to mark them in is `flyspell-large-region-buffer'."
|
||||||
(let (words-not-found
|
(let* (words-not-found
|
||||||
(ispell-otherchars (ispell-get-otherchars))
|
(flyspell-casechars (flyspell-get-casechars))
|
||||||
(buffer-scan-pos flyspell-large-region-beg)
|
(ispell-otherchars (ispell-get-otherchars))
|
||||||
case-fold-search)
|
(ispell-many-otherchars-p (ispell-get-many-otherchars-p))
|
||||||
|
(word-chars (concat flyspell-casechars
|
||||||
|
"+\\("
|
||||||
|
(if (not (string= "" ispell-otherchars))
|
||||||
|
(concat ispell-otherchars "?"))
|
||||||
|
flyspell-casechars
|
||||||
|
"+\\)"
|
||||||
|
(if ispell-many-otherchars-p
|
||||||
|
"*" "?")))
|
||||||
|
(buffer-scan-pos flyspell-large-region-beg)
|
||||||
|
case-fold-search)
|
||||||
(with-current-buffer flyspell-external-ispell-buffer
|
(with-current-buffer flyspell-external-ispell-buffer
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
;; Loop over incorrect words, in the order they were reported,
|
;; Loop over incorrect words, in the order they were reported,
|
||||||
|
@ -1453,11 +1463,18 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
|
||||||
;; Move back into the match
|
;; Move back into the match
|
||||||
;; so flyspell-get-word will find it.
|
;; so flyspell-get-word will find it.
|
||||||
(forward-char -1)
|
(forward-char -1)
|
||||||
(flyspell-get-word)))
|
;; Is this a word that matches the
|
||||||
|
;; current dictionary?
|
||||||
|
(if (looking-at word-chars)
|
||||||
|
(flyspell-get-word))))
|
||||||
(found (car found-list))
|
(found (car found-list))
|
||||||
(found-length (length found))
|
(found-length (length found))
|
||||||
(misspell-length (length word)))
|
(misspell-length (length word)))
|
||||||
(when (or
|
(when (or
|
||||||
|
;; Misspelled word is not from the
|
||||||
|
;; language supported by the current
|
||||||
|
;; dictionary.
|
||||||
|
(null found)
|
||||||
;; Size matches, we really found it.
|
;; Size matches, we really found it.
|
||||||
(= found-length misspell-length)
|
(= found-length misspell-length)
|
||||||
;; Matches as part of a boundary-char separated
|
;; Matches as part of a boundary-char separated
|
||||||
|
@ -1479,13 +1496,21 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
|
||||||
;; backslash) and none of the previous
|
;; backslash) and none of the previous
|
||||||
;; conditions match.
|
;; conditions match.
|
||||||
(and (not ispell-really-aspell)
|
(and (not ispell-really-aspell)
|
||||||
|
(not ispell-really-hunspell)
|
||||||
|
(not ispell-really-enchant)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (- (nth 1 found-list) 1))
|
(goto-char (- (nth 1 found-list) 1))
|
||||||
(if (looking-at "[\\]" )
|
(if (looking-at "[\\]" )
|
||||||
t
|
t
|
||||||
nil))))
|
nil))))
|
||||||
(setq keep nil)
|
(setq keep nil)
|
||||||
(flyspell-word nil t)
|
;; Don't try spell-checking words whose
|
||||||
|
;; characters don't match CASECHARS, because
|
||||||
|
;; flyspell-word will then consider as
|
||||||
|
;; misspelling the preceding word that matches
|
||||||
|
;; CASECHARS.
|
||||||
|
(or (null found)
|
||||||
|
(flyspell-word nil t))
|
||||||
;; Search for next misspelled word will begin from
|
;; Search for next misspelled word will begin from
|
||||||
;; end of last validated match.
|
;; end of last validated match.
|
||||||
(setq buffer-scan-pos (point))))
|
(setq buffer-scan-pos (point))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue