Mercurial > emacs
comparison lisp/textmodes/flyspell.el @ 66855:30d90742b0a8
(flyspell-large-region): Call flyspell-accept-buffer-local-defs.
(flyspell-notify-misspell): Fix misspelling of "Misspelling".
(flyspell-process-localwords): New function.
(flyspell-large-region): Call flyspell-process-localwords and
flyspell-delete-region-overlays.
(flyspell-delete-region-overlays): New function.
(flyspell-delete-all-overlays): Call that.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 14 Nov 2005 04:53:00 +0000 |
parents | 8bf6bc8d7145 |
children | bf55d63c7dd6 |
comparison
equal
deleted
inserted
replaced
66854:0e159d758b16 | 66855:30d90742b0a8 |
---|---|
945 poss | 945 poss |
946 (if flyspell-sort-corrections | 946 (if flyspell-sort-corrections |
947 (sort (car (cdr (cdr poss))) 'string<) | 947 (sort (car (cdr (cdr poss))) 'string<) |
948 (car (cdr (cdr poss))))))) | 948 (car (cdr (cdr poss))))))) |
949 (if flyspell-issue-message-flag | 949 (if flyspell-issue-message-flag |
950 (message "mispelling `%s' %S" word replacements)))) | 950 (message "misspelling `%s' %S" word replacements)))) |
951 | 951 |
952 ;*---------------------------------------------------------------------*/ | 952 ;*---------------------------------------------------------------------*/ |
953 ;* flyspell-word-search-backward ... */ | 953 ;* flyspell-word-search-backward ... */ |
954 ;*---------------------------------------------------------------------*/ | 954 ;*---------------------------------------------------------------------*/ |
955 (defun flyspell-word-search-backward (word bound) | 955 (defun flyspell-word-search-backward (word bound) |
1373 ;; Kill and forget the buffer with the list of incorrect words. | 1373 ;; Kill and forget the buffer with the list of incorrect words. |
1374 (kill-buffer flyspell-external-ispell-buffer) | 1374 (kill-buffer flyspell-external-ispell-buffer) |
1375 (setq flyspell-external-ispell-buffer nil)) | 1375 (setq flyspell-external-ispell-buffer nil)) |
1376 | 1376 |
1377 ;*---------------------------------------------------------------------*/ | 1377 ;*---------------------------------------------------------------------*/ |
1378 ;* flyspell-process-localwords ... */ | |
1379 ;* ------------------------------------------------------------- */ | |
1380 ;* This function is used to prevent marking of words explicitly */ | |
1381 ;* declared correct. */ | |
1382 ;*---------------------------------------------------------------------*/ | |
1383 (defun flyspell-process-localwords (misspellings-buffer) | |
1384 (let (localwords | |
1385 (ispell-casechars (ispell-get-casechars))) | |
1386 ;; Get localwords from the original buffer | |
1387 (save-excursion | |
1388 (goto-char (point-min)) | |
1389 ;; Localwords parsing copied from ispell.el. | |
1390 (while (search-forward ispell-words-keyword nil t) | |
1391 (let ((end (save-excursion (end-of-line) (point))) | |
1392 string) | |
1393 ;; buffer-local words separated by a space, and can contain | |
1394 ;; any character other than a space. Not rigorous enough. | |
1395 (while (re-search-forward " *\\([^ ]+\\)" end t) | |
1396 (setq string (buffer-substring-no-properties (match-beginning 1) | |
1397 (match-end 1))) | |
1398 ;; This can fail when string contains a word with invalid chars. | |
1399 ;; Error handling needs to be added between Ispell and Emacs. | |
1400 (if (and (< 1 (length string)) | |
1401 (equal 0 (string-match ispell-casechars string))) | |
1402 (push string localwords)))))) | |
1403 ;; Remove localwords matches from misspellings-buffer. | |
1404 ;; The usual mechanism of communicating the local words to ispell | |
1405 ;; does not affect the special ispell process used by | |
1406 ;; flyspell-large-region. | |
1407 (with-current-buffer misspellings-buffer | |
1408 (save-excursion | |
1409 (dolist (word localwords) | |
1410 (goto-char (point-min)) | |
1411 (let ((regexp (concat "^" word "\n"))) | |
1412 (while (re-search-forward regexp nil t) | |
1413 (delete-region (match-beginning 0) (match-end 0))))))))) | |
1414 | |
1415 ;*---------------------------------------------------------------------*/ | |
1378 ;* flyspell-large-region ... */ | 1416 ;* flyspell-large-region ... */ |
1379 ;*---------------------------------------------------------------------*/ | 1417 ;*---------------------------------------------------------------------*/ |
1380 (defun flyspell-large-region (beg end) | 1418 (defun flyspell-large-region (beg end) |
1381 (let* ((curbuf (current-buffer)) | 1419 (let* ((curbuf (current-buffer)) |
1382 (buffer (get-buffer-create "*flyspell-region*"))) | 1420 (buffer (get-buffer-create "*flyspell-region*"))) |
1383 (setq flyspell-external-ispell-buffer buffer) | 1421 (setq flyspell-external-ispell-buffer buffer) |
1384 (setq flyspell-large-region-buffer curbuf) | 1422 (setq flyspell-large-region-buffer curbuf) |
1385 (setq flyspell-large-region-beg beg) | 1423 (setq flyspell-large-region-beg beg) |
1386 (setq flyspell-large-region-end end) | 1424 (setq flyspell-large-region-end end) |
1425 (flyspell-accept-buffer-local-defs) | |
1387 (set-buffer buffer) | 1426 (set-buffer buffer) |
1388 (erase-buffer) | 1427 (erase-buffer) |
1389 ;; this is done, we can start checking... | 1428 ;; this is done, we can start checking... |
1390 (if flyspell-issue-message-flag (message "Checking region...")) | 1429 (if flyspell-issue-message-flag (message "Checking region...")) |
1391 (set-buffer curbuf) | 1430 (set-buffer curbuf) |
1414 (expand-file-name | 1453 (expand-file-name |
1415 ispell-personal-dictionary))))) | 1454 ispell-personal-dictionary))))) |
1416 (setq args (append args ispell-extra-args)) | 1455 (setq args (append args ispell-extra-args)) |
1417 args)))) | 1456 args)))) |
1418 (if (eq c 0) | 1457 (if (eq c 0) |
1419 (flyspell-external-point-words) | 1458 (progn |
1459 (flyspell-process-localwords buffer) | |
1460 (with-current-buffer curbuf | |
1461 (flyspell-delete-region-overlays beg end)) | |
1462 (flyspell-external-point-words)) | |
1420 (error "Can't check region..."))))) | 1463 (error "Can't check region..."))))) |
1421 | 1464 |
1422 ;*---------------------------------------------------------------------*/ | 1465 ;*---------------------------------------------------------------------*/ |
1423 ;* flyspell-region ... */ | 1466 ;* flyspell-region ... */ |
1424 ;* ------------------------------------------------------------- */ | 1467 ;* ------------------------------------------------------------- */ |
1501 (defun flyspell-overlay-p (o) | 1544 (defun flyspell-overlay-p (o) |
1502 "A predicate that return true iff O is an overlay used by flyspell." | 1545 "A predicate that return true iff O is an overlay used by flyspell." |
1503 (and (overlayp o) (overlay-get o 'flyspell-overlay))) | 1546 (and (overlayp o) (overlay-get o 'flyspell-overlay))) |
1504 | 1547 |
1505 ;*---------------------------------------------------------------------*/ | 1548 ;*---------------------------------------------------------------------*/ |
1506 ;* flyspell-delete-all-overlays ... */ | 1549 ;* flyspell-delete-region-overlays, flyspell-delete-all-overlays */ |
1507 ;* ------------------------------------------------------------- */ | 1550 ;* ------------------------------------------------------------- */ |
1508 ;* Remove all the overlays introduced by flyspell. */ | 1551 ;* Remove overlays introduced by flyspell. */ |
1509 ;*---------------------------------------------------------------------*/ | 1552 ;*---------------------------------------------------------------------*/ |
1510 (defun flyspell-delete-all-overlays () | 1553 (defun flyspell-delete-region-overlays (beg end) |
1511 "Delete all the overlays used by flyspell." | 1554 "Delete overlays used by flyspell in a given region." |
1512 (let ((l (overlays-in (point-min) (point-max)))) | 1555 (let ((l (overlays-in beg end))) |
1513 (while (consp l) | 1556 (while (consp l) |
1514 (progn | 1557 (progn |
1515 (if (flyspell-overlay-p (car l)) | 1558 (if (flyspell-overlay-p (car l)) |
1516 (delete-overlay (car l))) | 1559 (delete-overlay (car l))) |
1517 (setq l (cdr l)))))) | 1560 (setq l (cdr l)))))) |
1561 | |
1562 | |
1563 (defun flyspell-delete-all-overlays () | |
1564 "Delete all the overlays used by flyspell." | |
1565 (flyspell-delete-region-overlays (point-min) (point-max))) | |
1518 | 1566 |
1519 ;*---------------------------------------------------------------------*/ | 1567 ;*---------------------------------------------------------------------*/ |
1520 ;* flyspell-unhighlight-at ... */ | 1568 ;* flyspell-unhighlight-at ... */ |
1521 ;*---------------------------------------------------------------------*/ | 1569 ;*---------------------------------------------------------------------*/ |
1522 (defun flyspell-unhighlight-at (pos) | 1570 (defun flyspell-unhighlight-at (pos) |