Emacs My Way

Everyone knows Emacs is a way of life.

You start learning it the first day and you never stop learning. If you think you’ve learned it all then you’re doing it wrong.

I started reading about Emacs when a funny joke about it was “EMACS: Eight Megabytes and Constantly Swapping”, but I never thought I would eventually get into it.

About twenty years have passed before I decided to give it a try, and since then I had to spend around two full years memorizing key chords. I am a happy user now, and here’s some tips to shorten your learning path 🙂


I will assume you have your standard Emacs installation working. I use homebrew on OSX to install it with:

    brew install emacs --HEAD --use-git-head --cocoa --srgb

Once you do that make sure it runs, and then clone my emacs.d repo. Save it as ~/.emacs.d, launch emacs and you’re almost done 🙂

It will take a while installing several libraries and it might require you a couple of Emacs reboots to finish installing everything.

Since you’re here reading and waiting that Emacs is done doing its magic stuff let’s discuss how my setup works.

Everything is based on el-get. El-get is a kind of meta-package-manager for Emacs.

It allows you to install and manage packages from multiple sources. Package.el, Emacswiki, github, you name them!

El-get also allows you to quickly whip up your recipes for forked or newer version of packages, very useful (check ~/.emacs.d/el-get-user-recipes/autotest.rcp to check one).

El-get also has a way to neatly package custom init files for the packages you install with it (check ~/.emacs.d/el-get-user/init). 

I use el-get to install all the different packages I use in my daily routine. As of today, but it varies wildly with time, I use:

  • ag, emacs frontend to the silver_searcher, blazing fast search in your projects. AMAZING!)
  • autotest, to continously run your test suite in a buffer
  • bundler, to run bundler commands from emacs, kinda quirky for now
  • coffee-mode, for your Coffeescript needs
  • gist, very useful when there’s a snippet you want to share with the outside world right now
  • go-mode, because the cool guys program in Go now, don’t they?
  • ido-ubiquitous, extends the essential ido-mode to every type of minibuffer query
  • magit, because once you learn to use git from emacs you won’t ever go back to the terminal anymore
  • markdown-mode, for your README.md 🙂
  • paredit, when you want to hack lisp dialects you also want your parentheses not to get in your way
  • php-mode, no comment here
  • powerline, to improve the look and feel of your status line
  • rspec-mode, run specs from emacs, get back results that are hotlinked to the sources. Very useful.
  • ruby-compilation, run scripts and rake and other Ruby stuff from Emacs
  • rvm, allows you to switch ruby versions and gemsets from the editor
  • smex, similar to ido-mode, for M-x commands
  • yaml-mode, sooner or later you’ll need to edit yaml files too 🙂
  • zenburn-theme, for a color theme that improves your health

As you can see from my packages, I am mostly a Ruby developer, but you can easily switch, remove and add to the packages you use by using M-x el-get-install, or edit ~/.emacs.d/init.el.

In addition to init.el and the el-get-user folder, there are four more files in my installation:

  • functions.el, here you can find some functions I defined for general usage. I am moving most of the things you can find here in el-get-user/init
  • defaults.el sets up most of your environment. You know, defaults 🙂
  • languages.el holds configuration for programming languages major modes. I am also moving code away from here and into their el-get-user/init files
  • system.el contains information about your system. You should for sure edit the following line to match your system, or lots of things won’t work
    (if (not (getenv "TERM_PROGRAM"))
    (setenv "PATH"
            (shell-command-to-string "source $HOME/.bash_profile && printf $PATH")))

In addition to using lots of packages to help your daily endeavor, there are some defaults I put it to ease the transition from other less powerful  younger editors (I used to use Textmate).

Remember, you will get lost in Emacs at first, and you will panic. Don’t! Just remember that C-x C-c allows you to quit and try again 🙂

Once your muscle memory wraps around the key chords you need for your programming needs, you’ll be a better person, and a happier programmer.

And you’ll also love Emacs, like I do 😉

Kim Jong Un approves

Note from the editorial staff: This is the last post on dev.mikamai.com until next year! Thanks everyone for following us, on January we’ll be back with more Emacs Lisp, Ruby, Arduino, Raspberry PI, Python, Go, PHP, Prestashop, …

Leave a Reply