run ruby from emacs buffer
You can do this with inf-ruby.el
.
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
.
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 inf-ruby run ruby buffer with argument?
The short answer: instead of M-x run-ruby
, call it with a prefix arg like so: C-u M-x run-ruby
. This will allow you to edit the command line.
The long answer: don't. Instead re-structure your code so that you can test / call all the functionality without relying on parsing the command line arguments. Then do some simple tests from the command line whether your argument parsing works out okay.
Ruby-mode in Emacs in short-cut key for compile/run?
I suggest using quickrun.el which is maintenanced by me.
quickrun.el is a extension to execute editing buffer.
quickrun.el supports many programming languages and markup languages, of course
it supports Ruby.
You download quickrun.el following URL.
https://raw.github.com/syohex/emacs-quickrun/master/quickrun.el
And you add quickrun.el following setting to your configuration file and evaluate it(or restart Emacs).
(add-to-list 'load-path "~/.emacs.d/elisp") ;; If you install quickrun.el to ~/.emacs.d/elisp
(require 'quickrun)
Now you can use following command to execute current buffer.
M-x quickrun
You can use compile current buffer(not execute).
M-x quickrun-compile-only
If you will often use quickrun command, you should assign key bindings, like following.
(global-set-key (kbd "<f7>") 'quickrun)
(global-set-key (kbd "<f8>") 'quickrun-compile-only)
Please see github page, if you know more information about quickrun.el.
Thanks
Running irb in emacs (via run-ruby) echos everything I type
The inferior Ruby mode is built on top of comint-mode.
I noticed that there was a comint variable named comint-process-echoes.
I set this variable to t (true) and the echoing stopped.
Here's how I set the variable:
;;; Define Ruby Mode Hook
(defun my-ruby-mode-hook ()
(progn
(setq comint-process-echoes t)
(turn-on-font-lock)
(auto-fill-mode)
(yas/minor-mode)
(inf-ruby-keys)))
;;; Register Ruby Mode Hook
(add-hook 'ruby-mode-hook 'my-ruby-mode-hook)
In Emacs irb (inferior-ruby-mode), how to make Autocomplete honor words from Ruby mode buffers?
look to ac-source-words-in-same-mode-buffers
... We can re-use this approach to build our own completion sources, for example:
(ac-define-source words-in-ruby-buffers
'((init . ac-update-word-index)
(candidates . (ac-word-candidates
(lambda (buffer)
(eq (buffer-local-value 'major-mode buffer) 'ruby-mode))))))
will give us ac-source-words-in-ruby-buffers
completion source.
P.S. I hadn't tested it, but it should work ;-)
Ruby on Emacs Package Installation
electric-indent-mode
is a global minor mode (i.e. it applies to all buffers in all modes), so just enable it once in your .emacs, no need to play around with hooks.
Setting up .emacs file for mac ruby development
Put the line (warn "Loading .emacs")
as the first line of .emacs. When you start emacs does it show you that message in a warning buffer? If so, it at least started loading the file.
If this does nothing, try opening the file in emacs, and running M-x eval-buffer
.
Also, at startup, does the Messages buffer indicate any errors in your .emacs? This is the most common reason for a .emacs not to take effect.
Related Topics
Add Current Time Before Log Message
Naming Conventions for Boolean Attributes
Fresh Install of Rvm in Ubuntu Isn't Letting Me Install Gems (Zlib Error)
How to Find Out the Starting Point for Each Match in Ruby
Is There a Shorthand If (Without Else) Statement in Ruby on Rails
Simple_Form with Bootstrap Check Box
Approach for Installing System Service Implemented as Ruby Gem
Alter Rails Params Hash from Rack Middleware
Is There a Definitive Reference Document for Ruby Syntax
How to Install and Use Slim Template Engine with Middleman
Rails Console Fails with 'Switch to Inspect Mode' in Windows
Ruby Method, Proc, and Block Confusion
Implicit Argument Passing of Super from Method Defined by Define_Method() Is Not Supported
Heroku: Pg::Connectionbad: Could Not Connect to Server: Connection Refused
Have a Parent Class's Method Access the Subclass's Constants