Setting up Emacs for Ruby Programming

Photo by Joshua Fuller on Unsplash

This is a short note how you can set up your Emacs editor for programming in Ruby within seconds.

The settings for your emacs is explained in detail this blog here.

I personally in my Ubuntu Linux home folder created a folder named emacs to put there all kind of settings for my emacs. Here, I create a folder for ruby in this folder and enter it:

$ mkdir -p ~/emacs/ruby
$ cd ~/emacs/ruby

Then, I git clone a folder containing the init.el file with all necessary settings for ruby programming by:

$ git clone

And now comes the step and knowledge which took most of the time to find it out:

Usually emacs people do something like

$ mv ~/.emacs.d ~/.emacs.d.orig
$ mv ~/some_settings_folder ~/.emacs.d

And later have to name the renamed folders back. This is quite error prone.

A better solution is to start your emacs by:

$ env HOME=$HOME/emacs/ruby/emacs-for-ruby emacs &

This defines the folder containing the init.el for emacs as $HOME for the command emacs &. The disadvantage however is, if you call system commands from within your script using absolute paths or paths requiring your actual $HOME.

The advantage however is that you don’t have to rename folders which can mess things up a lot.

Since I want to call emacs for ruby programming by the command $ ruem (for rubyemacs), I add to my ~/.bashrc file:

alias rubyemacs="env HOME=$HOME/emacs/ruby/emacs-for-ruby emacs &"
alias ruem="rubyemacs"

And source the ~/.bashrc, and can call my emacs with ruby settings by:

$ ruem

In my particular case, since I have my emacs locally installed in a conda envrionment named emacs, I entered into my ~/.bashrc:

alias rubyemacs="source activate emacs && env HOME=$HOME/emacs/ruby/emacs-for-ruby emacs &"
alias ruem="rubyemacs"

This activates first the conda environment by source activate emacs (or conda activate emacs, before it calls emacs with the newly defined $HOME.

The init.el file of emacs-for-ruby takes care of all necessary installations in emacs’ site.




Code tweaker + Human Geneticist (Ph.D.) | Join medium by:

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Top Flutter App Development Companies

Top Flutter App Development Companies

Looping in Java

Weekly Update: W/C 19th August, 2019

Is There Any Text Analysis API in JSON?

The Simple Introduction to Hadoop EcoSystem

Creating Navigation using

MongoDb observability with sidecars, Prometheus and Jaeger

Is There Any Real-Time Email Classification API?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gwang Jin Kim

Gwang Jin Kim

Code tweaker + Human Geneticist (Ph.D.) | Join medium by:

More from Medium

Going backstage — building a Ruby CLI app

Working with ruby C extensions on Mac

Custom Active Model Serializers

Not all programming languages are created equal (not shit Sherlock). Ruby vs Python