From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: executing Ruby from Emacs buffer
Date: Thu, 10 May 2012 04:23:40 -0700 (PDT) [thread overview]
Message-ID: <14a895ad-f4c5-476a-8d23-3203b64078e6@jx17g2000pbb.googlegroups.com> (raw)
In-Reply-To: mailman.898.1336645753.855.help-gnu-emacs@gnu.org
On May 10, 3:28 am, ishi soichi <soichi...@gmail.com> wrote:
> 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?
the issue is for the ruby interpreter to know it's lib paths, not
emacs. So, i don't think your issue lies in emacs.
this might be what you need or helpful.
〈Emacs Lisp Wrapper for Perl/Python/Ruby Scripts〉
http://xahlee.org/emacs/elisp_perl_wrapper.html
feel free to ask if you have more questions.
Xah
next parent reply other threads:[~2012-05-10 11:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.898.1336645753.855.help-gnu-emacs@gnu.org>
2012-05-10 11:23 ` Xah Lee [this message]
2012-05-10 10:28 executing Ruby from Emacs buffer ishi soichi
2012-05-10 13:50 ` Andrea Crotti
2012-05-10 14:18 ` Peter Dyballa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14a895ad-f4c5-476a-8d23-3203b64078e6@jx17g2000pbb.googlegroups.com \
--to=xahlee@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).