今更ですが、FreeBSD側の作業マシンやファイルサーバの移行のタイミングで、jaJP.eucJP なロケールから jaJP.UTF-8 なロケールへ移ろうと試行錯誤中です。
ports/japanese/jless がちょっと使いにくくなったので ports/misc/lv に移行してみたり、PuTTY + screen + emacs の 256 色環境をやりなおしてみたり。
で、ちょっとはまったのが、メールクライアント Wanderlust の UTF-8 環境での利用でした。
今使っている emacs 22.1 では、なんら問題なく UTF-8 環境を扱うことができます。その emacs の設定さえできていれば、もちろん Wanderlust も UTF-8 で読み書きができます。
が、私の場合はロシア語など、わけのわからないスパムメールが日々届いている環境です。そうすると、いろんなエンコーディングを emacs が丁寧に解釈してレンダリングしてくれようとします。が、最終的に表示しているのは Windows の PuTTY で、これがロシア語などを正しくレンダリングしてくれるとは限らない。
そうすると、メールの一覧表示などがどんどんと崩れていってしまいます。今までは、EUC-JP で表示できないものは ???? などと表示されていたので、読めはしないけどぐちゃぐちゃになることもありませんでした。EUC-JP しかサポートしていないのが逆に良かったわけです。
さて、このままだとメールを読むのが大変になってしまいます。幸いにして、Wanderlustでは一覧表示での差出人、題名の表示部分をカスタマイズすることができます。いろいろと試行錯誤した上で、最終的には以下のようなコードを ~/.wl に入れることで対応しました。
オリジナルの関数と比較して、やっていることといえば、表示しようとしている文字列が EUC-JP で表示できるかどうかを確認して、表示できればそれを表示、できなければそれは使わない、というような処理をしているだけです。
本文を表示してしまうとまた崩れてしまうのですが、とりあえずはこれでいいや、ってことで。
(defun wl-summary-default-from-2 (from)
(let (retval tos ng from0)
(unless
(and (eq major-mode 'wl-summary-mode)
(stringp wl-summary-showto-folder-regexp)
(string-match wl-summary-showto-folder-regexp
(wl-summary-buffer-folder-name))
(wl-address-user-mail-address-p from)
(cond
((and (setq tos (elmo-message-entity-field
wl-message-entity 'to t))
(not (string= "" tos)))
(setq retval
(concat "To:"
(mapconcat
(function
(lambda (to)
(eword-decode-string
(if wl-use-petname
(or
(funcall
wl-summary-get-petname-function to)
(car
(std11-extract-address-components to))
to)
to))))
(wl-parse-addresses tos)
","))))
((setq ng (elmo-message-entity-field
wl-message-entity 'newsgroups))
(setq retval (concat "Ng:" ng)))))
(setq from0 (car (std11-extract-address-components from)))
(unless (and from0
(memq (car (coding-system-get 'euc-japan 'alias-coding-systems))
(find-coding-systems-string from0)))
(setq from0 (nth 1 (std11-extract-address-components from))))
(if wl-use-petname
(setq retval (or (funcall wl-summary-get-petname-function from)
from0
from))
(setq retval from)))
retval))
(setq wl-summary-from-function 'wl-summary-default-from-2)
(defun wl-summary-default-subject-2 (subject-string)
(progn
(if
(or
(eq (car (find-coding-systems-string subject-string))
'undecided)
(memq (car (coding-system-get 'euc-japan 'alias-coding-systems))
(find-coding-systems-string subject-string)))
(setq subject-string subject-string)
(setq subject-string "Unsupported encoding"))
(if (string-match "^[ \t]*\\[[^:]+[,: ][0-9]+\\][ \t]*" subject-string)
(substring subject-string (match-end 0))
subject-string)))
(setq wl-summary-subject-function 'wl-summary-default-subject-2)

コメントする