Commit 7492978d authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(ispell-message-text-end): New variable.

(ispell-message): Use ispell-message-text-end.
Spell check all of a multi-line subject.
Correct bug whereby internally generated messages were not recognized.
parent 007852e0
...@@ -1706,8 +1706,26 @@ inside of a word." ...@@ -1706,8 +1706,26 @@ inside of a word."
;;; ********************************************************************** ;;; **********************************************************************
;;; Ispell Message ;;; Ispell Message
;;; ********************************************************************** ;;; **********************************************************************
;;; Original from Daniel Quinlan, Ethan Bradford, and Alon Albert ;;; Original from D. Quinlan, E. Bradford, A. Albert, and M. Ernst
(defvar ispell-message-text-end
(mapconcat (function identity)
'(
;; Matches postscript files.
"^%!PS-Adobe-2.0"
;; Matches uuencoded text
"^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM"
;; Matches shell files (esp. auto-decoding)
"^#! /bin/sh"
;; Matches difference listing
"diff -c .*\n\\*\\*\\* .*\n--- "
;; Matches "----------------- cut here"
"^[-=]+\\s cut here")
"\\|")
"*End of text which will be checked in ispell-message.
If it is a string, limit at first occurence of that regular expression.
Otherwise, it must be a function which is called to get the limit.")
;;;###autoload ;;;###autoload
(defun ispell-message () (defun ispell-message ()
...@@ -1729,33 +1747,43 @@ Or you can bind the function C-c i in gnus or mail by setting ...@@ -1729,33 +1747,43 @@ Or you can bind the function C-c i in gnus or mail by setting
news-reply-mode-hook or mail-mode-hook to the following lambda expression: news-reply-mode-hook or mail-mode-hook to the following lambda expression:
(function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))" (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))"
(interactive) (interactive)
(let* ((internal-messagep (save-excursion (save-excursion
(search-forward mail-header-separator nil t))) (beginning-of-buffer)
(cite-regexp ;Prefix of inserted text (let* ((internal-messagep
(cond (search-forward mail-header-separator nil t))
((featurep 'supercite) ; sc 3.0 (limit
(concat "\\(" (sc-cite-regexp) "\\)" "\\|" (cond
(ispell-non-empty-string sc-reference-tag-string))) ((not ispell-message-text-end) (point-max))
((featurep 'sc) ; sc 2.3 ((char-or-string-p ispell-message-text-end)
(concat "\\(" sc-cite-regexp "\\)" "\\|" (if (re-search-forward ispell-message-text-end nil t)
(ispell-non-empty-string sc-reference-tag-string))) (match-beginning 0)
((equal major-mode 'news-reply-mode) ;Gnus (point-max)))
(concat "In article <" "\\|" (t (min (point-max) (funcall ispell-message-text-end)))))
(if mail-yank-prefix (cite-regexp ;Prefix of inserted text
(ispell-non-empty-string mail-yank-prefix) (cond
"^ \\|^\t"))) ((featurep 'supercite) ; sc 3.0
((equal major-mode 'mh-letter-mode) ; mh mail message (concat "\\(" (sc-cite-regexp) "\\)" "\\|"
(ispell-non-empty-string mh-ins-buf-prefix)) (ispell-non-empty-string sc-reference-tag-string)))
((not internal-messagep) ; Assume n sent us this message. ((featurep 'sc) ; sc 2.3
(concat "In [a-zA-Z.]+ you write:" "\\|" (concat "\\(" sc-cite-regexp "\\)" "\\|"
"In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|" (ispell-non-empty-string sc-reference-tag-string)))
" *> *")) ((equal major-mode 'news-reply-mode) ;Gnus
((boundp 'vm-included-text-prefix) ; VM mail message (concat "In article <" "\\|"
(concat "[^,;&+=]+ writes:" "\\|" (if mail-yank-prefix
(ispell-non-empty-string vm-included-text-prefix))) (ispell-non-empty-string mail-yank-prefix)
(mail-yank-prefix ; vanilla mail message. "^ \\|^\t")))
(ispell-non-empty-string mail-yank-prefix)) ((equal major-mode 'mh-letter-mode) ; mh mail message
(t "^ \\|^\t"))) (ispell-non-empty-string mh-ins-buf-prefix))
((not internal-messagep) ; Assume nn sent us this message.
(concat "In [a-zA-Z.]+ you write:" "\\|"
"In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|"
" *> *"))
((boundp 'vm-included-text-prefix) ; VM mail message
(concat "[^,;&+=]+ writes:" "\\|"
(ispell-non-empty-string vm-included-text-prefix)))
(mail-yank-prefix ; vanilla mail message.
(ispell-non-empty-string mail-yank-prefix))
(t "^ \\|^\t")))
(cite-regexp-start (concat "^[ \t]*$\\|" cite-regexp)) (cite-regexp-start (concat "^[ \t]*$\\|" cite-regexp))
(cite-regexp-end (concat "^\\(" cite-regexp "\\)")) (cite-regexp-end (concat "^\\(" cite-regexp "\\)"))
(old-case-fold-search case-fold-search) (old-case-fold-search case-fold-search)
...@@ -1769,31 +1797,38 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression: ...@@ -1769,31 +1797,38 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression:
(< (point) internal-messagep) (< (point) internal-messagep)
(and (looking-at "[a-zA-Z---]+:\\|\t\\| ") (and (looking-at "[a-zA-Z---]+:\\|\t\\| ")
(not (eobp)))) (not (eobp))))
(if (and (not (looking-at "Subject: .*Re:"))
(not (looking-at "Subject: +\\[")) ;; spell check Subject: field without Re:'s.
(looking-at "Subject:")) ; last so (match-end 0) works right. (if (looking-at "Subject: *")
;; spell check Subject: field without Re:'s. (progn
(let ((case-fold-search old-case-fold-search)) (goto-char (match-end 0))
(end-of-line) (if (and (not (looking-at ".*Re\\>"))
(ispell-region (match-end 0) (point)))) (not (looking-at "\\[")))
(let ((case-fold-search old-case-fold-search))
(ispell-region (point)
(progn
(end-of-line)
(while (looking-at "\n[ \t]")
(end-of-line 2))
(point)))))))
(forward-line 1)) (forward-line 1))
(setq case-fold-search nil) (setq case-fold-search nil)
;; Skip mail header, particularly for non-english languages. ;; Skip mail header, particularly for non-english languages.
(if (looking-at mail-header-separator) (if (looking-at mail-header-separator)
(forward-line 1)) (forward-line 1))
(while (not (eobp)) (while (< (point) limit)
;; Skip across text cited from other messages. ;; Skip across text cited from other messages.
(while (and (looking-at cite-regexp-start) (while (and (looking-at cite-regexp-start)
(not (eobp))) (< (point) limit))
(forward-line 1)) (forward-line 1))
(if (not (eobp)) (if (< (point) limit)
;; Check the next batch of lines that *aren't* cited. ;; Check the next batch of lines that *aren't* cited.
(let ((end (save-excursion (let ((end (save-excursion
(if (re-search-forward cite-regexp-end nil 'end) (if (re-search-forward cite-regexp-end limit 'end)
(beginning-of-line)) (match-beginning 0)
(point)))) limit))))
(ispell-region (point) end) (ispell-region (point) end)
(goto-char end))))))) (goto-char end))))))))
(defun ispell-non-empty-string (string) (defun ispell-non-empty-string (string)
(if (or (not string) (string-equal string "")) (if (or (not string) (string-equal string ""))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment