ぜろから導入、cocoa emacsでSuperCollider

インストール

macports

他のインストールを楽にするため、まずはmacportsを入れます。コンパイルは面倒なので、パッケージをDLしてインストールしてしまいましょう。

http://www.macports.org/
Installing MacPorts
“dmg”disk images for Snow Leopard
git

macportsからインストールします。ここでは、git-coreだけで問題ないでしょう。

$ sudo port install git-core
cocoa emacs
$ sudo port install emacs-app
w3m
$ sudo port install w3m
emacs-w3m

macportsからインストールすると、emacsのバージョンによってはサポートしていないと怒られる場合がありますので、念のためCVSからインストールします。

$ cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot login
CVS password:
# パスワードは設定されていません.単に Enter/Return キーを押して下さい.
$ cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot co emacs-w3m

インストールします。

$ ./configure --with-emacs=/Applications/Emacs.app/Contents/MacOS/Emacs --with-lispdir=/Applications/Emacs.app/Contents/Resource/share/emacs/site-lisp/w3m --with-icondir=/Applications/Emacs.app/Contents/Resource/etc/w3m
$ make
$ sudo make install
$ sudo make install-icons

設定

シェル

以下bashの場合ですが、sc3へのパスを通してやります。最後にsclangを実行してみて、パスが通っていることを確認します。

$ echo $SHELL
/bin/bash
$ vi .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
$ cat .bash_profile
$ vi .bashrc
export PATH=$PATH:/Applications/SuperCollider
$ cat .bashrc
$ sclang -h
sc3ファイルのコピー
$ mkdir ~/.sclang
$ cp -R /Applications/SuperCollider/SCClassLibrary ~/.sclang
$ cp -R /Applications/SuperCollider/plugins ~/.sclang
$ cp /Applications/SuperCollider/scsynth ~/.sclang

コピーしたら、~/.sclang/SCClassLibrary/Platform/osx/OSXPlatform.scファイルのstartup部分を以下に変更します。

startup {
            if ( this.hasFeature( \emacs ) ) {
                            Document.implementationClass.startup;
            };
            this.loadStartupFiles;
}
scel

scelをgitでDLして、SCClassLibraryにコピーします。

$ ls ~/.emacs.d
(なければ $ mkdir ~/.emacs.d
$ cd ~/.emacs.d
$ git init
$ git submodule add git://github.com/samaaron/scel.git vendor/supercollider

$ cp -R ~/.emacs.d/vendor/supercollider/sc ~/.sclang/SCClassLibrary/Common/Emacs
emacs

emacsの設定ファイルを記述します。emacs22からは~/.emacs.elではなく、~/.emacs.d/以下に設定ファイルを置くことが推奨されているそうです。
では、~/.emacs.d/init.elに以下を記述します。ついでにヘルプファイルを見るために必要なw3memacs-w3mの設定も記述しましょう。

(set-language-environment 'Japanese)
(prefer-coding-system 'utf-8)

(setq exec-path (append exec-path '("/opt/local/bin")))
(require 'w3m-load)

(add-to-list 'load-path "~/.emacs.d/vendor/supercollider/el")
(require 'sclang)

(custom-set-variables
'(sclang-auto-scroll-post-buffer t)
'(sclang-eval-line-forward nil)
'(sclang-help-path (quote ("/Applications/SuperCollider/Help")))
'(sclang-runtime-directory "~/.sclang/"))

(setq path "/Applications/SuperCollider:/rest/of/PATH")
(setenv "PATH" path)
(push "/Applications/SuperCollider" exec-path)

実行

インストールしたemacs.appを実行します。次にスパコモードへ変更、

M-x sclang-start

で変更されます。
以下scelのショートカットコマンドです。

サーバブート	C-c C-p b
サーバストップ	C-c C-p q
サーバパネル開く	C-c C-p p
リージョン実行(範囲内どこでも)	C-M-x
リージョン実行(範囲指定)	C-c C-x
一行実行	C-c C-c
ストップ	C-c C-s
メイン実行	C-c C-f
再コンパイル	C-c C-l
ヘルプ(検索)	C-c C-h
ヘルプ(w3m)	C-M-h
クラス定義開く	C-c :
クラスリファレンス開く	C-c ;

以上

慣れればemacs最強!とか周りに言い出すはずです。慣れるまで結構時間かかりますけれど。
linux時代に作ったチートシートがありますのでどぞ。たぶんcocoa emacsでもそのまま使えるはずです。
http://spreadsheets.google.com/pub?key=pcuCAL5TV5IcS_bSRIXrYEg&single=true&gid=0&output=html