Meadow に Ruby 開発環境を設定
2009-12-04


「どんならんな」さんの「Emacs で Ruby 開発環境」(http://d.hatena.ne.jp/yuko1658/20071213/1197517201) を参考にしながら設定
色々と試行錯誤 (行き当たりばったり) したので、次に下記の通り行っても本当に上手くいくかどうかは不明
なお、以下の作業はすべて Meadow の shell-mode で行った

  1. 下準備として wget をインストール (←これは cygwin の setup.exe で実行)

  2. Ruby のソースコードを取得・展開し、ruby-1.9.1-p243.tar/misc ディレクトリ下の全ての *.el ファイルを Meadow インストールディレクトリ下にある site-lisp ディレクトリ下にコピー
    $ wget http://core.ring.gr.jp/archives/lang/ruby/ruby-1.9.1-p243.tar.gz
    $ tar xzvf ruby-1.9.1-p243.tar.gz
    $ cp ruby-1.9.1-p243/misc/*.el c:/TOOLS/meadow/site-lisp/
    


  3. emacs-rails を取得・展開し、emacs-rails ディレクトリ下の全ての *.el ファイルをMeadow インストールディレクトリ下にある site-lisp ディレクトリ下にコピー
    $ wget http://rubyforge.org/frs/download.php/20976/emacs-rails-0.5.99.5.tar.gz
    $ tar xzvf emacs-rails-0.5.99.5.tar.gz
    $ cp emacs-rails/*.el c:/TOOLS/meadow/site-lisp/
    


  4. ruby-block.el を取得し、Meadow インストールディレクトリ下にある site-lisp ディレクトリ下にコピー
    $ wget http://www.emacswiki.org/cgi-bin/wiki/ruby-block.el
    $ cp ruby-block.el c:/TOOLS/meadow/site-lisp/
    


  5. snippet.el を取得し、Meadow インストールディレクトリ下にある site-lisp ディレクトリ下にコピー
    $ wget http://www.kazmier.com/computer/snippet.el
    $ cp snippet.el c:/TOOLS/meadow/site-lisp/
    


  6. find-recursive.el を取得し、Meadow インストールディレクトリ下にある site-lisp ディレクトリ下にコピー
    $ wget http://www.webweavertech.com/ovidiu/emacs/find-recursive.txt
    $ cp find-recursive.txt c:/TOOLS/meadow/site-lisp/find-recursive.el
    


  7. ここで、.emacs を設定してちょっと動かしてみる .emnacs に追加する設定は、次の通り (つか、「Emacs で Ruby 開発環境」のまんま)
    ;; ruby-mode
    (autoload 'ruby-mode "ruby-mode"
      "Mode for editing ruby source files" t)
    (setq auto-mode-alist
          (append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
    (setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
                                         interpreter-mode-alist))
    (autoload 'run-ruby "inf-ruby"
      "Run an inferior Ruby process")
    (autoload 'inf-ruby-keys "inf-ruby"
      "Set local key defs for inf-ruby in ruby-mode")
    (add-hook 'ruby-mode-hook
              '(lambda () (inf-ruby-keys)))
    ;; ruby-electric
    (require 'ruby-electric)
    (add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t)))
    ;; rubydb
    (autoload 'rubydb "rubydb3x"
      "run rubydb on program file in buffer *gud-file*.
    the directory containing file becomes the initial working directory
    and source-file directory for your debugger." t)
    ;; rails
    (defun try-complete-abbrev (old)
      (if (expand-abbrev) t nil))
    (setq hippie-expand-try-functions-list
          '(try-complete-abbrev
            try-complete-file-name
            try-expand-dabbrev))
    (setq rails-use-mongrel t)
    (require 'cl)
    (require 'rails)
    ;; ruby-block
    (require 'ruby-block)
    (ruby-block-mode t)
    ;; ミニバッファに表示し, かつ, オーバレイする.
    (setq ruby-block-highlight-toggle t)
    
    おおむね良好、が、ここで if とか { とか入力すると対応する end や } が自動的に挿入され喜ぶ、が CentOS の Emacs に設定したときにはこんな動きはならなかったけどなー、と思い調べてみると、.rb ファイルを読み込むと次のようなエラーが発生していた
    File mode specification error: (void-function run-mode-hooks)
    
    困ったときの google 頼みで "ruby-mode File mode specification error: (void-function run-mode-hooks)" で検索すると、次のようなページに行き当たった
    「[ruby-dev:34853] emacs21でruby-mode.el」(http://old.nabble.com/-ruby-dev:34853--emacs21%E3%81%A7ruby-mode.el-td17466768.html)
    
    ピンポンみたいです。このページの説明にしたがい ruby-mode.el の
    259  (run-mode-hooks 'ruby-mode-hook))
    
    259  (if (fboundp 'run-mode-hooks)
    260    (run-mode-hooks 'ruby-mode-hook)
    261   (run-hooks 'ruby-mode-hook)))
    
    に変えると動き出した。Meadow の方は Emacs のバージョンが新しいので、こんな問題は発生しないみたい。

  8. Ruby でコード補完
    以下の設定は、「nao研究室」さんの「[Emacs]Rubyでコード補完」(http://blogs.dion.ne.jp/moe_moe/archives/7481321.html) を開始点にして google 先生に教えを請いながら行った。

続きを読む

[アプリケーション]
[備忘録]
[Windows]

コメント(全0件)
コメントをする


記事を書く
powered by ASAHIネット