🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.editor.mule
Article #118

Re: html-helper-modeでのbuffer-file-coding-systemの設定

#118
From: Seiichi Namba
Date: Tue, 29 May 2001 02:37
88 lines
4130 bytes
難波です。

KANEMATSU Shin'ya <kane@lp.nm.fujitsu.co.jp> さん writes:

>   ところで、html-helper-modeの場合、以下のコメントを認識するようです。
> 
> <!--
> %%% Local Variables: 
> %%% mode: outline-minor
> %%% End: 
> -->
> 
>   よって、たとえば、そこに「%%% coding: sjis-dos」とあったらそちらを優

普通は
local variables の方が html-helper-mode-hook よりも後に eval されるよう
に思うんですが違いましたか。

書き方が違う、ということかな。今、

 (add-hook 'html-helper-mode-hook
              '(lambda ()
                 (setq buffer-file-coding-system 'iso-2022-jp-unix)
		 (message "THEHOOK:%s" buffer-file-coding-system)))

と html-helper-mode-hook を設定した上、

<!
Local Variables:
mode: html-helper
buffer-file-coding-system: sjis-dos
coding-system: junet
version-control: never
End:
>

と書いたファイルを find-file したところ、coding-system は sjis-dos 
になりました。

>     <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
> とあったら、そちらを優先してくれるとありがたいです。(そいうのがみつから
> ない場合は、iso-2022-jp-unixになってほしい。)

これはやはり mode の方が面倒を見るべき事項のように思われます。
つまり、バッファの内容を parse する関数を用意して
html-helper-mode-hook などで呼ぶんでしょうかね。

行きあたりばったりですが

(defun junkfun ()
  (interactive)
  (let ((case-fold-search t))
    (save-excursion
      (goto-char (point-min))
      (search-forward-regexp "charset *= *\\([a-zA-Z _]+\\)" nil t)
      (message "%s"
               (buffer-substring (match-beginning 1) (match-end 1))))))

というような感じで、上の行の "Shift_JIS" というストリングは取り出せました。
あとはテーブルを作って emacs の coding-system に変換して
buffer-file-coding-system に setq する…?。ここから先はお任せします。

出来た奴を html-helper-mode.el の作者に送るといいのかもしれません。
これは世界共通の問題だと思うので。

上のような関数は html-helper-mode-hook に登録しておくか、

eval: (junkfun)

などと local variables に書いておいても呼べます(あまりお勧めしたくな
るような方法ではありませんが)。

>   できれば、html-helper-modeやemacsの標準配布ファイルをいじるのではな
> かく、.emacs等の外にあるファイルで指定できるのがうれしいです。

 .emacs等の外にあるファイルというのがよく判りませんが、上の
ような関数は .emacs(.el) に書いてもいいし、.emacs とは別のファイルに
書いておいてロードしてもどちらでもいいでしょう。

>   emacs-version = "20.4.1"
>   mule-version = "4.0 (HANANOEN)"

20.7 まで来てますよ(20.8 出てます?最近見てないや)。

> #    Elisp20.3のinfoを見たのですが、Local Variables:で指定されたcoding
> #  の値の参照方法さえ見付けることができませんでした。多分、前提知識が

これは上記の通りです。
Technical Details
Message-ID: <9ev217$j2a$1@sn.asahi-net.email.ne.jp>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.media.kyoto-u.ac.jp!onodera-news!yynet.tama.tokyo.jp!nf.asahi-net.or.jp!not-for-mail
References: <yftbsodx9zh.fsf@toya.lp.nm.fujitsu.co.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: 10eba4,303b1f0aa21bcc0c
X-Google-Attributes: gid10eba4,public
X-Google-ArrivalTime: 2001-05-28 19:42:14 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.media.kyoto-u.ac.jp!onodera-news!yynet.tama.tokyo.jp!nf.asahi-net.or.jp!not-for-mail
From: Seiichi Namba <sn@asahi-net.email.ne.jp>
Newsgroups: fj.editor.mule
Subject: Re: html-helper-modeでのbuffer-file-coding-systemの設定
Date: 29 May 2001 11:37:24 +0900
Organization: Smoke
Message-ID: <9ev217$j2a$1@sn.asahi-net.email.ne.jp>
References: <yftbsodx9zh.fsf@toya.lp.nm.fujitsu.co.jp>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 8bit
Lines: 88
NNTP-Posting-Host: h201091.ppp.asahi-net.or.jp
X-Trace: 991104129 news3.asahi-net.or.jp 14358 61.114.201.91
X-Complaints-To: ap-net@asahi-net.or.jp