从emacs缓冲区运行ruby [英] run ruby from emacs buffer

查看:121
本文介绍了从emacs缓冲区运行ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在缓冲区中运行一个红宝石码,而不是将缓冲区保存在文件中?一个场景是
a)切换到临时缓冲区
b)M-x ruby​​-mode
c)键入ruby代码
d)编译缓冲区并将结果打印到另一个缓冲区。我不想将缓冲区内容保存在文件中,然后编译该文件

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

更新1-9-2011
哪些是最新版本红宝石模式和红宝石,我可以在哪里得到它们?我使用ubuntu natty版本的ruby模式和emacs的empa版本的elpa版本23.2。在一个干净的emacs配置下,以下配置(见下面)失败:

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". 

以下,emacs.d中没有其他配置指令:

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))


推荐答案

code> inf-ruby.el 。

You can do this with inf-ruby.el.

使用 inf-ruby 安装, Mx inf-ruby 在后台启动一个新的ruby解释器,您可以使用 ruby​​-send - * 命令,例如 ruby​​-send-region (bound b y默认为 C-c C-r )。要发送整个缓冲区,请使用 Cx h 全部选择,然后点击 Cc Cr

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.

更新,2011-09-02:最新版本的 inf-ruby.el (2.1.1,available在ELPA中)由非顺序 github 维护,并且快照包可在 Melpa

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.

这篇关于从emacs缓冲区运行ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆