頭痛がいたくてしょうがない
NTT DoCoMo 503i とか、iアプリを emacs で書くひとむけの、いちいち jar 作るたびに jam かくのめんどくさいので
*.jam を更新する elisp
;; -*-emacs-lisp-*- ;; jam-mode.el ;; $Id: 01.tdf,v 1.2 2005/02/20 08:06:08 morimoto Exp $ ;; result of current-time-string is in the form "Thu Jan 4 12:22:33 2001" (defvar jam-mode-map nil "Keymap used in jam-mode.") (defvar jam-mode-syntax-table nil "Syntax table in use in jam-mode buffers.") (if jam-mode-map nil (setq jam-mode-map (make-sparse-keymap)) (define-key jam-mode-map "\C-c\C-c" 'jam-update)) (defun jam-mode () "Major mode for editing jam file" (interactive) (use-local-map jam-mode-map) (setq mode-name "jam") (setq major-mode 'jam-mode) (run-hooks 'jam-mode-hook)) (defun jar-last-modified-string (jar-filename) "" (let ((jar-attribute) (jar-last-modified) (jar-mday) (jar-day) (jar-month) (jar-year) (jar-time) (pattern "^\\([A-Z][a-z][a-z]\\) \\([A-Z][a-z][a-z]\\) +\\([0-9]+\\) \\(\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\) \\([0-9][0-9][0-9][0-9]\\)")) (setq jar-attribute (file-attributes jar-filename)) (setq jar-last-modified (current-time-string (nth 6 jar-attribute))) (if (string-match pattern jar-last-modified) (progn (setq jar-mday (match-string 1 jar-last-modified)) (setq jar-month (match-string 2 jar-last-modified)) (setq jar-day (match-string 3 jar-last-modified)) (setq jar-time (match-string 4 jar-last-modified)) (setq jar-year (match-string 5 jar-last-modified)) (format "%s, %s %s %s %s" jar-mday jar-day jar-month jar-year jar-time)) nil))) (defun jar-app-size-string (jar-filename) "" (format "%s" (nth 7 (file-attributes jar-filename)))) (defun jam-update-jar-size (jar-filename) "" (beginning-of-buffer) (if (re-search-forward "AppSize *= *" nil t nil) (progn (kill-line) (insert (jar-app-size-string jar-filename))) (progn (beginning-of-line) (insert "AppSize = ") (insert (jar-app-size-string jar-filename)) (insert "\n")))) (defun jam-update-last-modified (jar-filename) "" (beginning-of-buffer) (if (re-search-forward "LastModified *= *" nil t nil) (progn (kill-line) (insert (jar-last-modified-string jar-filename))) (progn (beginning-of-line) (insert "LastModified = ") (insert (jar-last-modified-string jar-filename)) (insert "\n")))) (defun jam-update () "Updates LastModified and AppSize lines of buffer." (interactive) (save-excursion (let ((jar-filename)) (beginning-of-buffer) (if (re-search-forward "PackageURL *= *" nil t nil) (progn (re-search-forward "\\w+\\.jar" nil t nil) (setq jar-filename (match-string 0)) (jam-update-jar-size jar-filename) (jam-update-last-modified jar-filename)) (progn (beep) (message "PackageURL does not specified!!"))))))
例によって、~/.emacs に
(autoload 'jam-mode "jam-mode" "jam mode." t) (setq auto-mode-alist (append '(("\\.jam$" . jam-mode)) auto-mode-alist))
とか書いて、*.jam を読んだときに jam-mode になるようにしてくれ
あとは C-c C-c で LastModified 行と AppSize 行が更新される
む。バファリンが効いたのか、あたまいたいのなおった。
現実逃避終了。では。