help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: executing Ruby from Emacs buffer


From: Andrea Crotti
Subject: Re: executing Ruby from Emacs buffer
Date: Thu, 10 May 2012 14:50:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

ishi soichi <soichi777@gmail.com> writes:

> Cococa Emacs 23.2
>
> GNU Emacs 23.2.1 (x86_64-apple-darwin10.4.0, NS apple-appkit-1038.32)
> of 2010-08-27
> ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
>
> I am not sure if this question is to be asked here, but I'll try.
>
> I'm trying to run Ruby codes from Emacs.
>
> (defun execute-ruby ()
>   (interactive)
>   (let (buf)
>     (setq buf
>  (get-buffer-create "*result ruby execution*"))
>     (call-process-region
>      (region-beginning) (region-end) "ruby" nil buf nil)
>     (display-buffer buf)))
>
> as you can see, this piece of Elisp code runs a region where Ruby code
> is written.
>
> # -*- encoding: utf-8 -*-
> require 'twitter'
> Twitter.configure do |config|
>   config.consumer_key = ''
>   config.consumer_secret = ''
>   config.oauth_token = ''
>   config.oauth_token_secret = ''
> end
> p Twitter.user_timeline("soujiro0725").first.text
>
>
> The Ruby code utilizes a gem library, called 'twitter', which enables
> to tweet or get timelines by writing simple codes.
> Of course, this particular gem library is installed and it perfectly
> runs in a regular shell, such as zsh or bash.
>
> But for some reason, it gives an error when executed in Emacs buffer.
>
> ruby_twitter.rb:2:in `require': no such file to load -- twitter
> (LoadError)
> from ruby_twitter.rb:2
>
> Looks like Emacs cannot find the gem library.
>
> How can I have Emacs find the proper library or gems?
>
> soichi

I think that if you are calling ruby as an external process than emacs
doesn't have anything to do with the fact that a library is not found.
More probably it's not the right interpreter or something similar..

Anyway ruby-mode http://emacswiki.org/emacs/RubyMode does all these
things and more, why not try that?

-- 
GNU Emacs 24.1.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.1)
 of 2012-04-29 on dell



reply via email to

[Prev in Thread] Current Thread [Next in Thread]