* Changing ispell dictionary
@ 2007-08-10 14:51 Sven Joachim
2007-08-10 19:49 ` Tassilo Horn
2007-10-19 22:37 ` sven.bretfeld
0 siblings, 2 replies; 12+ messages in thread
From: Sven Joachim @ 2007-08-10 14:51 UTC (permalink / raw)
To: info-gnus-english
Hi,
I am looking for an efficient way to change the ispell dictionary based
on the newsgroup or mail recipients I'm posting/mailing to. The
Manual says in section 5.4, "Mail and Post":
,----
| If you want to change the `ispell' dictionary based on what group
| you're in, you could say something like the following:
|
| (add-hook 'gnus-select-group-hook
| (lambda ()
| (cond
| ((string-match
| "^de\\." (gnus-group-real-name gnus-newsgroup-name))
| (ispell-change-dictionary "deutsch"))
| (t
| (ispell-change-dictionary "english")))))
`----
This does not work, unfortunately. It will only change the dictionary
_local_ in the summary buffer, but not in the buffer for the message I
am going to compose. Right now I work around this by using
(ispell-change-dictionary "deutsch" 1) to change the global
dictionary instead, but I find this suboptimal.
Does somebody have a bright idea how to automatically change the local
dictionary in the message buffer (assuming that a newsgroup or mail
recipient is known; of course it cannot be guessed if I just type
C-x m outside of Gnus)? There are various *message-*hook variables
and I don't know which to choose.
Cheers,
Sven
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Changing ispell dictionary
2007-08-10 14:51 Changing ispell dictionary Sven Joachim
@ 2007-08-10 19:49 ` Tassilo Horn
2007-08-10 20:20 ` Tassilo Horn
` (2 more replies)
2007-10-19 22:37 ` sven.bretfeld
1 sibling, 3 replies; 12+ messages in thread
From: Tassilo Horn @ 2007-08-10 19:49 UTC (permalink / raw)
To: info-gnus-english
Sven Joachim <svenjoac@gmx.de> writes:
Hi Sven,
> Does somebody have a bright idea how to automatically change the local
> dictionary in the message buffer (assuming that a newsgroup or mail
> recipient is known; of course it cannot be guessed if I just type C-x
> m outside of Gnus)? There are various *message-*hook variables and I
> don't know which to choose.
At least for newsgroups you could do something like this:
--8<---------------cut here---------------start------------->8---
(defun th-switch-ispell-dictionary ()
(save-excursion
(message-goto-newsgroups)
(let ((newsgroups (buffer-substring-no-properties
(line-beginning-position) (line-end-position))))
(cond ((string-match (rx " de.") newsgroups)
(ispell-change-dictionary "german"))
((string-match (rx " fr.") newsgroups)
(ispell-change-dictionary "french"))
(t
(ispell-change-dictionary "english"))))))
--8<---------------cut here---------------end--------------->8---
I didn't test it, but I wouldn't be too surprised if it works. ;-)
For mail recipients you could probably use a field in the bbdb which
indicates the receivers language, or simply guess by the top-level
domain of the email address.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Changing ispell dictionary
2007-08-10 19:49 ` Tassilo Horn
@ 2007-08-10 20:20 ` Tassilo Horn
2007-08-10 20:30 ` Reiner Steib
[not found] ` <mailman.4633.1186777273.32220.info-gnus-english@gnu.org>
2 siblings, 0 replies; 12+ messages in thread
From: Tassilo Horn @ 2007-08-10 20:20 UTC (permalink / raw)
To: info-gnus-english
Tassilo Horn <tassilo@member.fsf.org> writes:
Hi again,
> I didn't test it, but I wouldn't be too surprised if it works. ;-)
Well, I thought it could be useful for me, too, so I tried it. It
didn't work. Below is a working version.
> For mail recipients you could probably use a field in the bbdb which
> indicates the receivers language, or simply guess by the top-level
> domain of the email address.
That's what I do now.
--8<---------------cut here---------------start------------->8---
(defun th-switch-ispell-dictionary ()
(save-excursion
(goto-char (point-min))
(re-search-forward (rx bol (group (or "To:" "Newsgroups:"))))
(if (string= (match-string 1) "Newsgroups:")
(let ((newsgroups (buffer-substring-no-properties
(line-beginning-position) (line-end-position))))
(cond ((string-match (rx " de.") newsgroups)
(ispell-change-dictionary "german"))
(t
(ispell-change-dictionary "english"))))
(let ((to (buffer-substring-no-properties
(line-beginning-position) (line-end-position))))
(cond ((string-match (rx ".de" (not (any word))) to)
(ispell-change-dictionary "german"))
(t
(ispell-change-dictionary "english")))))))
(add-hook 'message-setup-hook 'th-switch-ispell-dictionary)
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
--
Chuck Norris' favorite cereal is Kellogg's Nails 'N' Gravel.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Changing ispell dictionary
2007-08-10 19:49 ` Tassilo Horn
2007-08-10 20:20 ` Tassilo Horn
@ 2007-08-10 20:30 ` Reiner Steib
2007-08-10 21:09 ` Tassilo Horn
[not found] ` <mailman.4635.1186780214.32220.info-gnus-english@gnu.org>
[not found] ` <mailman.4633.1186777273.32220.info-gnus-english@gnu.org>
2 siblings, 2 replies; 12+ messages in thread
From: Reiner Steib @ 2007-08-10 20:30 UTC (permalink / raw)
To: info-gnus-english
On Fri, Aug 10 2007, Tassilo Horn wrote:
> (message-goto-newsgroups)
> (let ((newsgroups (buffer-substring-no-properties
> (line-beginning-position) (line-end-position))))
`message-fetch-field'
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Changing ispell dictionary
2007-08-10 20:30 ` Reiner Steib
@ 2007-08-10 21:09 ` Tassilo Horn
[not found] ` <mailman.4635.1186780214.32220.info-gnus-english@gnu.org>
1 sibling, 0 replies; 12+ messages in thread
From: Tassilo Horn @ 2007-08-10 21:09 UTC (permalink / raw)
To: info-gnus-english
Reiner Steib <reinersteib+gmane@imap.cc> writes:
Hi Reiner,
>> (message-goto-newsgroups)
>> (let ((newsgroups (buffer-substring-no-properties
>> (line-beginning-position) (line-end-position))))
>
> `message-fetch-field'
Oh, much easier. Thanks for that pointer. Now that's what I use:
--8<---------------cut here---------------start------------->8---
(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)
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.4635.1186780214.32220.info-gnus-english@gnu.org>]
* Re: Changing ispell dictionary
[not found] ` <mailman.4635.1186780214.32220.info-gnus-english@gnu.org>
@ 2007-08-11 18:10 ` Sven Joachim
2007-08-11 18:59 ` Tassilo Horn
0 siblings, 1 reply; 12+ messages in thread
From: Sven Joachim @ 2007-08-11 18:10 UTC (permalink / raw)
To: info-gnus-english
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Changing ispell dictionary
2007-08-11 18:10 ` Sven Joachim
@ 2007-08-11 18:59 ` Tassilo Horn
0 siblings, 0 replies; 12+ messages in thread
From: Tassilo Horn @ 2007-08-11 18:59 UTC (permalink / raw)
To: info-gnus-english
Sven Joachim <svenjoac@gmx.de> writes:
Hi Sven,
> 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:
>
> [...]
Oh, right. Thanks for the correction.
Best regards,
Tassilo
--
There are no steroids in baseball. Just players Chuck Norris has
breathed on.
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.4633.1186777273.32220.info-gnus-english@gnu.org>]
* Re: Changing ispell dictionary
[not found] ` <mailman.4633.1186777273.32220.info-gnus-english@gnu.org>
@ 2007-08-11 10:31 ` Hadron
0 siblings, 0 replies; 12+ messages in thread
From: Hadron @ 2007-08-11 10:31 UTC (permalink / raw)
To: info-gnus-english
Tassilo Horn <tassilo@member.fsf.org> writes:
> Tassilo Horn <tassilo@member.fsf.org> writes:
>
> Hi again,
>
>> I didn't test it, but I wouldn't be too surprised if it works. ;-)
>
> Well, I thought it could be useful for me, too, so I tried it. It
> didn't work. Below is a working version.
>
>> For mail recipients you could probably use a field in the bbdb which
>> indicates the receivers language, or simply guess by the top-level
>> domain of the email address.
>
> That's what I do now.
>
> (defun th-switch-ispell-dictionary ()
> (save-excursion
> (goto-char (point-min))
> (re-search-forward (rx bol (group (or "To:" "Newsgroups:"))))
> (if (string= (match-string 1) "Newsgroups:")
> (let ((newsgroups (buffer-substring-no-properties
> (line-beginning-position) (line-end-position))))
> (cond ((string-match (rx " de.") newsgroups)
> (ispell-change-dictionary "german"))
> (t
> (ispell-change-dictionary "english"))))
> (let ((to (buffer-substring-no-properties
> (line-beginning-position) (line-end-position))))
> (cond ((string-match (rx ".de" (not (any word))) to)
> (ispell-change-dictionary "german"))
> (t
> (ispell-change-dictionary "english")))))))
>
> (add-hook 'message-setup-hook 'th-switch-ispell-dictionary)
>
> Bye,
> Tassilo
I would be very interested in this code using the bbdb idea instead (top
level domains are not indicative of persons real or favorite language in
this global world) - look for existence of a bbdb alias called
"language" and if it exists then switch to it with
ispell-change-dictionary
... :-;
--
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Changing ispell dictionary
2007-08-10 14:51 Changing ispell dictionary Sven Joachim
2007-08-10 19:49 ` Tassilo Horn
@ 2007-10-19 22:37 ` sven.bretfeld
2007-11-03 23:16 ` leandro noferini
1 sibling, 1 reply; 12+ messages in thread
From: sven.bretfeld @ 2007-10-19 22:37 UTC (permalink / raw)
To: info-gnus-english
[-- Attachment #1.1: Type: text/plain, Size: 541 bytes --]
Hi Sven
Maybe this is what you need:
(setq gnus-posting-styles
'(("emacs-liste"
(address "sven.bretfeld@gmx.ch")
(eval (setq ispell-local-dictionary "american")))
("auctex-liste"
(address "sven.bretfeld@gmx.ch")
(eval (setq ispell-local-dictionary "american")))))
emacs-liste and auctex-liste are names of mailboxes. If I send a
message to one of these groups, my mail-address is automatically
changes to the gmx.ch and the ispell-dictionary switches to "american"
instead of "swiss" which is my default.
Greetings,
Sven
[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
http://lists.gnu.org/mailman/listinfo/info-gnus-english
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2007-11-05 16:17 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-10 14:51 Changing ispell dictionary Sven Joachim
2007-08-10 19:49 ` Tassilo Horn
2007-08-10 20:20 ` Tassilo Horn
2007-08-10 20:30 ` Reiner Steib
2007-08-10 21:09 ` Tassilo Horn
[not found] ` <mailman.4635.1186780214.32220.info-gnus-english@gnu.org>
2007-08-11 18:10 ` Sven Joachim
2007-08-11 18:59 ` Tassilo Horn
[not found] ` <mailman.4633.1186777273.32220.info-gnus-english@gnu.org>
2007-08-11 10:31 ` Hadron
2007-10-19 22:37 ` sven.bretfeld
2007-11-03 23:16 ` leandro noferini
2007-11-04 19:35 ` Sven Bretfeld
2007-11-05 16:17 ` leandro noferini
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).