From: Zhang Wei <id.brep@gmail.com>
Subject: Re: How to change encoding temporarily?
Date: Sat, 18 Nov 2006 05:27:08 +0800 [thread overview]
Message-ID: <87ac2pepcj.fsf@emacsfans.org> (raw)
In-Reply-To: <v9zmaphnr3.fsf@marauder.physik.uni-ulm.de>
Reiner Steib <reinersteib+gmane@imap.cc> writes:
> I'd suggest something like this (barely tested):
>
> --8<---------------cut here---------------start------------->8---
> (setq sssslang-message-change-charset-regexp "@hotmail\\.com\\>")
> (setq mm-coding-system-priorities '(iso-8859-1 utf-8)))))
> (add-hook 'message-send-mail-hook 'sssslang-message-change-charset)
> (defun sssslang-message-change-charset ()
> (save-restriction
> (message-narrow-to-headers)
> (when (or (string-match sssslang-message-change-charset-regexp
> (or (message-fetch-field "to") ""))
> (string-match sssslang-message-change-charset-regexp
> (or (message-fetch-field "cc") ""))
> (string-match sssslang-message-change-charset-regexp
> (or (message-fetch-field "bcc") "")))
> (set (make-local-variable 'mm-coding-system-priorities)
> '(iso-8859-1 gbk utf-8)))))
> --8<---------------cut here---------------end--------------->8---
Good argument, but there's two subtle details should be point out,
first, we couldn't do this:
(set (make-local-variable 'mm-coding-system-priorities)
'(iso-8859-1 gbk utf-8))
It's a good idea to make a variable buffer local before change
it's value, but perhaps gnus makes a new buffer for the encoded
message, so if we don't change the global value of
`mm-coding-system-priorities', it won't take effect.
second, if we send mail through a SMTP server, be careful with
the message-send-mail-function, set it like this:
(setq message-send-mail-function 'message-smtpmail-send-it)
not,
(setq message-send-mail-function 'smtpmail-send-it)
otherwise the `message-send-mail-hook' won't run.
so something like this should cope with the problem:
--8<---------------cut here---------------start------------->8---
(setq sssslang-message-change-charset-regexp "@hotmail\\.com\\>")
(setq mm-coding-system-priorities '(iso-8859-1 utf-8))
(add-hook 'message-send-mail-hook 'sssslang-message-change-charset)
(defun sssslang-message-change-charset ()
(save-restriction
(message-narrow-to-headers)
(if (or (string-match sssslang-message-change-charset-regexp
(or (message-fetch-field "to") ""))
(string-match sssslang-message-change-charset-regexp
(or (message-fetch-field "cc") ""))
(string-match sssslang-message-change-charset-regexp
(or (message-fetch-field "bcc") "")))
(setq mm-coding-system-priorities
'(iso-8859-1 gbk utf-8))
(setq mm-coding-system-priorities
'(iso-8859-1 utf-8)))))
--8<---------------cut here---------------end--------------->8---
--
荣华我已知庄梦
忠愤人将谓杞忧
next prev parent reply other threads:[~2006-11-17 21:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-17 12:28 ssSslang
2006-11-17 13:16 ` Reiner Steib
2006-11-17 13:46 ` ssSslang
2006-11-17 15:53 ` Brep
2006-11-17 19:33 ` Reiner Steib
2006-11-17 21:27 ` Zhang Wei [this message]
2006-11-18 6:37 ` ssSslang
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=87ac2pepcj.fsf@emacsfans.org \
--to=id.brep@gmail.com \
/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).