Starting with Emacs


It has been almost one year since I’ve started using Emacs. I think this is a good moment to give you some tips about starting using it. This isn’t typical tutorial, but rather the description of my approach to learning Emacs.

Let’s start

Before I even download the binary files of Emacs, I read quite a lot about it. In many guides I’ve read that instead of installing “plain” Emacs, I should try a preconfigured version of it. On Github you can find many Emacs distributions (or rather configurations) like:

Because I read lots of good opinions about Prelude, I’ve decided to use it.

Failure

Without any delays I’ve installed Emacs, pulled all code from Prelude repository into .emacs.d folder and I’ve started my journey. Telling the truth, this wasn’t a very long one. After starting Emacs, I did a basic tutorial (this is suggested by almost everybody and I also encourage you to do it - you can press C-h t to show it) and I was lost. There was no menu or toolbar that could help me. There was some active minor modes that I didn’t understand. My inner curiosity forces me also to look into .emacs.d directory. I wanted to understand the code that was there. For me, a Lisp beginner, this wasn’t an easy task - I couldn’t manage so much code. The result was, that after one day I’ve gave up and deleted Emacs from my hard drive.

(Please, don’t get me wrong I think that Prelude and other configs are great. They provide a superior, fully customized, experience when working with Emacs. Also their code base is well written and structured. Simply this wasn’t the right time for me to use them. If you are completely beginner then maybe it won’t be good for you too. But if you know Emacs a bit at least then you should definitely look at those distros. Right now I often read their code, to get some inspiration and learn new stuff)

Start it plain

I’ve return to Emacs again after one week of a break. This time I’ve decided that I will start with plain Emacs - without any modifications, with GUI that will help me. I’ve also used the default key bindings - even for “copy”, “cut” and “paste” which are awkward at the beginning, because they are different then the “Windows” one. I’ve used it for any task that I would normally do in Sublime text. I did them with problems. I was looking for help everywhere - in the Emacs build-in help (a very good one), in the Internet or through out available menus in toolbar. The time I’ve spent on a typical task was bigger then it would take me in Sublime, but I was stubborn. After some time I’ve started to feel more comfortable. I’ve known few key binding and commands. I found some places (like editing JavaScript or org-mode) where Emacs shines. I’ve also started to recognize elements of Emacs that I wanted to improve. This was a moment when I started to figure out how to customize Emacs.

Let it change

We as programmers love to code. This can be used to master Emacs skills. Emacs uses Lisp as a language for its extensibility and customization, so you can write “real” code to change it to your needs. I encourage you to experiment with the configs files. This will give you better understanding of Emacs and therefore better productivity. I also challenge you to change all Emacs config code in itself - this way you also level up your editing skills.

Let’s write some Lisp code

In Emacs all the configuration is done in init.el file (there are also other options, but I skip them for simplicity). The whole configuration is done through Emacs lisp code. When Emacs starts it evaluates the code in its config files. This code can change the look and feel of the editor (GUI) or define additional commands and functions.

The more advance Emacs configuration is usually splitted into many config files, that deals with different elements of Emacs (i.e. every file customizes different modes). When I started customizing Emacs, I wrote all my code in init.el file. I didn’t even try to write it in some meaning order. My main goal was to see what I can change and how:

  • how can I change the font or the color theme?
  • how can I use fuzzy search in buffer switching?
  • and many more…

To answer those question I’ve read lots of articles on emacswiki, I’ve looked at mentioned Emacs distributions code and of course I googled a lot. Before I’ve used any function, I’ve read its description. If I’ve copied some code snipped, I’ve spent time to understand it. I extend and extend my init.el file for a long time - to a moment when I was quite happy with the results. This gave me better confidence in working with and customizing Emacs.

Let’s improve

Of course, as almost every programmer I felt bad about my messy code in init.el file. After some time I’ve started introducing changes and splitting my confing into smaller, more readable and manageable files. My current configuration is heavily inspired by Prelude Emacs code - Bozhidar Batsov is great and very inspiring developer. You should definitely look at his work.

At present I don’t modify Emacs so much - I do it when something irritating me during my work.

If you still aren’t convenient to use Emacs, I need to say that every time I use Emacs I feel joy - this is so great text editor! I hope that you will find this joy too!

Previous post
Emacs

You may also like

Emacs

Moving to Octopress

Lesser known Clojure: reduce kv