Post by Ted Zlatanov(defun my-ispell-message ()
PM> Thanks! Would it make sense to integrate it into Gnus?
I'm in favor.
Before doing that, here is a slightly enhanced version:
--8<---------------cut here---------------start------------->8---
(defun my-ispell-message ()
"Do ispell on the subject line and the unquoted body lines."
(interactive)
(let ((case-fold-search t)
(res t)
start end)
(message-goto-subject)
(setq end (point))
(beginning-of-line)
(while (memq (char-after) '(?\t ? ))
(forward-line -1))
(when (looking-at "subject:[\t\n ]*\\(?:\\(fwd\\|re\\):[\t\n ]*\\)*")
(setq start (match-end 0)))
(when (< start end)
(unless (ispell-region start end) (setq res nil)))
(message-goto-body)
(while (not (eobp))
(while (and (not (eobp))
(or (looking-at message-cite-prefix-regexp)
(looking-at "<#.*>$")
(looking-at "[\t ]*$")))
(forward-line 1))
(setq start (point))
(while (not (or (eobp)
(looking-at message-cite-prefix-regexp)
(looking-at "<#.*>$")
(looking-at "[\t ]*$")))
(forward-line 1))
(setq end (point-marker))
(unless (ispell-region start end) (setq res nil))
(goto-char end))
(when (markerp end)
(set-marker end nil))
res))
--8<---------------cut here---------------end--------------->8---
First, mml-tags are excluded from spell-checking.
Second, when ispell fails, the function returns nil.
The latter is useful, when this function is called from the
message-send-hook, and while spell-checking the user sees big mistakes
and wants to edit further the message and wishes to stop the sending.
See for example the last line of my message-send-hook:
--8<---------------cut here---------------start------------->8---
(defun pm/message-send ()
(unless (message-field-value gnus-delay-header)
(unless (string-equal pm/role "list")
(if (jl-epg-check-unique-keys (jl-mail-recipients))
(mml-secure-message-sign-encrypt)
(mml-secure-message-sign)))
(or (pm/spell) (keyboard-quit)))) ; here the sending can be cancelled
--8<---------------cut here---------------end--------------->8---
--
Peter