simple-hatena-setup
ようやく手元の simple-hatena-mode で simple-hatena-setup が動くようになった。
明朝 id:antipop に御査収戴いて、赤ペン訂正の上 commit 戴…… coderepos なんだから commit しちゃって直してもらえばいいのか。
一応こんなの。hatena group についてはまた今度。
--- simple-hatena-mode.el (revision 1538) +++ simple-hatena-mode.el (working copy) @@ -1,5 +1,5 @@ +;;; -*- coding: utf-8; mode: emacs-lisp; indent-tabs-mode: nil -*- ;;; simple-hatena-mode.el --- Emacs interface to Hatena::Diary Writer -;; -*- coding: utf-8; mode:emacs-lisp -*- ;; Copyright (C) 2007 Kentaro Kuribayashi ;; Author: Kentaro Kuribayashi <kentarok@gmail.com> @@ -266,8 +266,71 @@ ;;;; * コマンド (defun simple-hatena-setup () - "ディレクトリ配置をセットアップする。") + (interactive) + "ディレクトリ配置をセットアップする。" + (and + ;; simple-hatena-bin + (simple-hatena-setup-hatena-bin-executable-p) + + ;; hatena id(s) + (simple-hatena-setup-id))) + +(defun simple-hatena-setup-hatena-bin-executable-p () + (if (file-executable-p simple-hatena-bin) + t + (progn + (when (y-or-n-p + (format + (concat + "Please download and/or setup `はてなダイアリーライター'.\n" + " open a webpage? ") + simple-hatena-bin)) + (browse-url "http://coderepos.org/share/wiki/SimpleHatenaMode")) + (message "Without forgetting the rerun of the simple-hatena-setup.") + (read-char) ;; wait user input. + nil))) + +(defun simple-hatena-setup-id () + (let + ((ids (list))) + + (when (file-directory-p simple-hatena-root) + (dolist (id (simple-hatena-internal-list-directories simple-hatena-root)) + (add-to-list 'ids id))) + + (when simple-hatena-default-id + (add-to-list 'ids simple-hatena-default-id)) + + (when (eq (length ids) 0) + (add-to-list 'ids (read-string "Please input your default Hatena id: "))) + + (while (y-or-n-p + (format + "id `%s' found.\nsetup other id(s)? " + (mapconcat 'identity + ids "', `"))) + (add-to-list 'ids (read-string "Please input your other Hatena id: "))) + + (dolist (id ids) + (simple-hatena-setup-id-create-directory-and-file id)))) + +(defun simple-hatena-setup-id-create-directory-and-file (id) + (simple-hatena-setup-create-directory-and-file + (expand-file-name + (format "%s/%s/diary/config.txt" + simple-hatena-root id)))) + +(defun simple-hatena-setup-create-directory-and-file (filename) + "setup adirectory and a file. +NOTE: Create intermediate directories as required." + (let + ((dirname (file-name-directory filename))) + (unless (file-exists-p filename) + (unless (file-directory-p dirname) + (make-directory dirname 'parents)) + (append-to-file 1 1 filename)))) + (defun simple-hatena (id) "実行日現在の日付のファイルを開く。" (interactive