[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to change encoding temporarily?
From: |
Reiner Steib |
Subject: |
Re: How to change encoding temporarily? |
Date: |
Fri, 17 Nov 2006 20:33:20 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (gnu/linux) |
On Fri, Nov 17 2006, Brep wrote:
> ssSslang <sssslang@163.com.removeme> writes:
>
>> Thank you, Reiner. I saw these hooks, but they're not related to mail
>> address. Do you mean I should write a function to select the encoding
>> according to the From header, and then bind it to the hook?
>
> Try this:
>
> (add-hook 'message-send-hook 'change-charset)
> (defun change-charset ()
> (when (message-mail-p)
> (if (string-match "hotmail" (mail-fetch-field "to"))
> (setq mm-coding-system-priorities
> '(iso-8859-1 gbk utf-8))
> (setq mm-coding-system-priorities
> '(iso-8859-1 utf-8)))))
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---
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/