emacs-railsのrails-create-projectで自作のスクリプトを使う
emacs-railsではrails-create-projectで新しいRailsプロジェクトを作成することができる。裏ではrailsコマンドを実行しているんだけど、どうせならこれをd:id:mteramoto:20061112:p1で作ったrails-create.shに置き換えたい。
rails-create-projectはrails-scripts.elで定義されているので、内容を見てみる。
;;;;;;;;;; Rails create project ;;;;;;;;;; (defun rails-create-project (dir) "Create new project in ``dir'' directory" (interactive "FNew project directory: ") (shell-command (concat "rails " dir) rails-generation-buffer-name) (flet ((rails-core:root () (concat dir "/") )) (rails-log-add (format "\nCreating project %s\n%s" dir (buffer-string-by-name rails-generation-buffer-name)))) (find-file dir))
ごらんの通り、railsがハードコーディングされてる。しょうがないので.emacsでrails-create-projectを再定義してやろう。
(defun rails-create-project (dir) "Create new project in ``dir'' directory" (interactive "FNew project directory: ") (shell-command (concat "rails-create.sh " dir) rails-generation-buffer-name) (flet ((rails-core:root () (concat dir "/") )) (rails-log-add (format "\nCreating project %s\n%s" dir (buffer-string-by-name rails-generation-buffer-name)))) (find-file dir))
shell-commandで実行するコマンドをrailsからrails-create.shに書き換えただけ。(require 'rails)より後に記述しないと意味ないことに注意。
あとはEmacsからrails-create-projectを実行してやればOK。
のはずが、エラーメッセージとともにcoding systemの選択を迫られた。どうも日本語で出力されたログのencodingを決めかねているみたい。utf-8を選択しても文字化けしたログしか残らない。
とりあえずrails-create.shでLANGとLC_ALLをCにセットしてしのいだけど、なんか気持ち悪いな。
These default coding systems were tried to encode "2006/11/12...": japanese-iso-8bit However, each of them encountered these problematic characters: japanese-iso-8bit: \212 \240 \343 \201 \227 \343 \201 \201 \204 \343 ... The first problematic character is at point in the displayed buffer, and C-u C-x = will give information about it. Select one of the following safe coding systems, or edit the buffer: utf-8 utf-16 utf-16 utf-16 utf-16be utf-16le Or specify any other coding system at the risk of losing the problematic characters.