ブログを記述することの一番の障壁は書き初めが面倒くさいことだ。「ブロ グを書くぞ」と気合を入れてからファイルを開いたしている。文章を書こうと 思うと心構えが必要になる。問題はその心構えをすること自体が徐々に億劫に なってくることだ。
即座にファイルを開いて文章を書き初められるように専用のコマンドを実装した。 作成した文章を即座に特定のディレクトリに書き込めるようにした。
(defcustom symdon-ga-post-directory "/ng/symdon/pages/posts"
"Path to directory of symdon-ga posts")
(defun symdon-ga-create-new-file-path ()
(concat
(directory-file-name symdon-ga-post-directory)
"/"
(format "%s.org"
(truncate (float-time)))))
(defun symdon-ga-post (text)
(with-current-buffer (find-file-noselect (symdon-ga-create-new-file-path))
(insert text)
(save-buffer)
(current-buffer)))
(defun editor-get-editor-buffer-text ()
(with-current-buffer (get-buffer editor-buffer-name)
(buffer-substring-no-properties (point-min) (point-max))))
(defun editor-save-as-kill ()
(interactive)
(symdon-ga-post
(editor-get-editor-buffer-text))
(kill-buffer editor-buffer-name))
(custom-set-variables '(symdon-ga-post-directory "/ng/symdon/pages/posts"))
(bind-keys :map editor-mode-map
("C-c C-c" . editor-save-as-kill))