Emacs and rails

Up until now, I’ve been using TextMate to develop my rails applications.
However, I develop on a Linux box as well, and I want my development
environment to be consistent over the two computers, my macbook and my
linux box.

So I decided to give emacs a try. I am slowly learning how to get a
handle on this editor, and it’s loads of fun.

I was wondering, if some of you other emacs rails people could post
there .emacs files so that I (and anyone else interested) could check
them out, and hopefully learn something from them.

I am learning the emacs editor along side the rails-emacs el package.
So far I’ve been pretty un-productive, but I am getting better. You
know how in textmate you can hit Cmd-return and it will give you an
indented new-line from wherever you are on the previous line? Is there
a way to accomplish this in emacs? Also, I can’t seem to figure out how
to set the tab indentation to 2 soft spaces. I’ve got (setq tab-width
2) in my emacs file, but it doesn’t seem to effect anything as I am
still tabbing 8 spaces in everything but ruby/erb files.

On Dec 19, 1:05 pm, Matt S. [email protected] wrote:

them out, and hopefully learn something from them.

I am learning the emacs editor along side the rails-emacs el package.
So far I’ve been pretty un-productive, but I am getting better. You
know how in textmate you can hit Cmd-return and it will give you an
indented new-line from wherever you are on the previous line?
Is there a way to accomplish this in emacs?

The command is newline-and-indent. It is usually bound to Control-J.
Have you tried Control-H m (help for mode) and Control-H b (list key
bindings) ?

Also, I can’t seem to figure out how
to set the tab indentation to 2 soft spaces. I’ve got (setq tab-width
2) in my emacs file, but it doesn’t seem to effect anything as I am
still tabbing 8 spaces in everything but ruby/erb files.

M-x set-variable ruby-indent-level 2

You might want to set that in your emacs initialization file.

On Wed, 2007-12-19 at 14:05 -0500, Matt S. wrote:

them out, and hopefully learn something from them.

I am learning the emacs editor along side the rails-emacs el package.
So far I’ve been pretty un-productive, but I am getting better. You
know how in textmate you can hit Cmd-return and it will give you an
indented new-line from wherever you are on the previous line? Is there
a way to accomplish this in emacs? Also, I can’t seem to figure out how
to set the tab indentation to 2 soft spaces. I’ve got (setq tab-width
2) in my emacs file, but it doesn’t seem to effect anything as I am
still tabbing 8 spaces in everything but ruby/erb files.

Ok here is my .emacs file:

(setq load-path
(append (list nil “~/lisp/”
“~/lisp/arorem/”
“~/lisp/custom/”
“~/lisp/nxml_mode/”
“~/lisp/rinari/”
“~/lisp/rinari/rhtml”
“~/lisp/icicles”
“~/lisp/shared/”)
load-path))

;; here let’s load everything in proper order here
(load “setup.el”)
(load “01bm.el”)
(load “02ruby_mode.el”)
(load “03rails.el”)
(load “04nxml.el”)
(load “05ido.el”)
;;(load “07vm.el”)
(load “08fri.el”)
(load “09org.el”)
(load “10sql.el”)
(load “11erlang.el”)
(load “12rd.el”)
(load “13rcode.el”)
(load “last.el”)
(load “my_snippets.el”)

(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won’t work right.
'(bm-persistent-face ((((class color) (background light))
(:background “MistyRose” :foreground “Black”))))
'(font-lock-comment-face ((((class color) (min-colors 88) (background
light)) (:foreground “grey64” :slant italic :family
“--helvetica-medium----12-------*”)))))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won’t work right.
)

And You can download ready to run/work lisp files from
http://syncnotes.googlecode.com/files/lisp.tar.bz2

The caveats are, I have obviously customized emacs, to suit my taste
of key bindings, and hence for me Control-W is backward word delete,
and region kill is C-X,C-K

Other set of shortcuts are basically inspired from here:

Unzip the archive and put it under directory ~/lisp . If you in home,
it would automatically create that directory for you.

lisp
|
|---- rinari
|---- xxxx

And put the above .emacs file in your home directory and restart your
emacs. For using above packages, you must be running > Emacs 22

Snippets, ruby debugging, control/view/testcase switching, console,
irb, and many other things should work out of the box.

All the best


Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org

Very cool, that is getting closer. However, the newline-and-indent will
still break a line if you are in the middle of it. The behaviour I am
looking for, would be something like jumping to the end of the current
line, followed by a newline-and-indent. Supposing there is no one
command to accomplish this, is there a way to bind two actions to a
single key combo?

Thanks for you help!

Thank you my friend, this is very useful. I see that you are using
Rinari. I heard that the rails-emacs group was going to be merging
rinari into itself. Did that already happen? Is that even accurate
info?

Thanks again!

On Dec 20, 12:31 am, Matt S. [email protected] wrote:

Very cool, that is getting closer. However, the newline-and-indent will
still break a line if you are in the middle of it. The behaviour I am
looking for, would be something like jumping to the end of the current
line, followed by a newline-and-indent. Supposing there is no one
command to accomplish this, is there a way to bind two actions to a
single key combo?

That would be Control-E Control-J, which requires only three key
presses: control, E, J. You could create a keyboard macro or lisp
function
and bind it to some key and see if it really helps. I type Control-E-
J so quickly that it wouldn’t make much difference to me.

P.P.S.- I hate wordpress, will eventually move to my own Rails app for
blogging…

I’ve got some blog posts on setting up Aquamacs/generic emacs to use for
Rails development and other stuff here:
http://blog.katipo.co.nz/?p=39

http://blog.katipo.co.nz/?p=38

http://blog.katipo.co.nz/?p=21

You might some of it handy.

Cheers,
Walter

P.S. - I must admit Aquamacs 1.2 is annoying the hell out of me right
now,
for some reason it has disabled C-space as “set mark”. Some other
funkiness
that might be related to my set up, so be warned.

Cheers for this! Good stuff in there.

On Dec 19, 11:09 pm, kevin cline [email protected] wrote:

I type Control-E-J so quickly that it wouldn’t make much difference to me.

I can’t help noting that the equivalent vi command would be “o”.

///ark

Unless you are in insert-mode, then it would be escape-o. But first
you’d have to check your mode, then type the command. About the
same…

I always wanted to use vim / gvim for rails development, I thought it
was more elegant and simple compared to emacs, but the escape is a
little far away to be comfortable in touch typing. I’m sure that
someone will tell me that you can just remap Esc to another key, but
this is my reasoning for choosing emacs in the end.

On Dec 23, 1:03 pm, fredistic [email protected] wrote:

Unless you are in insert-mode, then it would be escape-o. But first
you’d have to check your mode, then type the command. About the
same…

That’s not how vi users work. For us, there are commands (like o) and
insertions (like ithisisaninsertion). The Esc is part of the
insertion. If you’re experienced, you don’t really have to think about
modes.

///ark

This looks like something peculiar to my user environment which I
haven’t
figured out yet. It’s not in Aquamacs or emacs from what I can tell.
Cheers,
Walter

On Dec 24, 9:26 pm, Matt S. [email protected] wrote:

I always wanted to use vim / gvim for rails development, I thought it
was more elegant and simple compared to emacs, but the escape is a
little far away to be comfortable in touch typing. I’m sure that
someone will tell me that you can just remap Esc to another key, but
this is my reasoning for choosing emacs in the end.

I’ve always used ^[ for Esc. ObRails: There’s a good plugin for Rails
development with vi available.

///ark