Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Aidan Kehoe <kehoea@parhasard.net>
Subject: Gnus MIME charset advice, with XEmacs
Date: Fri, 26 Nov 2004 18:42:16 +0000	[thread overview]
Message-ID: <lvmzx4a1vb.fsf@ns5.nestdesign.com> (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 


                 reply	other threads:[~2004-11-26 18:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=lvmzx4a1vb.fsf@ns5.nestdesign.com \
    --to=kehoea@parhasard.net \
    /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).