开发者

run ruby from emacs buffer

How can I run a ruby piece of code from a buffer, without actually saving the buffer in a file? A scenario would be to a) switch to the scratch buffer b) M-x ruby-mode c) type ruby code d) "compile" the buffer and print results in another buffer. I don't want to save the buffer contents in a file and then "compile" that file

UPDATE 1-9-2011 Which are the latest versions of ruby-mode and inf-ruby and where can I get them? I use the ubuntu natty version of ruby mode and the elpa version of inf-ruby of emacs 23.2. On a clean 开发者_开发问答emacs config, the following config (see underneath) fail with:

can't convert nil into String 
from (irb):1:in `eval' 
from (irb):1". 

Configuration is just the following, no other configuration directives in emacs.d:

(require 'ruby-mode)
(load-file "Configs/.emacs.d/elpa/inf-ruby-2.1/inf-ruby.el")

(autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby pathrocess" t)
(autoload 'inf-ruby-keys "inf-ruby" "" t)
(eval-after-load 'ruby-mode
  '(add-hook 'ruby-mode-hook 'inf-ruby-keys))


You can do this with inf-ruby.el.

With inf-ruby installed, M-x inf-ruby starts a new ruby interpreter in the background, to which you can send code using the ruby-send-* commands, such as ruby-send-region (bound by default to C-c C-r). To send the whole buffer, select all with C-x h then hit C-c C-r.

Update, 2011-09-02: The latest version of inf-ruby.el (2.1.1, available in ELPA) is that maintained by 'nonsequitur' on github, and snapshot packages are available in Melpa.


A few options for you to try

1. Rinari from Github

It claims to be

aimed towards making Emacs into a top-notch Ruby and Rails development environment


2. ruby-compilation.el is what you need.

There's a thread on that here which I have used and found helpful.

Chris

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜