On Thu, Dec 05, 2002 at 05:57:46PM +0900, Harry Ohlsen wrote:

> I seem to recall someone wote some macros to execute Ruby code in
> vim ... 

Now don't think that I'm trying to entice anyone to the dark side, but
with Emacs ;-) I'm using a nice little snippet in my ~/.emacs that
would be perfect for nubies:

(defun ruby-eval-buffer () (interactive)
  "Evaluate the buffer with ruby."
  (shell-command-on-region (point-min) (point-max) "ruby"))

(defun ruby-custom-setup ()
  (define-key ruby-mode-map "\C-c\C-c" 'ruby-eval-buffer))

(add-hook 'ruby-mode-hook 'ruby-custom-setup)

Whatever buffer you are in, as long as it is in Ruby mode (and it will
be if you started with `emacs foo.rb'), just press `c' twice while
holding down the control key and the buffer's content will be piped
into the interpreter.  No need to save, no need to switch to the
command line, very IDE-like.  The result appears in a new window.

Unfortunately it won't work at all with interactive programs.  Some
day I'll look into the misteries of comint-modes...


Massimiliano