comparison lisp/textmodes/flyspell.el @ 67858:35ea50aa6020

(flyspell-external-point-words): Use local var buffer-scan-pos to advance scan for next misspelling. Advance it only after we find the misspelling. New criteria for finding the misspelling in the buffer.
author Richard M. Stallman <rms@gnu.org>
date Tue, 27 Dec 2005 22:45:10 +0000
parents 88f36bfe01f5
children 5770fac9a117
comparison
equal deleted inserted replaced
67857:226904e7d40b 67858:35ea50aa6020
1306 "Mark words from a buffer listing incorrect words in order of appearance. 1306 "Mark words from a buffer listing incorrect words in order of appearance.
1307 The list of incorrect words should be in `flyspell-external-ispell-buffer'. 1307 The list of incorrect words should be in `flyspell-external-ispell-buffer'.
1308 \(We finish by killing that buffer and setting the variable to nil.) 1308 \(We finish by killing that buffer and setting the variable to nil.)
1309 The buffer to mark them in is `flyspell-large-region-buffer'." 1309 The buffer to mark them in is `flyspell-large-region-buffer'."
1310 (let (words-not-found 1310 (let (words-not-found
1311 (ispell-otherchars (ispell-get-otherchars))) 1311 (ispell-otherchars (ispell-get-otherchars))
1312 (buffer-scan-pos flyspell-large-region-beg))
1312 (with-current-buffer flyspell-external-ispell-buffer 1313 (with-current-buffer flyspell-external-ispell-buffer
1313 (goto-char (point-min)) 1314 (goto-char (point-min))
1314 ;; Loop over incorrect words. 1315 ;; Loop over incorrect words, in the order they were reported,
1316 ;; which is also the order they appear in the buffer being checked.
1315 (while (re-search-forward "\\([^\n]+\\)\n" nil t) 1317 (while (re-search-forward "\\([^\n]+\\)\n" nil t)
1316 ;; Bind WORD to the next one. 1318 ;; Bind WORD to the next one.
1317 (let ((word (match-string 1)) (wordpos (point))) 1319 (let ((word (match-string 1)) (wordpos (point)))
1318 ;; Here there used to be code to see if WORD is the same 1320 ;; Here there used to be code to see if WORD is the same
1319 ;; as the previous iteration, and count the number of consecutive 1321 ;; as the previous iteration, and count the number of consecutive
1323 (if flyspell-issue-message-flag 1325 (if flyspell-issue-message-flag
1324 (message "Spell Checking...%d%% [%s]" 1326 (message "Spell Checking...%d%% [%s]"
1325 (* 100 (/ (float (point)) (point-max))) 1327 (* 100 (/ (float (point)) (point-max)))
1326 word)) 1328 word))
1327 (with-current-buffer flyspell-large-region-buffer 1329 (with-current-buffer flyspell-large-region-buffer
1328 (goto-char flyspell-large-region-beg) 1330 (goto-char buffer-scan-pos)
1329 (let ((keep t)) 1331 (let ((keep t))
1330 ;; Iterate on string search until string is found as word, 1332 ;; Iterate on string search until string is found as word,
1331 ;; not as substring 1333 ;; not as substring
1332 (while keep 1334 (while keep
1333 (if (search-forward word 1335 (if (search-forward word
1334 flyspell-large-region-end t) 1336 flyspell-large-region-end t)
1335 (save-excursion 1337 (let* ((found-list
1336 (goto-char (- (point) 1)) 1338 (save-excursion
1337 (let* ((flyword-prev-l (flyspell-get-word nil)) 1339 ;; Move back into the match
1338 (flyword-prev (car flyword-prev-l)) 1340 ;; so flyspell-get-word will find it.
1339 (size-match (= (length flyword-prev) (length word)))) 1341 (forward-char -1)
1340 (when (or 1342 (flyspell-get-word nil)))
1341 ;; size matches, we are done 1343 (found (car found-list))
1342 size-match 1344 (found-length (length found))
1343 ;; Matches as part of a boundary-char separated word 1345 (misspell-length (length word)))
1344 (member word 1346 (when (or
1345 (split-string flyword-prev ispell-otherchars)) 1347 ;; Size matches, we really found it.
1346 ;; ispell treats beginning of some TeX 1348 (= found-length misspell-length)
1347 ;; commands as nroff control sequences 1349 ;; Matches as part of a boundary-char separated word
1348 ;; and strips them in the list of 1350 (member word
1349 ;; misspelled words thus giving a 1351 (split-string found ispell-otherchars))
1350 ;; non-existent word. Skip if ispell 1352 ;; Misspelling has higher length than
1351 ;; is used, string is a TeX command 1353 ;; what flyspell considers the
1352 ;; (char before beginning of word is 1354 ;; word. Caused by boundary-chars
1353 ;; backslash) and none of the previous 1355 ;; mismatch. Validating seems safe.
1354 ;; contitions match 1356 (< found-length misspell-length)
1355 (and (not ispell-really-aspell) 1357 ;; ispell treats beginning of some TeX
1356 (save-excursion 1358 ;; commands as nroff control sequences
1357 (goto-char (- (nth 1 flyword-prev-l) 1)) 1359 ;; and strips them in the list of
1358 (if (looking-at "[\\]" ) 1360 ;; misspelled words thus giving a
1359 t 1361 ;; non-existent word. Skip if ispell
1360 nil)))) 1362 ;; is used, string is a TeX command
1361 (setq keep nil) 1363 ;; (char before beginning of word is
1362 (flyspell-word) 1364 ;; backslash) and none of the previous
1363 ;; Next search will begin from end of last match 1365 ;; contitions match
1364 ))) 1366 (and (not ispell-really-aspell)
1367 (save-excursion
1368 (goto-char (- (nth 1 found-list) 1))
1369 (if (looking-at "[\\]" )
1370 t
1371 nil))))
1372 (setq keep nil)
1373 (flyspell-word)
1374 ;; Search for next misspelled word will begin from
1375 ;; end of last validated match.
1376 (setq buffer-scan-pos (point))))
1365 ;; Record if misspelling is not found and try new one 1377 ;; Record if misspelling is not found and try new one
1366 (add-to-list 'words-not-found 1378 (add-to-list 'words-not-found
1367 (concat " -> " word " - " 1379 (concat " -> " word " - "
1368 (int-to-string wordpos))) 1380 (int-to-string wordpos)))
1369 (setq keep nil))))))) 1381 (setq keep nil)))))))