Mercurial > emacs
comparison lisp/textmodes/=ispell4.el @ 7446:3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
`ispell-message-limit'. Spell-check subject as well as body.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 10 May 1994 23:30:23 +0000 |
parents | 9e51b51e8595 |
children | edf32f56ba70 |
comparison
equal
deleted
inserted
replaced
7445:c9942f71e2e9 | 7446:3b974ab09824 |
---|---|
955 (regexp-quote string))) | 955 (regexp-quote string))) |
956 | 956 |
957 (defvar ispell-message-cite-regexp "^ \\|^\t" | 957 (defvar ispell-message-cite-regexp "^ \\|^\t" |
958 "*Regular expression to match lines cited from one message into another.") | 958 "*Regular expression to match lines cited from one message into another.") |
959 | 959 |
960 (defvar ispell-message-text-end | |
961 (concat "^\\(" (mapconcat (function identity) | |
962 '( | |
963 ;; Matches postscript files. | |
964 "%!PS-Adobe-2.0" | |
965 ;; Matches uuencoded text | |
966 "begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM" | |
967 ;; Matches shell files (esp. auto-decoding) | |
968 "#! /bin/sh" | |
969 ;; Matches difference listing | |
970 "diff -c .*\n\\*\\*\\* .*\n--- " | |
971 ;; Matches "--------------------- cut here" | |
972 "[-=]+\\s cut here") | |
973 "\\|") | |
974 "\\)") | |
975 "*End of text which will be checked in ispell-message. | |
976 If it is a string, limit at first occurence of that regular expression. | |
977 Otherwise, it must be a function which is called to get the limit.") | |
978 | |
979 (defvar ispell-message-limit (* 100 80) | |
980 "*Ispell-message will check no more than this number of characters.") | |
981 | |
960 ;;;###autoload | 982 ;;;###autoload |
961 (defun ispell-message () | 983 (defun ispell-message () |
962 "Check the spelling of a mail message or news post. | 984 "Check the spelling of a mail message or news post. |
963 Don't check spelling of message headers or included messages. | 985 Don't check spelling of message headers (except subject) or included messages. |
964 | 986 |
965 To spell-check whenever a message is sent, include this line in .emacs: | 987 To spell-check whenever a message is sent, include this line in .emacs: |
966 (setq news-inews-hook (setq mail-send-hook 'ispell-message)) | 988 (setq news-inews-hook (setq mail-send-hook 'ispell-message)) |
967 | 989 |
968 Or you can bind the function to C-c i in gnus or mail with: | 990 Or you can bind the function to C-c i in gnus or mail with: |
981 (while (and (looking-at "[a-zA-Z-]+:\\|\t\\| ") | 1003 (while (and (looking-at "[a-zA-Z-]+:\\|\t\\| ") |
982 (not (eobp))) | 1004 (not (eobp))) |
983 (forward-line 1)) | 1005 (forward-line 1)) |
984 (setq non-internal-message t) | 1006 (setq non-internal-message t) |
985 ) | 1007 ) |
986 (let ((cite-regexp ;Prefix of inserted text | 1008 (let* ((cite-regexp ;Prefix of inserted text |
987 (cond | 1009 (cond |
988 ((featurep 'supercite) ; sc 3.0 | 1010 ((featurep 'supercite) ; sc 3.0 |
989 (concat "\\(" (sc-cite-regexp) "\\)" "\\|" | 1011 (concat "\\(" (sc-cite-regexp) "\\)" "\\|" |
990 (ispell-non-empty-string sc-reference-tag-string))) | 1012 (ispell-non-empty-string sc-reference-tag-string))) |
991 ((featurep 'sc) ; sc 2.3 | 1013 ((featurep 'sc) ; sc 2.3 |
1007 ((boundp 'mh-ins-buf-prefix) ; mh mail message | 1029 ((boundp 'mh-ins-buf-prefix) ; mh mail message |
1008 (ispell-non-empty-string mh-ins-buf-prefix)) | 1030 (ispell-non-empty-string mh-ins-buf-prefix)) |
1009 (mail-yank-prefix ; vanilla mail message. | 1031 (mail-yank-prefix ; vanilla mail message. |
1010 (ispell-non-empty-string mail-yank-prefix)) | 1032 (ispell-non-empty-string mail-yank-prefix)) |
1011 (t ispell-message-cite-regexp))) | 1033 (t ispell-message-cite-regexp))) |
1012 (continue t)) | 1034 (continue t) |
1013 | 1035 (limit |
1014 (while (and (not (eobp)) continue) | 1036 (min |
1037 (+ (point-min) ispell-message-limit) | |
1038 (point-max) | |
1039 (save-excursion | |
1040 (cond | |
1041 ((not ispell-message-text-end) (point-max)) | |
1042 ((char-or-string-p ispell-message-text-end) | |
1043 (if (re-search-forward ispell-message-text-end nil 'end) | |
1044 (match-beginning 0) | |
1045 (point-max))) | |
1046 (t (funcall ispell-message-text-end)))))) | |
1047 (search-limit ; Search limit which won't stop in middle of citation | |
1048 (+ limit (length cite-regexp))) | |
1049 ) | |
1050 ;; Check the subject | |
1051 (save-excursion | |
1052 (let ((case-fold-search t) | |
1053 (message-begin (point))) | |
1054 (goto-char (point-min)) | |
1055 ;; "\\s *" matches newline if subject is empty | |
1056 (if (and (re-search-forward "^Subject:[\t ]*" message-begin t) | |
1057 (not (looking-at "re\\>"))) | |
1058 (setq continue | |
1059 (ispell-region (- (point) 1) | |
1060 (progn | |
1061 (end-of-line) | |
1062 (while (looking-at "\n[ \t]") | |
1063 (end-of-line 2)) | |
1064 (point)))) | |
1065 ))) | |
1066 | |
1067 ;; Check the body. | |
1068 (while (and (< (point) limit) continue) | |
1015 ;; Skip across text cited from other messages. | 1069 ;; Skip across text cited from other messages. |
1016 (while (and (looking-at (concat "^[ \t]*$\\|" cite-regexp)) | 1070 (while (and (looking-at (concat "^[ \t]*$\\|" cite-regexp)) |
1017 (not (eobp))) | 1071 (< (point) limit)) |
1018 (forward-line 1)) | 1072 (forward-line 1)) |
1019 (if (not (eobp)) | 1073 (if (< (point) limit) |
1020 ;; Check the next batch of lines that *aren't* cited. | 1074 ;; Check the next batch of lines that *aren't* cited. |
1021 (let ((start (point))) | 1075 (let ((start (point))) |
1022 (if (re-search-forward | 1076 (if (re-search-forward |
1023 (concat "^\\(" cite-regexp "\\)") nil 'end) | 1077 (concat "^\\(" cite-regexp "\\)") search-limit 'end) |
1024 (beginning-of-line)) | 1078 (beginning-of-line)) |
1079 (if (> (point) limit) (goto-char limit)) | |
1025 (let ((case-fold-search old-case-fold-search)) | 1080 (let ((case-fold-search old-case-fold-search)) |
1026 (save-excursion | 1081 (save-excursion |
1027 (setq continue (ispell-region (- start 1) (point)))))))))))) | 1082 (setq continue (ispell-region (- start 1) (point)))))))))))) |
1028 | 1083 |
1029 (provide 'ispell) | 1084 (provide 'ispell) |