[Mew-dist 08111] Re: Code conversions on Mew.
Kyotaro HORIGUCHI
kyota at example.com
1999年 3月 16日 (火) 19:27:08 JST
堀口です. Muleの文字コード変換にまつわる問題の続きです.
前にでっち上げたものをもうちょっとまともに仕上げてみました. ベー
スは Mew1.94b13/IM-110 です.
以下の修正で Windows 以外のプラットフォームでも問題がなさそうな
らばこれを元に本体へ修正を加えていただきたいのですがどうでしょう
か?
----------
まず, IM 全体でパラメータをとる引数(?)のバリエーションを追加して,
--optname=hogehoge ;; そのまま opt{optname}='hogehoge' とする.
--optname#=hogehoge ;; hogehoge を B-encode とみなしてデコードして
EUCに変換する.
としました. 変更点は Config.pm, Japanese.pm です.
そのうえで, 先に出した mew-process.elをそれにあわせて変更しまし
た. この版では変換対象は --expression at example.com, --grep at example.com です.
あとは XEmacs での Virtual-mode に対応するために
file-name-coding-system を mew-cs-noconv にしているところなどをや
めればいいはずです. mew-cs-noconv を nil にするのはほかへの影響が
出そうなので, とりあえず grep で見つかったところを修正するパッチ
を添付します.
テストとしては mew-cs-pick はとりあえずは no-conversion に設定す
るだけでいいと思うので 後に添付したパッチを当てた上で .emacs に以
下の行を追加すれば動かせると思います. 実際は mew-cs-pick を使って
いるところを削除すればいいと思います.
(seq mew-cs-pick 'no-conversion)
(add-hook 'mew-init-hook '(lambda ()(require 'mew-process)))
これで解決した問題の場所は名前に漢字を含んだフォルダでの scan,
virtual, pick. さらに漢字を含んだ文字列を pick-pattern に指定した
場合やそれらの併せ技のあたりです.
--
堀口恭太郎
-------------- next part --------------
*** Config.pm.org Tue Mar 16 01:44:40 1999
--- Config.pm Tue Mar 16 02:12:56 1999
***************
*** 14,19 ****
--- 14,21 ----
require 5.003;
require Exporter;
+ use IM::EncDec;
+ use IM::Japanese;
use IM::Util;
use integer;
use strict 'vars';
***************
*** 403,408 ****
--- 405,419 ----
if (/^(--\w+)=(.*)/) {
$name = lc($1);
$val = $2;
+ $desc = $O_DESC{$name} || im_die("unknown option $name\n");
+ $vnam = $O_VNAM{$name};
+ splice(@$argref, $ref, 1);
+ set_value($desc, $vnam, $val, 'opt');
+ } elsif (/^(--\w+)#=(.*)/) {
+ $name = lc($1);
+ $val = $2;
+ $val = &mime_decode_string($val);
+ $val=&conv_jis2euc($val);
$desc = $O_DESC{$name} || im_die("unknown option $name\n");
$vnam = $O_VNAM{$name};
splice(@$argref, $ref, 1);
*** Japanese.pm.org Wed Mar 10 15:33:24 1999
--- Japanese.pm Tue Mar 16 00:03:58 1999
***************
*** 20,26 ****
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(code_check code_check_body
! convert_iso2022jp_body conv_iso2022jp);
=head1 NAME
--- 20,26 ----
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(code_check code_check_body
! convert_iso2022jp_body conv_iso2022jp conv_jis2euc);
=head1 NAME
***************
*** 270,275 ****
--- 270,292 ----
return "$E_jp$cur$E_asc";
}
}
+
+ # conv_jis2euc is based on j2e of jcode.pl 2.0
+ sub conv_jis2euc ($$) {
+ my ($cur, $rest) = @_;
+ $cur =~ s/(\e\$[\@B]|\e\([BJ]|\e\(I)([^\e]*)/&_j2e($1, $2)/geo;
+ return $cur;
+ }
+
+ sub _j2e ($$) {
+ my ($esc, $rest) = @_;
+ if($esc !~ /\e\([BJ]/o) {
+ $rest=~ tr/\041-\176/\241-\376/;
+ $rest =~ s/[\241-\337]/\216$&/g if $esc =~ /\e\(I/o;
+ }
+ return $rest;
+ }
+
##### ISO-2022-JP CODE CONVERSION FROM EUC #####
#
*** mew-mule3.el.org Wed Mar 10 13:34:58 1999
--- mew-mule3.el Tue Mar 16 00:06:08 1999
***************
*** 132,138 ****
(defmacro mew-piolet (read write &rest body)
`(let ((call-process-hook nil)
- (file-name-coding-system mew-cs-noconv) ;; for imgrep
(coding-system-for-read ,read)
(coding-system-for-write ,write))
, at example.com))
--- 132,137 ----
*** mew-scan.el.org Sat Feb 27 10:25:52 1999
--- mew-scan.el Tue Mar 16 00:06:14 1999
***************
*** 100,107 ****
(if (not (mew-summary-exclusive-p))
()
(condition-case nil
! (let ((process-connection-type mew-connection-type1)
! (file-name-coding-system mew-cs-noconv)) ;; for grep
(cond
((string-match mew-prog-imget prog)
(if (string= mew-config-imget mew-config-default)
--- 100,106 ----
(if (not (mew-summary-exclusive-p))
()
(condition-case nil
! (let ((process-connection-type mew-connection-type1))
(cond
((string-match mew-prog-imget prog)
(if (string= mew-config-imget mew-config-default)
***************
*** 115,123 ****
(setq mew-summary-buffer-start-point (point))
(setq mew-summary-buffer-string nil) ;; just in case
(setq mew-summary-buffer-process
! (apply (function start-process)
prog;; name
- (current-buffer)
prog;; program
(format "--width=%d" (if mew-summary-scan-width
mew-summary-scan-width
--- 114,121 ----
(setq mew-summary-buffer-start-point (point))
(setq mew-summary-buffer-string nil) ;; just in case
(setq mew-summary-buffer-process
! (apply (function mew-im-start-process)
prog;; name
prog;; program
(format "--width=%d" (if mew-summary-scan-width
mew-summary-scan-width
-------------- next part --------------
;; mew-process.el
;; mew-process.el encodes arguments passed to im* by same manner to
;; mail-header encoding. this can protect argument from mule argument encoding
;; into native coding system.
;; mew-process-encode-paramter-alist is alist indictes what parameters to
;; be encoded. format is
;; ( (PROGRAM-NAME . LIST-OF-ARGUMENTS-TO-BE-ENCODED) ...)
(defvar mew-process-encode-argument-alist
(list (cons mew-prog-imgrep '("expression"))
(cons mew-prog-imls '("grep"))))
;; mew-process-encode-arguments make argument list encoded.
(defun mew-process-encode-arguments (PROGRAM args)
(let (target param-name param)
(if (setq target (cdr (assoc PROGRAM mew-process-encode-argument-alist)))
(mapcar
(lambda (str)
(if (and (string-match "^--\\([a-zA-Z0-9]+\\)=\\(.*\\)$" str)
(member (setq param-name (match-string 1 str)) target))
(progn
(setq param (match-string 2 str))
(concat "--" param-name "#="
(if (equal (mew-charset-guess-string param)
mew-us-ascii)
param
(mew-header-encode param))))
str))
args) ;; mapcar
args))) ;; else
;; mew-call-process is alternative call-process with process argument
;; encoding for mew
(defun mew-call-process (PROGRAM &optional INFILE BUFFER DISPLAY &rest args)
(interactive)
(apply 'call-process PROGRAM INFILE BUFFER DISPLAY
(mew-process-encode-arguments PROGRAM args)))
;; mew-start-process is alternative start-process with process argument
;; encoding for mew
(defun mew-start-process (NAME BUFFER PROGRAM &rest args)
(interactive)
(apply 'start-process NAME BUFFER PROGRAM
(mew-process-encode-arguments PROGRAM args)))
;; ####################################################################
;; these code overrides mew-funcs.el to use mew-(call|start)-process as
;; substitutes for (call|start)-process
(defun mew-im-call-process (msg prog &rest arg)
(let (ret)
(and msg (message "%s ..." msg))
(setq ret (apply (function mew-call-process)
prog nil t nil (append arg mew-prog-im-arg)))
(if (equal ret 0)
(progn
(and msg (message "%s ... done" msg))
t)
(if msg (message "%s ... failed" msg) (message "failed"))
nil)))
(defun mew-im-call-process-no-output (msg prog &rest arg)
(let (ret)
(and msg (message "%s ..." msg))
(setq ret (apply (function mew-call-process)
prog nil nil nil (append arg mew-prog-im-arg)))
(if (equal ret 0)
(progn
(and msg (message "%s ... done" msg))
t)
(if msg (message "%s ... failed" msg) (message "failed"))
nil)))
(defun mew-im-start-process (prog name &rest arg)
(apply (function mew-start-process)
name (current-buffer) prog
(append arg mew-prog-im-arg)))
(provide 'mew-process)
Mew-dist メーリングリストの案内