* executing Ruby from Emacs buffer
@ 2012-05-10 10:28 ishi soichi
2012-05-10 13:50 ` Andrea Crotti
2012-05-10 14:18 ` Peter Dyballa
0 siblings, 2 replies; 4+ messages in thread
From: ishi soichi @ 2012-05-10 10:28 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1347 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 2090 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing Ruby from Emacs buffer
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
1 sibling, 0 replies; 4+ messages in thread
From: Andrea Crotti @ 2012-05-10 13:50 UTC (permalink / raw)
To: ishi soichi; +Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing Ruby from Emacs buffer
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
1 sibling, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2012-05-10 14:18 UTC (permalink / raw)
To: ishi soichi; +Cc: help-gnu-emacs
Am 10.05.2012 um 12:28 schrieb ishi soichi:
> (region-beginning) (region-end) "ruby" nil buf nil)
Assume you have two ruby binaries on your system. One of them, installed via Fink or Macports or such, is configured to use the gem library, the other, Apple's one, not. In shell you could invoke 'which ruby'. Then substitute the simple "ruby" string with the absolute pathname returned in shell. Could be this works better...
--
Greetings
Pete
Computers are good at following instructions, but not at reading your mind.
- D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.898.1336645753.855.help-gnu-emacs@gnu.org>]
* Re: executing Ruby from Emacs buffer
[not found] <mailman.898.1336645753.855.help-gnu-emacs@gnu.org>
@ 2012-05-10 11:23 ` Xah Lee
0 siblings, 0 replies; 4+ messages in thread
From: Xah Lee @ 2012-05-10 11:23 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-10 14:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
[not found] <mailman.898.1336645753.855.help-gnu-emacs@gnu.org>
2012-05-10 11:23 ` Xah Lee
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).