(defun flyspell-external-point-words () "Mark words from a buffer listing incorrect words in order of appearance. The list of incorrect words should be in `flyspell-external-ispell-buffer'. \(We finish by killing that buffer and setting the variable to nil.) The buffer to mark them in is `flyspell-large-region-buffer'." (let (words-not-found (ispell-otherchars (ispell-get-otherchars)) (mydebug nil)) (with-current-buffer flyspell-external-ispell-buffer (goto-char (point-min)) ;; Loop over incorrect words. (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t) ;; Bind WORD to the next one. (let ((word (match-string 1)) (wordpos (point))) ;; Here there used to be code to see if WORD is the same ;; as the previous iteration, and count the number of consecutive ;; identical words, and the loop below would search for that many. ;; That code seemed to be incorrect, and on principle, should ;; be unnecessary too. -- rms. (if flyspell-issue-message-flag (message "Spell Checking...%d%% [%s]" (* 100 (/ (float (point)) (point-max))) word)) ;; Search the other buffer for occurrences of this word, ;; and check them. Stop when we find one that reports "incorrect". ;; (I don't understand the reason for that logic, ;; but I didn't want to change it. -- rms.) (with-current-buffer flyspell-large-region-buffer (goto-char flyspell-large-region-beg) (let ((keep t)) ;; Iterate on string search until string is found as word, ;; not as substring, (while keep (if (search-forward word flyspell-large-region-end t) (progn (goto-char (- (point) 1)) (let* ((match-point (point)) ; flyspell-get-word might move it (flyword-prev-l (flyspell-get-word nil)) (flyword-endpoint (point)) (flyword-prev (car flyword-prev-l)) (size-match (= (length flyword-prev) (length word))) ) (when mydebug ;; --- debugging code starts (message "word[%s], flyword[%s], wp[%d] flrb[%d] p[%d]" word flyword-prev wordpos flyspell-large-region-beg (point)) (when (not size-match) (message "Size mismatch f:[%s] m:[%s] %s" flyword-prev word flyword-prev-l)) ) ;; --- debugging code ends (when (or size-match (member word (split-string flyword-prev ispell-otherchars)) (and (not ispell-really-aspell) (save-excursion (goto-char (- (nth 1 flyword-prev-l) 1)) (if (looking-at "[\\]" ) (progn (when mydebug (message "[%s] %s has nroff problems in \\%s" (match-string 0) word flyword-prev)) t) nil )) ) ) ; end-or (setq keep nil) (flyspell-word) (setq flyspell-large-region-beg (if size-match flyword-endpoint match-point)) ;; --------------------------- (when mydebug (if size-match (message "+ Moving to %d (match on %d)" flyword-endpoint match-point) (message "+ Moving to %d (point on %d)" match-point flyword-endpoint))) ;; ------------------------------ ) ; end-when ) ; end-let ) ; end-progn (when mydebug (error "Error for word [%s] on flrb[%d] p[%d]" word flyspell-large-region-beg (point))) (add-to-list 'words-not-found (concat " -> " word " - " (int-to-string wordpos))) (setq keep nil) )))))) ;; we are done (if flyspell-issue-message-flag (message "Spell Checking completed."))) (dolist (word words-not-found) (message "%s: word not found" word)) ;;) ; let keep ;; Kill and forget the buffer with the list of incorrect words. (when (not mydebug) (kill-buffer flyspell-external-ispell-buffer) (setq flyspell-external-ispell-buffer nil)) ) ); let