;; ;; Last updated: <2000/02/02 13:04:47 +0900> ;; (provide "auto-time-stamp") (in-package "editor") (require "timestmp") (export '(save-buffer-with-time-stamp time-stamp-toggle-active *time-stamp-active* *time-stamp-start* *time-stamp-end* *time-stamp-format*)) ; non-nil なら time-stamp 処理を行う (defvar *time-stamp-active* t) ; time-stamp 直前にマッチさせる正規表現 (defvar *time-stamp-start* "Last updated:[ \t]+[<\"]") ; time-stamp 直後にマッチさせる正規表現 (defvar *time-stamp-end* "[>\"]") ; time-stamp のフォーマット(詳細は timestmp を参照) (defvar *time-stamp-format* "%Y/%m/%d %H:%M:%S %Z") ; time-stamp が有効な行数 (defvar *time-stamp-line-limit* 30) (defun time-stamp () "time-stamp-start と time-stamp-end の間に現在時刻を挿入する" (save-excursion (let (begin end limit) (goto-char (point-min)) (save-excursion (forward-line *time-stamp-line-limit*) (setq limit (point))) (cond ((scan-buffer *time-stamp-start* :regexp t :tail t :limit limit) (setq begin (point)) (save-excursion (goto-eol) (setq limit (point))) (if (scan-buffer *time-stamp-end* :regexp t :limit limit) (progn (setq end (point)) (delete-region begin end) (insert (format-date-string *time-stamp-format*))) (message "なんかフォーマットちがうんとちゃう?"))) (t (message "ほんまにタイムスタンプいるの?")))))) (defun save-buffer-with-time-stamp () "*time-stamp-active* が non-nil なら (time-stamp) を実行してから save-buffer" (interactive) (when (buffer-modified-p) (and *time-stamp-active* (time-stamp)) (save-buffer))) (defun time-stamp-toggle-active (&optional arg) "*time-stamp-active* のトグル" (interactive "*p") (setq *time-stamp-active* (cond ((null arg) (not *time-stamp-active*)) (t nil))) (message (concat "タイムスタンプ" (if *time-stamp-active* "つけるで" "つけへんで") ".")))