diff options
| author | Eli Zaretskii | 2005-12-02 13:17:38 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2005-12-02 13:17:38 +0000 |
| commit | 27e0edcdca4f14c669f68ef136ed0d0025b339c5 (patch) | |
| tree | 632df048b2913ce7e4ccf9adf2aad1c1b182c61d | |
| parent | 116e44a12d452fa9b8ea0c5fe7bfecf86a1d30d1 (diff) | |
| download | emacs-27e0edcdca4f14c669f68ef136ed0d0025b339c5.tar.gz emacs-27e0edcdca4f14c669f68ef136ed0d0025b339c5.zip | |
(flyspell-external-point-words): Consider a misspelling as found in the string
search if: (a) misspelling and found string lengths match, or (b) misspelling
is found as element in a boundary-chars separated longer string, or
(c) ispell-program-name is really ispell and misspelling is found as part of
a TeX string. After successful match move beginning of search region to end
of match. Warn about not found misspellings once the process is done.
(flyspell-large-region) Do not set ispell-parser to tex if in TeX mode.
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/textmodes/flyspell.el | 117 |
2 files changed, 83 insertions, 47 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ce23abbf1c9..bf8d6bf2503 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2005-12-02 Agustin Martin <agustin.martin@hispalinux.es> | ||
| 2 | |||
| 3 | * textmodes/flyspell.el (flyspell-external-point-words): Consider | ||
| 4 | a misspelling as found in the string search if: (a) misspelling | ||
| 5 | and found string lengths match, or (b) misspelling is found as | ||
| 6 | element in a boundary-chars separated longer string, or (c) | ||
| 7 | ispell-program-name is really ispell and misspelling is found as | ||
| 8 | part of a TeX string. After successful match move beginning of | ||
| 9 | search region to end of match. Warn about not found misspellings | ||
| 10 | once the process is done. | ||
| 11 | (flyspell-large-region) Do not set ispell-parser to tex if in TeX | ||
| 12 | mode. | ||
| 13 | |||
| 1 | 2005-12-02 Nick Roberts <nickrob@snap.net.nz> | 14 | 2005-12-02 Nick Roberts <nickrob@snap.net.nz> |
| 2 | 15 | ||
| 3 | * progmodes/gud.el (gud-menu-map): Put gud-finish back on the | 16 | * progmodes/gud.el (gud-menu-map): Put gud-finish back on the |
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index a0f36f5f794..402a3995795 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -1307,50 +1307,75 @@ Word syntax described by `flyspell-dictionary-alist' (which see)." | |||
| 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 | 1310 | (let (words-not-found | |
| 1311 | (with-current-buffer flyspell-external-ispell-buffer | 1311 | (ispell-otherchars (ispell-get-otherchars))) |
| 1312 | (goto-char (point-min)) | 1312 | (with-current-buffer flyspell-external-ispell-buffer |
| 1313 | ;; Loop over incorrect words. | 1313 | (goto-char (point-min)) |
| 1314 | (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t) | 1314 | ;; Loop over incorrect words. |
| 1315 | ;; Bind WORD to the next one. | 1315 | (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t) |
| 1316 | (let ((word (match-string 1)) (wordpos (point))) | 1316 | ;; Bind WORD to the next one. |
| 1317 | ;; Here there used to be code to see if WORD is the same | 1317 | (let ((word (match-string 1)) (wordpos (point))) |
| 1318 | ;; as the previous iteration, and count the number of consecutive | 1318 | ;; Here there used to be code to see if WORD is the same |
| 1319 | ;; identical words, and the loop below would search for that many. | 1319 | ;; as the previous iteration, and count the number of consecutive |
| 1320 | ;; That code seemed to be incorrect, and on principle, should | 1320 | ;; identical words, and the loop below would search for that many. |
| 1321 | ;; be unnecessary too. -- rms. | 1321 | ;; That code seemed to be incorrect, and on principle, should |
| 1322 | (if flyspell-issue-message-flag | 1322 | ;; be unnecessary too. -- rms. |
| 1323 | (message "Spell Checking...%d%% [%s]" | 1323 | (if flyspell-issue-message-flag |
| 1324 | (* 100 (/ (float (point)) (point-max))) | 1324 | (message "Spell Checking...%d%% [%s]" |
| 1325 | word)) | 1325 | (* 100 (/ (float (point)) (point-max))) |
| 1326 | ;; Search the other buffer for occurrences of this word, | 1326 | word)) |
| 1327 | ;; and check them. Stop when we find one that reports "incorrect". | 1327 | (with-current-buffer flyspell-large-region-buffer |
| 1328 | ;; (I don't understand the reason for that logic, | 1328 | (goto-char flyspell-large-region-beg) |
| 1329 | ;; but I didn't want to change it. -- rms.) | 1329 | (let ((keep t)) |
| 1330 | (with-current-buffer flyspell-large-region-buffer | 1330 | ;; Iterate on string search until string is found as word, |
| 1331 | (goto-char flyspell-large-region-beg) | 1331 | ;; not as substring |
| 1332 | (let ((keep t)) | 1332 | (while keep |
| 1333 | (while keep | 1333 | (if (search-forward word |
| 1334 | (if (search-forward word | 1334 | flyspell-large-region-end t) |
| 1335 | flyspell-large-region-end t) | 1335 | (progn |
| 1336 | (progn | 1336 | (goto-char (- (point) 1)) |
| 1337 | (setq flyspell-large-region-beg (point)) | 1337 | (let* ((match-point (point)) ; flyspell-get-word might move it |
| 1338 | (goto-char (- (point) 1)) | 1338 | (flyword-prev-l (flyspell-get-word nil)) |
| 1339 | (setq keep | 1339 | (flyword-prev (car flyword-prev-l)) |
| 1340 | ;; Detect when WORD can't be checked properly | 1340 | (size-match (= (length flyword-prev) (length word)))) |
| 1341 | ;; because flyspell-get-word finds | 1341 | (when (or |
| 1342 | ;; just part of it, and treat that as ok. | 1342 | ;; size matches, we are done |
| 1343 | (if (< (length (car (flyspell-get-word nil))) | 1343 | size-match |
| 1344 | (length word)) | 1344 | ;; Matches as part of a boundary-char separated word |
| 1345 | nil | 1345 | (member word |
| 1346 | (flyspell-word)))) | 1346 | (split-string flyword-prev ispell-otherchars)) |
| 1347 | (error "Bug: misspelled word `%s' (output pos %d) not found in buffer" | 1347 | ;; ispell treats beginning of some TeX |
| 1348 | word wordpos))))))) | 1348 | ;; commands as nroff control sequences |
| 1349 | ;; we are done | 1349 | ;; and strips them in the list of |
| 1350 | (if flyspell-issue-message-flag (message "Spell Checking completed."))) | 1350 | ;; misspelled words thus giving a |
| 1351 | ;; Kill and forget the buffer with the list of incorrect words. | 1351 | ;; non-existent word. Skip if ispell |
| 1352 | (kill-buffer flyspell-external-ispell-buffer) | 1352 | ;; is used, string is a TeX command |
| 1353 | (setq flyspell-external-ispell-buffer nil)) | 1353 | ;; (char before beginning of word is |
| 1354 | ;; backslash) and none of the previous | ||
| 1355 | ;; contitions match | ||
| 1356 | (and (not ispell-really-aspell) | ||
| 1357 | (save-excursion | ||
| 1358 | (goto-char (- (nth 1 flyword-prev-l) 1)) | ||
| 1359 | (if (looking-at "[\\]" ) | ||
| 1360 | t | ||
| 1361 | nil)))) | ||
| 1362 | (setq keep nil) | ||
| 1363 | (flyspell-word) | ||
| 1364 | ;; Next search will begin from end of last match | ||
| 1365 | (setq flyspell-large-region-beg match-point)))) | ||
| 1366 | ;; Record if misspelling is not found and try new one | ||
| 1367 | (add-to-list 'words-not-found | ||
| 1368 | (concat " -> " word " - " | ||
| 1369 | (int-to-string wordpos))) | ||
| 1370 | (setq keep nil))))))) | ||
| 1371 | ;; we are done | ||
| 1372 | (if flyspell-issue-message-flag (message "Spell Checking completed."))) | ||
| 1373 | ;; Warn about not found misspellings | ||
| 1374 | (dolist (word words-not-found) | ||
| 1375 | (message "%s: word not found" word)) | ||
| 1376 | ;; Kill and forget the buffer with the list of incorrect words. | ||
| 1377 | (kill-buffer flyspell-external-ispell-buffer) | ||
| 1378 | (setq flyspell-external-ispell-buffer nil))) | ||
| 1354 | 1379 | ||
| 1355 | ;;*---------------------------------------------------------------------*/ | 1380 | ;;*---------------------------------------------------------------------*/ |
| 1356 | ;;* flyspell-process-localwords ... */ | 1381 | ;;* flyspell-process-localwords ... */ |
| @@ -1375,7 +1400,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1375 | (match-end 1))) | 1400 | (match-end 1))) |
| 1376 | ;; This can fail when string contains a word with invalid chars. | 1401 | ;; This can fail when string contains a word with invalid chars. |
| 1377 | ;; Error handling needs to be added between Ispell and Emacs. | 1402 | ;; Error handling needs to be added between Ispell and Emacs. |
| 1378 | (if (and (< 1 (length string)) | 1403 | (if (and (< 1 (length string)) |
| 1379 | (equal 0 (string-match ispell-casechars string))) | 1404 | (equal 0 (string-match ispell-casechars string))) |
| 1380 | (push string localwords)))))) | 1405 | (push string localwords)))))) |
| 1381 | ;; Remove localwords matches from misspellings-buffer. | 1406 | ;; Remove localwords matches from misspellings-buffer. |
| @@ -1419,8 +1444,6 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1419 | (if ispell-local-dictionary | 1444 | (if ispell-local-dictionary |
| 1420 | (setq ispell-dictionary ispell-local-dictionary)) | 1445 | (setq ispell-dictionary ispell-local-dictionary)) |
| 1421 | (setq args (ispell-get-ispell-args)) | 1446 | (setq args (ispell-get-ispell-args)) |
| 1422 | (if (eq ispell-parser 'tex) | ||
| 1423 | (setq args (cons "-t" args))) | ||
| 1424 | (if ispell-dictionary ; use specified dictionary | 1447 | (if ispell-dictionary ; use specified dictionary |
| 1425 | (setq args | 1448 | (setq args |
| 1426 | (append (list "-d" ispell-dictionary) args))) | 1449 | (append (list "-d" ispell-dictionary) args))) |