info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing ispell dictionary


From: Sven Joachim
Subject: Re: Changing ispell dictionary
Date: Sat, 11 Aug 2007 20:10:23 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Hello Tassilo,

many thanks for your suggestions.  I'm using your last code snippet
now, with one correction:

> (defun th-message-switch-ispell-dictionary ()
>   (save-excursion
>     (message-narrow-to-headers-or-head)
>     (let ((newsgroups (message-fetch-field "Newsgroups"))
>           (to         (message-fetch-field "To")))
>       (message "newsgroup or to = %s." (or newsgroups to))
>       (if newsgroups
>           (cond ((string-match (rx bol (or "de." "infko.")) newsgroups)
>                  (ispell-change-dictionary "german"))
>                 (t
>                  (ispell-change-dictionary "english")))
>         (cond ((string-match (rx ".de" (or (not (any word)) eol)) to)
>                (ispell-change-dictionary "german"))
>               (t
>                (ispell-change-dictionary "english")))))))
>
> (add-hook 'message-setup-hook 'th-message-switch-ispell-dictionary)

This has the problem that both newsgroups and to can be nil, e.g. when
composing a brand new message outside Gnus with C-x m.  In this case
an error occurs in the second string-match.  Here is a corrected
version:

(defun th-message-switch-ispell-dictionary ()
  (save-excursion
    (message-narrow-to-headers-or-head)
    (let ((newsgroups (message-fetch-field "Newsgroups"))
          (to         (message-fetch-field "To")))
      (message "newsgroup or to = %s." (or newsgroups to))
      (if newsgroups
          (cond ((string-match (rx bol (or "de." "infko.")) newsgroups)
                 (ispell-change-dictionary "german"))
                (t
                 (ispell-change-dictionary "english")))
        (cond ((and to (string-match (rx ".de" (or (not (any word)) eol)) to))
               (ispell-change-dictionary "german"))
              (t
               (ispell-change-dictionary "english")))))))

Cheers,
       Sven


reply via email to

[Prev in Thread] Current Thread [Next in Thread]