Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Gnus MIME charset advice, with XEmacs
@ 2004-11-26 18:42 Aidan Kehoe
  0 siblings, 0 replies; only message in thread
From: Aidan Kehoe @ 2004-11-26 18:42 UTC (permalink / raw)



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 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-26 18:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-26 18:42 Gnus MIME charset advice, with XEmacs Aidan Kehoe

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).