symfony のスタックトレースのファイルリンクをemacsで開く


公式サイトにはTextMateでの説明しかなかったので、emacsでもできないか試してみました。
mac + Carbon Emacs の組み合わせで動作確認済みです。
スクリーンキャスト


.emacsに(server-start)を書いておく。
setteings.ymlにsf_file_link_formatの値を以下の形式で追加。

dev:
  .settings:
    file_link_format: "emacs:%f#%l"


以下のサイトを参考にdmgファイルを作成して、アプリケーションフォルダにインストール。

blog.katsuma.tv


一応完成ファイルも置いておきます。
http://dl.dropbox.com/u/136436/emacsOpen.app.dmg


AppleScript

on open location v
    if v starts with "emacs:" then
        activate
        set v to text from character 7 to character -1 of v
        set org_delimi to text item delimiters of AppleScript
        set text item delimiters of AppleScript to "#"
        set f to text item 1 of v
        set l to text item 2 of v
        set text item delimiters of AppleScript to org_delimi
        do shell script "emacsclient -n +" & l & " " & f
    end if
    quit
end open location

info.plist の追加箇所

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>emacs URL</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>emacs</string>
            </array>
        </dict>
    </array>
    <key>NSiUIElement</key>
    <true/>