最近 Gauche の勉強をしている - 刺身☆ブーメランのはてなダイアリー でかいたシェル関数の today() を eshell の中でも使いたくなったので emacs lisp 関数として書き直してみた。
;; today - 今日の日付のディレクトリに移動 なければ作成
(defun today ()
(interactive)
(let ((today (concat (getenv "HOME") "/" "daily" "/" (format-time-string "%Y-%m-%d" (current-time)))))
(if (file-exists-p today)
(cd today)
(progn
(make-directory today)
(cd today)))))concat のあたりがなんとも汚らしい。 join- で始まる文字列連結関数があるんじゃないかと思って C-h f してみたけど候補にそれっぽいのがでてこなかった。 file-exists-p でディレクトリの有無もチェックできる。 directory-exists-p って関数はなかった。