Gnus development mailing list
 help / color / mirror / Atom feed
From: "Peter Münster" <pmlists@free.fr>
To: ding@gnus.org
Subject: Re: spell checking message buffer
Date: Fri, 26 Sep 2014 00:05:49 +0200	[thread overview]
Message-ID: <87lhp7icea.fsf@micropit.roche-blanche.homenet.org> (raw)
In-Reply-To: <87zjdoisvf.fsf@lifelogs.com>

On Wed, Sep 24 2014, Ted Zlatanov wrote:

> On Mon, 21 Apr 2014 21:09:33 +0200 Peter Münster <pmlists@free.fr> wrote: 
>
> PM> On Mon, Apr 21 2014, Katsumi Yamaoka wrote:
>>> A quick hack is here:
>>> 
>>> (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




  reply	other threads:[~2014-09-25 22:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21  4:22 Peter Münster
2014-04-21  5:38 ` Katsumi Yamaoka
2014-04-21 19:09   ` Peter Münster
2014-09-24 21:57     ` Ted Zlatanov
2014-09-25 22:05       ` Peter Münster [this message]
2015-01-28  6:16         ` Lars Ingebrigtsen
2015-01-28 16:45           ` Peter Münster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhp7icea.fsf@micropit.roche-blanche.homenet.org \
    --to=pmlists@free.fr \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).