今まで使っていた html-helper-mode では <!-- hhmts start --> と <!-- hhmts end --> の間に更新時刻が自動挿入される。時刻のフォーマットは次のように設定していた。
(add-hook 'html-helper-timestamp-hook
(function (lambda ()
(insert "Last modified: "
(format-time-string "\n")))))
ところが,今の標準らしい mhtml-mode ではこのような機能がなさそうだ。そこで,Emacs の一般的な Time Stamp の方法を使って挿入する。最も簡単な方法としては,~/.emacs.d/init.el に次のように書き込んでおく。
(add-hook 'before-save-hook 'time-stamp) (setq time-stamp-pattern "-8/Last modified:[ \t]+<time>%:y-%02m-%02d %02H:%02M:%02S %Z</time>") (setq time-stamp-time-zone nil) ;; localtime
これでページの最後あたりに Last modified: <time>任意の文字列</time> と書き込んでおけば,保存時にタイムスタンプが自動挿入される。-8 はファイル末尾から8行を探すという意味である。