🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.editor.mule
Article #121

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

#121
From: Seiichi Namba
Date: Thu, 31 May 2001 03:17
49 lines
2821 bytes
難波です。

Seiichi Namba <sn@asahi-net.email.ne.jp> さん writes:

> save-buffer-hook てのはあったっけ(もちろん、save-buffer-hook 的なもの
> を利用するのであれば他のモードの事も考慮したコードを書く必要があります
> ね)…。
> 
> 捜せば hook は何かありそうですが、あまり時間を使いたくない時はテキトー

fj.editor.emacs の <tzg0dmjly9.wl@tenryu.tom.sfc.keio.ac.jp>
で、服部さんが書かれている
write-file-hooks
でしたね。

どの emacs でも同じかどうか判りませんが、 emacs-21.0.103 だと
save-buffer -> basic-save-buffer という順で実行され、
basic-save-buffer では

            (or (run-hook-with-args-until-success 'write-contents-hooks)
		(run-hook-with-args-until-success 'local-write-file-hooks)
		(run-hook-with-args-until-success 'write-file-hooks)
		;; If a hook returned t, file is already "written".
		;; Otherwise, write it the usual way now.
		(setq setmodes (basic-save-buffer-1)))

というくだりがあります。結構複雑ですね。

hack-local-variables を利用するとして、write-file-hooks を使う場合は

(add-hook 'write-file-hooks
  (lambda ()
    (and html-helper-mode
         (hack-local-variables))))

ですかね。

advice.el を使うのであれば、

(defadvice save-buffer (before html-helper-ad activate)
  (and html-helper-mode
       (hack-local-variables)))

でしょうか。

hook は呼ばれるタイミングを一応確認しないと安心できませんが、
advice の方はタイミングを指定できるところが便利かもしれません。

いずれも実際に動かしてないのですが、間違ってたらご容赦。
Technical Details
Message-ID: <9f4d56$a9q$1@sn.asahi-net.email.ne.jp>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsfeed.media.kyoto-u.ac.jp!newsfeed.rim.or.jp!Q.T.Honey!nf.asahi-net.or.jp!not-for-mail
References: <yftbsodx9zh.fsf@toya.lp.nm.fujitsu.co.jp> <9ev217$j2a$1@sn.asahi-net.email.ne.jp> <yftzobwwya5.fsf@toya.lp.nm.fujitsu.co.jp> <9evtmf$4nq$1@sn.asahi-net.email.ne.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-30 20:18:57 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsfeed.media.kyoto-u.ac.jp!newsfeed.rim.or.jp!Q.T.Honey!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: 31 May 2001 12:17:58 +0900
Organization: Smoke
Message-ID: <9f4d56$a9q$1@sn.asahi-net.email.ne.jp>
References: <yftbsodx9zh.fsf@toya.lp.nm.fujitsu.co.jp> <9ev217$j2a$1@sn.asahi-net.email.ne.jp> <yftzobwwya5.fsf@toya.lp.nm.fujitsu.co.jp> <9evtmf$4nq$1@sn.asahi-net.email.ne.jp>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 8bit
Lines: 49
NNTP-Posting-Host: g032090.ppp.asahi-net.or.jp
X-Trace: 991279136 news3.asahi-net.or.jp 18684 211.132.32.90
X-Complaints-To: ap-net@asahi-net.or.jp