--- flyspell.el.orig 2005-12-22 12:23:55.000000000 +0100 +++ flyspell.el 2005-12-22 12:49:28.000000000 +0100 @@ -1325,6 +1325,9 @@ (* 100 (/ (float (point)) (point-max))) word)) (with-current-buffer flyspell-large-region-buffer + ;; Make sure search starts from last validated match (or from + ;; beginning of region if the first time). This intends to avoid + ;; erroneous forward jumps that might cause fatal forward unsyncs. (goto-char flyspell-large-region-beg) (let ((keep t)) ;; Iterate on string search until string is found as word, @@ -1334,15 +1337,21 @@ flyspell-large-region-end t) (save-excursion (goto-char (- (point) 1)) - (let* ((flyword-prev-l (flyspell-get-word nil)) + (let* ((match-point (+ (point) 1)) + (flyword-prev-l (flyspell-get-word nil)) (flyword-prev (car flyword-prev-l)) - (size-match (= (length flyword-prev) (length word)))) + (flyword-length (length flyword-prev)) + (misspell-length (length word))) (when (or - ;; size matches, we are done - size-match + ;; Size matches, we are done + (= flyword-length misspell-length) ;; Matches as part of a boundary-char separated word (member word (split-string flyword-prev ispell-otherchars)) + ;; Misspelling has higher length than what flyspell + ;; considers the word. Caused by boundary-chars mismatch. + ;; Validating seems safe. + (< flyword-length misspell-length) ;; ispell treats beginning of some TeX ;; commands as nroff control sequences ;; and strips them in the list of @@ -1360,8 +1369,9 @@ nil)))) (setq keep nil) (flyspell-word) - ;; Next search will begin from end of last match - ))) + ;; Search for next misspelled word will begin from + ;; end of last validated match. + (setq flyspell-large-region-beg match-point)))) ;; Record if misspelling is not found and try new one (add-to-list 'words-not-found (concat " -> " word " - "