diff options
| author | Richard M. Stallman | 2005-12-27 22:49:46 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-12-27 22:49:46 +0000 |
| commit | 51978cac9a00637bcabe81e21beee67b25965624 (patch) | |
| tree | 48b28f1b8b2ffef3cf5c06103c005ee1fc75cb4f | |
| parent | 13fe29bd54b51b828ff7260902aa1030b69643a9 (diff) | |
| download | emacs-51978cac9a00637bcabe81e21beee67b25965624.tar.gz emacs-51978cac9a00637bcabe81e21beee67b25965624.zip | |
(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.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/textmodes/flyspell.el | 78 |
2 files changed, 56 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cc8debb4768..4e56c1bb12f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2005-12-27 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * textmodes/flyspell.el (flyspell-external-point-words): | ||
| 4 | Use local var buffer-scan-pos to advance scan for next misspelling. | ||
| 5 | Advance it only after we find the misspelling. | ||
| 6 | |||
| 7 | 2005-12-27 Agustin Martin <agustin.martin@hispalinux.es> | ||
| 8 | |||
| 9 | * textmodes/flyspell.el (flyspell-external-point-words): | ||
| 10 | New criteria for finding the misspelling in the buffer. | ||
| 11 | |||
| 1 | 2005-12-28 Nick Roberts <nickrob@snap.net.nz> | 12 | 2005-12-28 Nick Roberts <nickrob@snap.net.nz> |
| 2 | Juri Linkov <juri@jurta.org> | 13 | Juri Linkov <juri@jurta.org> |
| 3 | 14 | ||
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index cad65b3b59d..33582af28b9 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -1308,10 +1308,12 @@ 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))) |
| @@ -1325,43 +1327,53 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 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 " - " |