Subject: 23.2; flyspell ignores first line in message-mode

From: Peter Oliver <[email-masked]>
Date: Sat, 30 Apr 2011 16:38:09 +0100 (BST)

When using flyspell-mode with mail-mode or message-mode, the email header is ignored for spellchecking.

However, this incorrectly assumes that any such buffer will always begin with a header.  I use message-mode to edit the email body only, and I find that flyspell ignores the whole first paragraph of such a buffer.

Attached is a patch that causes flyspell to only try to skip over the header if the message really does begin with a header.

-- 
Peter Oliver

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [email-masked]
# target_branch: nosmart+bzr://bzr.savannah.gnu.org/emacs/trunk/
# testament_sha1: ef8db088392bf8fcaa680a1b3a15c8330d146423
# timestamp: 2011-04-30 16:30:01 +0100
# source_branch: bzr://bzr.savannah.gnu.org/emacs/trunk
# base_revision_id: [email-masked]\
#   wt20qtszxtt47p8y
# 
# Begin patch
=== modified file 'lisp/textmodes/flyspell.el'
--- lisp/textmodes/flyspell.el	2011-04-03 20:59:45 +0000
+++ lisp/textmodes/flyspell.el	2011-04-30 15:29:29 +0000
@@ -316,12 +316,15 @@
   "Function used for `flyspell-generic-check-word-predicate' in Mail mode."
   (let ((header-end (save-excursion
 		      (goto-char (point-min))
-		      (re-search-forward
-		       (concat "^"
-			       (regexp-quote mail-header-separator)
-			       "$")
-		       nil t)
-		      (point)))
+		      (if (not 
+			   (looking-at "^[A-Z]\\(?:\\(?:-[A-Z]\\)?[a-z]*\\)+:"))
+			  0
+			(re-search-forward
+			 (concat "^"
+				 (regexp-quote mail-header-separator)
+				 "$")
+			 nil t)
+			(point))))
 	(signature-begin
          (if (not (boundp 'message-signature-separator))
              (point-max)

# Begin bundle