As most of the time I work with Ruby and Ruby on Rails and Emacs is my favorite text editor I would like to devote my next post to the Emacs configuration.
Last week I have been customizing Emacs in order to simplify my work. Therefore, i would like to share my work with you.
I started with Emacs theme customization and used color-theme plugin, which can be found on Emacs color-theme plugin homepage or can be taken from Debian repository in emacs-goodies-el package. After the installation you have three options:
- Use one of the build-in themes (M-x color-theme-select);
- Create your own theme;
- Use mine :) (color theme)
For the options 2 and 3 you have to save the theme file into Emacs path directory and add the following line into your ~/.emacs file:
Also, as you have noticed, I set the custom font using set-frame-font (the font was chosen in xfontsel), disabled: toolbar, menubar and scrollbar.
Afterwards, I chose Rinari from a large list of Emacs Rails plugins. Rinari homepage.
The base Rinari directory is placed into Emacs path directory and the following code is added to ~/.emacs
The last hook for ruby-mode deactivates Emacs coding tags, automatically created by Emacs coding-system (that can be very uncomfortable while working with files that have Cyrillic symbols).
Unfortunately, Rinari does not include ruby-electric (helper for automatic brackets closure or any other language construction). To add ruby-electric copy ruby-electric.el to Emacs path directory and configure it into ~/.emacs
Generally, Emacs uses only one major editing mode, for example, ruby-mode in *.rb files. However, if we want to edit files that contain ruby and HTML we will have to either switch the modes every time or we can install MuMaMo (MultiMajorModes). MuMaMo automatically highlights the code and switches the major modes. Most often MuMaMo is used in *.html.erb files to edit ruby and HTML. MuMaMo is based on nXhtml. You can download the latest version of nXhtml (MuMaMo included) here.Unzip the archive and copy it into Emacs path directory. Add to ~/.emacs the following:
As I don`t like colored hunks, I set the variable MuMaMo-chunk-coloring being equal 5. This means that the coloring will turn on only for the fifth level, however, usually we see only three levels maximum.
Interactively Do Things
To speed up file management in you working directory you can use IDO helper (Interactively Do Things), which is a part of Rinari package. If you dislike it you can disable it any time.
Git in Emacs
As I use git a lot I included git-emacs (link) in Emacs as well:
In the last line I bound git-status function to C-x M-g combination.
Autocomplete plugin can be downloaded here. Unpack the plugin, copy to Emacs path and configure it:
As autocomplete has a short completion list. I used Rsense to extend autocomplete functionality. Further on I will tell how to install and configure Rsense in Debian (more detailed information for other OS you can find in Rsense installation guide).
So, having downloaded and unpacked the archive copy it into /opt directory and add local variable RSENSE_HOME that will keep the path to Rsense root directory. Afterwards, check whether bin/rsense can be executed and then create config file from Rsense configuration script.
What comes to the local variable RSENSE_HOME, add to ~/.bashrc the following line using your favorite editor:
Save the file, close the editor and open new console tab to re-read the configuration file.
That is all about Rsense installation.
Autocomplete with Rsense
To configure Emacs for Rsense and automplete + Rsense work:
That`s all folks! :) You can borrow my final version of ~/.emacs file here
Have a nice coding on Ruby on Rails with Emacs!