LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2007, 06:12 PM   #1
lilili
Member
 
Registered: Jan 2006
Location: SantaBarbara
Distribution: Slackware 12.1
Posts: 196

Rep: Reputation: 30
[ruby with emacs] taking user input


Hi everyone
I've just start to learn ruby. I'd like to use my emacs as my ruby editor.
I've download the el files that I think are necessary to run ruby mode on emacs
I've put the el files in /usr/share/emacs/21.4/site-lisp
some of the files that I have are
inf-ruby.el
ruby-mode.el
rubydb3.el
ruby-electric.el
snippet.el
find-recursive.el and some others

here is my .emacs file that is related to ruby mode

(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
)))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar "IMENU")
(require 'ruby-electric)
(ruby-electric-mode t)
))


(modify-coding-system-alist 'file "\\.rb$" 'utf-8)
(modify-coding-system-alist 'file "\\.rhtml$" 'utf-8)

(defun try-complete-abbrev (old)
(if (expand-abbrev) t nil))

(setq hippie-expand-try-functions-list
'(try-complete-abbrev
try-complete-file-name
try-expand-dabbrev))

(require 'rails)
(require 'snippet)
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) interpreter-mode-alist))

(require 'ruby-mode)
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)))
;; If you have Emacs 19.2x or older, use rubydb2x
(autoload 'rubydb "rubydb3x" "Ruby debugger" t)
;; uncomment the next line if you want syntax highlighting
;;(add-hook 'ruby-mode-hook 'turn-on-font-lock)

below is the code that I try to run in emacs buffer
print('Enter your name: ' )
name = gets()
puts( "Hello #{name}" )
Here's how I try to run it
esc -x compile, ruby input.rb
but when I type in the name and hit enter, emacs says no more errors yet
it seems that every time I try to user input and hit enter it says no more errors yet instead of taking the value entered.
Anybody has an idea why this is happening?

Thank you
 
Old 01-16-2007, 11:53 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
I don't know a whole lot about Ruby, but the compile command is not really for meant for interactive commands.
Try
Code:
M-x run-ruby
and then the Ruby command that runs/loads a file (there might also be a binding for doing that, try C-h m in a Ruby buffer to get some more help) in the buffer that pops up.

PS: please use [code] tags.
M-x means esc-x in Emacs notation (On most systems alt-x also produces M-x) and C-x means ctrl-x for any character x.

Last edited by ntubski; 01-16-2007 at 11:55 AM. Reason: must read posts more carefully
 
Old 01-18-2007, 12:17 PM   #3
lilili
Member
 
Registered: Jan 2006
Location: SantaBarbara
Distribution: Slackware 12.1
Posts: 196

Original Poster
Rep: Reputation: 30
Thanks , I will try that.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tty not taking keyboard input plus clock problem Treize.k Linux - General 1 10-31-2006 05:46 AM
123 file input is not taking for i in $(cat ./123) procfs Programming 3 07-20-2006 04:10 AM
weird emacs/xemacs problem Suse 10.0: no keyboard input rewtedesco Linux - Software 3 07-13-2006 10:08 AM
Granting SSH access to a Ruby on Rails user calande Linux - Security 1 01-12-2006 02:33 PM
Emacs 8-bit input as meta key cilantro Linux - Software 5 12-11-2003 11:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration