aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-05-10 23:30:23 +0000
committerRichard M. Stallman1994-05-10 23:30:23 +0000
commitd1dacaa04933136ca97511983b6bf671b62c36e5 (patch)
tree5a153e6c48b4e2c2f12286048f3addcf1872cc62
parente54d3b5db2a1fca071769083ae89783edddd8ae5 (diff)
downloademacs-d1dacaa04933136ca97511983b6bf671b62c36e5.tar.gz
emacs-d1dacaa04933136ca97511983b6bf671b62c36e5.zip
(ispell-message): Add `ispell-message-text-end' and
`ispell-message-limit'. Spell-check subject as well as body.
-rw-r--r--lisp/textmodes/ispell4.el75
1 files changed, 65 insertions, 10 deletions
diff --git a/lisp/textmodes/ispell4.el b/lisp/textmodes/ispell4.el
index 147e3ea12b0..95b99b5f771 100644
--- a/lisp/textmodes/ispell4.el
+++ b/lisp/textmodes/ispell4.el
@@ -957,10 +957,32 @@ an interior word fragment. `ispell-have-new-look' should be t."
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.
976If it is a string, limit at first occurence of that regular expression.
977Otherwise, 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.
963Don't check spelling of message headers or included messages. 985Don't check spelling of message headers (except subject) or included messages.
964 986
965To spell-check whenever a message is sent, include this line in .emacs: 987To 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))
@@ -983,7 +1005,7 @@ Or you can bind the function to C-c i in gnus or mail with:
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) "\\)" "\\|"
@@ -1009,19 +1031,52 @@ Or you can bind the function to C-c i in gnus or mail with:
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))))))))))))