From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/9499 Path: news.gmane.org!not-for-mail From: Sven Joachim Newsgroups: gmane.emacs.gnus.user Subject: Re: Changing ispell dictionary Date: Sat, 11 Aug 2007 20:10:23 +0200 Message-ID: <878x8idjsg.fsf@gmx.de> References: <87mywzqw73.fsf@gmx.de> <87r6mbb25g.fsf@baldur.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1186857681 8012 80.91.229.12 (11 Aug 2007 18:41:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 11 Aug 2007 18:41:21 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Sat Aug 11 20:41:16 2007 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IJvtf-0002QA-8r for gegu-info-gnus-english@m.gmane.org; Sat, 11 Aug 2007 20:41:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IJvte-0007Co-Ro for gegu-info-gnus-english@m.gmane.org; Sat, 11 Aug 2007 14:41:10 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!uio.no!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Lines: 46 Original-NNTP-Posting-Host: p54867c1e.dip.t-dialin.net Original-X-Trace: quimby.gnus.org 1186855641 28205 84.134.124.30 (11 Aug 2007 18:07:21 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Sat, 11 Aug 2007 18:07:21 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:OuhzhAXJFYWqurdqJeLmwk5WcSI= Original-Xref: shelby.stanford.edu gnu.emacs.gnus:79687 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:9499 Archived-At: 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