Back to emacs for Ruby on Rails

I remember last Java Sun Tech Days @ Hyderabad, when James Gosling was asking the audience who all were out there still using old editors like emacs/vim. Hardly a bunch would have raised their hands. The point he was driving was that in this age, we should probably move away from these editors and get into the groove of modern IDEs like Eclipse/NetBeans as they give powerful features like refactoring, automated testing etc. So its not worth the effort to learn all those weird key combos to drive the work. Of course he was talking more in perspective of J2EE development.

So what makes me drive back in time to the good old editor of yester years? Well, first is I am now full time into Ruby on Rails. I started Ruby learning expedition with NetBeans. But then somewhere in between I learnt Oracle has stopped support for JRuby in NetBeans. So then I moved to gedit and installed all the relevant plugins to make it a gmate (the mac-textmate equivalent in Ubuntu). Even though it was too good than the conventional gedit, still a lot was desired. So finally I decided to take the plunge and get into emacs. The good old emacs which I had been using some 4-5 years back and then ditched it to enter the snazzy world of IDEs. First few days were time for refreshing those old commands C-x s and C-x c etc. After that things just rolled out fast.

Now I am fully hooked onto emacs – the beautiful editor of Unix. To facilitate Ruby/Rails development I went ahead and installed Rinari – The Ruby on Rails Minor Mode for emacs. From there there was no looking back. The awesome keys which Rinari provides has made Rails development a breeze. If you are a Rails guy you would savour this short cuts – a ready reckoner of keyboard commands in emacs for Ruby on Rails Projects.

C-c ; f c rinari-find-controller
C-c ; f e rinari-find-environment
C-c ; f f rinari-find-file-in-project
C-c ; f h rinari-find-helper
C-c ; f i rinari-find-migration
C-c ; f j rinari-find-javascript
C-c ; f l rinari-find-plugin
C-c ; f m rinari-find-model
C-c ; f n rinari-find-configuration
C-c ; f o rinari-find-log
C-c ; f p rinari-find-public
C-c ; f s rinari-find-script
C-c ; f t rinari-find-test
C-c ; f v rinari-find-view
C-c ; f w rinari-find-worker
C-c ; f x rinari-find-fixture
C-c ; f y rinari-find-stylesheet

Rinari makes navigating within the Rails Project a breeze. Say if you are in view page you do C-c ; f c it takes you to the controller of the corresponding page and from there do C-c ; f m you land in the model of that page. It’s intelligent to figure you out the correct file for that.

Also it includes the shortcut C-c; w which starts the webserver for you within emacs. The webserver logs are like just another buffer in emacs. So when some error crops up do a C-x b to switch to the logs then in the error line in the log just hit a you land at the source code line where error has occured.

On top of Rinari, its good also to install Ruby-Electric which helps in automatic bracket closure, indentation etc. Then add up AutoCompletion and RSense to get auto completion feature in emacs for Ruby/Rails code like any other modern IDE. This blogpost is a good reference to configure emacs for Ruby on Rails.

The good thing about emacs is its just not a editor its an ecosystem unto itself, each day I am discovering something new in emacs. Once you are proficient in emacs I think you need not go out to shell or anyother place everything can be accomplished within emacs. For instance I have started maintaining my calendar & dairy and daily notes within the emacs with M-x calendar command. I have started using emacs calculator for my math occassionally, now I am trying to bring in my google mail box within emacs, small pdf documents I read within emacs now.

So the clock has turned back – its sheer joy using emacs and learning those beautiful commands.

I am not sure if there is any other editor out there which has some much features rolled into it and allow customizations to crazy levels if you know a bit of lisp.

Advertisements

One thought on “Back to emacs for Ruby on Rails

  1. I don’t care what Go$ling says. The GNU Emacs is the one and only supreme editor, powered by Lisp, the language of the gods. Netbeans and Eclipse are nothing but the usual Java-based junk, only usefukl for people brainwashed by the decadent hardware industry and malevolent capitalist and imperialist Software vendors like M$ and Oracle.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s