help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Customizing coding priority


From: Piet van Oostrum
Subject: Re: Customizing coding priority
Date: Fri, 19 Jan 2007 15:04:25 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (darwin)

>>>>> Sven Bretfeld <sven.bretfeld@relwi.unibe.ch> (SB) wrote:

>SB> I have inserted 

>SB>  (require 'ucs-tables) 
>SB>  (unify-8859-on-encoding-mode 1)

>SB> in my .emacs file. But it didn't solve the problem. Maybe there is a
>SB> mistake or a shortcoming in the vm-pakage. 

The standard VM just doesn't have the code to encode messages with
characters from mixed charsets properly. If it can't find a single charset
in the message that encodes all characters it chooses iso-2022-jp which is
what you see in your message. This is an encoding that switches between
other encodings with escape sequences. But most people outside Japan will
not be able to read it.

There are two solutions for it AFAIK.

One is a small piece of code I wrote when the Euro was introduces, because
I experienced the same problems when using the €-sign in VM. You just put
this in your .emacs file. I am quite sure it won't work with XEmacs (never
tried) but with Emacs 22 it does work. It follows below. It presupposes
that unify-on-encoding was set.

The other possiblity is to download Robert Widhopf-Fenk's version of VM
from http://www.robf.de/Hacking/elisp. It contains more robust code that
also works on XEmacs. maybe you can load only vm-mime.el, but I am not sure
if it works with all the other files. I am using his whole package without
problems. 

,----
| (defun vm-sort-coding-systems-predicate (a b)
|   (> (length (memq a vm-coding-system-priorities))
|      (length (memq b vm-coding-system-priorities))))
| 
| (setq vm-coding-system-priorities 
|       '(iso-latin-1 iso-latin-9 mule-utf-8 mac-roman)
| ;      '(iso-latin-1 iso-latin-9 windows-1252 mule-utf-8 mac-roman)
|       mm-coding-system-priorities vm-coding-system-priorities)
| 
| ; The next line is for a noautoload vm.elc. Otherwise use "vm-mime".
| ;(eval-after-load "vm"
| ; The next line is for an autoload (default) vm.elc. Otherwise use "vm".
| (eval-after-load "vm-mime"
| '(defun vm-determine-proper-charset (beg end)
|   (save-excursion
|     (save-restriction
|       (narrow-to-region beg end)
|       (catch 'done
|       (goto-char (point-min))
|       (if (or vm-xemacs-mule-p 
|               (and vm-fsfemacs-mule-p enable-multibyte-characters))
|           (let ((charsets (delq 'compound-text (find-coding-systems-region
|                                         (point-min) (point-max)))))
|             (cond ((equal charsets '(undecided))
|                    "us-ascii")
|                   (t
|                    (setq charsets 
|                          (sort charsets 'vm-sort-coding-systems-predicate))
|                    (while charsets
|                      (let ((cs (coding-system-get (pop charsets) 
'mime-charset)))
|                        (if cs
|                            (throw 'done (symbol-name cs))))))))
|         (and (re-search-forward "[^\000-\177]" nil t)
|              (throw 'done (or vm-mime-8bit-composition-charset
|                               "iso-8859-1")))
|         (throw 'done vm-mime-7bit-composition-charset)))))))
| 
| ; This is only necessary for incoming mail in utf-7 or from Windows
| (require 'utf-7)
| (eval-after-load "vm"
|   '(setq vm-mime-mule-charset-to-coding-alist 
|       (cons (quote ("utf-7" utf-7)) 
|           ;code below is to accept mail from those morons that send 
|           ; latin1 or windows-1252 characters without a charset declaration
|           ; (or with charset=ascii)
|           (cons (quote ("us-ascii" windows-1252)) 
|                 (cons (quote ("iso-8859-1" windows-1252)) 
|                       vm-mime-mule-charset-to-coding-alist)))))
`----

-- 
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet@vanoostrum.org


reply via email to

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