info-gnus-english
[Top][All Lists]
Advanced

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

Gnus MIME charset advice, with XEmacs


From: Aidan Kehoe
Subject: Gnus MIME charset advice, with XEmacs
Date: Fri, 26 Nov 2004 18:42:16 +0000
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux)

Hi!

I'm not in East Asia, yet I occasionally use Gnus to post messages to Usenet
which venture beyond ISO-8859-1, or, even, ISO-8859-15. The below advice
makes this possible, preferring UTF-8 to the XEmacs default of ISO-2022-JP
and/or multipart encodings. (Nothing but Emacs understands postings that
have been multipart-encoded for different character sets, to my knowledge.)

It's not that full-featured, and should be written to take advantage of
Stephen Turnbull's Latin Unity, and to take notice of
mm-coding-system-priorities. But it does what I want for the moment, and I
think it may be useful for other people wanting to do similar things. 

If you're using the stable version of XEmacs, you'll need to load Mule-UCS
to have Gnus find the UTF-8 coding system. I have; 

  (unless (or (coding-system-p (find-coding-system 'utf-8))
              (null (locate-library "un-define")))
    (require 'un-define)
    (require 'unidata))

in my ~/.xemacs/init.el, which has the nice side affect of also working on,
and not interfering with, 21.5 and its built-in Unicode support. 

Bye, 
        - Aidan

;; Try to get GNUS to do the sane thing when sending messages that can't be
;; encoded in Latin 1.
(defadvice mm-find-mime-charset-region (after do-sane-mime-charset-select
                                               activate)
  "Look at the contents of a message, and if they fit in ASCII, return nil.
If they fit in ISO-8859-1, return `iso-8859-1', otherwise return `utf-8'. 

Should revise this to use Latin Unity, and a configurable list of preferred
MIME character sets. "
  (let ((charsets (delq 'ascii (charsets-in-region (ad-get-arg 0)
                                                    (ad-get-arg 1)))))
    (setq ad-return-value (cond 
                           ((null charsets) nil) 
                           ((and (eq 1 (length charsets)) 
                                 (eq 'latin-iso8859-1 (car charsets)))
                            '(iso-8859-1))
                           (t '(utf-8))))))

-- 
"As democracy is perfected, the office of president represents, more and
more closely, the inner soul of the people. On some great and glorious day
the plain folks of the land will reach their heart's desire at last and the
White House will be adorned by a downright moron." -- H.L. Mencken 


reply via email to

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