;;; -*- Emacs-Lisp -*- ;;; (c)1999-2003 HIROSE Yuuji [yuuji@gentei.org] ;;; Set up all diary environment ;;; Last modified Sun Mar 5 18:41:01 2006 on firestorm ;;; $Id: webdiary.el,v 2.2 2008/02/24 21:21:50 yuuji Exp $ ;;; ~/.emacs に以下の行を追加する。 ;;; ;;; (autoload 'webdiary "webdiary" "Keep web diary!" t) ;;; ;;; M-x webdiary で日記を書こう。 ;;; ;;; おまけ ;;; リジョン指定して M-x webdiary-body2html ;;; するとその領域を body2html でHTML化するぞ。 ;;; body2html のHTML化規則に関してはbody2html スクリプトを見てくれい。 ;;; ;;; (autoload 'webdiary-body2html "webdiary" "en-HTML!" t) ;;; (define-key global-map "\C-cH" 'webdiary-body2html) ;;; ;;; とかしとくとええよ。 (defvar webdiary:dir "~/http/diary/" "*日記の基準となるディレクトリ ( / で終わらせること)") (defvar webdiary:mkdiary (expand-file-name "mkdiary.rb" webdiary:dir) "*日記ディレクトリ更新用スクリプト mkdiary のフルパス") (defvar webdiary:body2html (expand-file-name "body2html" webdiary:dir) "*プレインテキスト本文をHTML化するスクリプト body2html のフルパス") (defun webdiary*today () "今日の日付 YYYY/MM/DD" (let* ((ts (current-time-string)) (m (substring ts 4 7)) (d (substring ts 8 10)) (y (substring ts -4))) (setq m (cdr (assoc m '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8) ("Sep" . 9)("Oct" . 10)("Nov" . 11)("Dec" . 12)))) m (format "%02d" m) d (format "%02d" (string-to-int d))) (format "%s/%s/%s" y m d))) (defun webdiary*update-yeardir () "「年」のindexファイルを更新" (save-restriction (save-excursion (let ((dir (file-name-directory webdiary:mkdiary))) (widen) (goto-char (point-min)) (and (re-search-forward "<[Hh]1>" nil t) (progn (skip-chars-forward " \t\n") (not (looking-at ""))) (progn (start-process "mkdiary" " *mkdiary*" (expand-file-name webdiary:mkdiary) "../..") (start-process "mkdiary" " *mkdiary*" (expand-file-name webdiary:mkdiary) "-mkcat") (cond ((file-exists-p (expand-file-name "rss.rb" dir)) (unwind-protect (let ((default-directory dir)) (cd default-directory) (call-process shell-file-name nil nil nil shell-command-switch "./rss.rb")) (cd default-directory))))) nil)))) nil) (defun webdiary-body2html (beg end) (interactive "r") (save-excursion (shell-command-on-region beg end webdiary:body2html nil t))) (defun webdiary (date) "web日記セットアップ" (interactive (let ((wd webdiary:dir) (td (webdiary*today))) (or (string-match "/$" wd) (setq wd (concat wd "/"))) (list (read-file-name "Today: " wd (expand-file-name td wd) nil td)))) ;;今日のディレクトリを掘る ;(or (file-directory-p date) (make-directory date)) ;;テンプレートファイルを作成 (let ((target (expand-file-name "index.html" date)) (ymd (substring date -10))) (if (not (file-exists-p target)) (call-process webdiary:mkdiary nil nil nil "-date" ymd)) (find-file target) (add-hook (make-local-variable 'after-save-hook) 'webdiary*update-yeardir))) (defun webdiary-on-dir (dir) "Call webdiary with special directory." (let ((mkdiary (expand-file-name "mkdiary.rb" dir))) (let*((webdiary:dir dir) (webdiary:mkdiary mkdiary)) (call-interactively 'webdiary)) (set (make-local-variable 'webdiary:mkdiary) mkdiary))) (autoload 'img2www "img2www" "An interface to img2www script" t) (provide 'webdiary)