Devigner blog about development and design

Distraction Free Programming With GNU Emacs


Since becoming a switcher in 2004 I exclusively did my work in Textmate. Early summer 2008 I started to explore other options. I spent a couple of months in Vim, MacVim to be precise, and really enjoyed it. After I got comfortable with MacVim, it’s tabs and use of NerdTree for file management started to feel a lot like Textmate. That’s not necessarily a bad thing, just not what I was really looking for.
h3. emacs

During my Vim use, I launched emacs (Carbon Emacs) a few times and was turned off by the key combinations. However, the more I played with it, the more I liked it and the key combos quickly became a non-issue; almost second nature. If i wanted to cheat, i can turn on mac-key-mode for shortcuts that behave like Mac programs. Emacs runs on windows and linux so I decided to take the plunge and learn key combos the emacs way in case I have to jump to Ubuntu.

A Distraction Free Work Environment

For distraction-prone people like me, emacs excels in the full-screen department. When I think full screen I think Writeroom, Aperture and Lightroom, where everything is gone including the menu bar leaving me with nothing except the task I’m working on. This is something I could not effectively do with Textmate and I found myself constantly switching between Textmate and Terminal to get my work done, with an occasional jump to Twitterific, NetNewsWire and irc.


[Full-screen capture: this is all i see when I’m working in emacs.]


[Full-screen: mouse-over menu bar]


[Full-screen: alternate layout]

Explanation of screenshots

Windows in emacs are backwards from what you expect them to be. Emacs calls the collection of windows or a single window a frame and a frame can be split horizontally or vertically in a number of ways to create multiple windows. Depicted in the screenshots I have everything I need. The top window is the code I’m currently working on. In the lower left window I have dired for my file management and terminal (or shell) in the lower right so I never have to switch between emacs and Terminal. The third screenshot is simply a illustration of another way I find myself splitting the frame.

Snippet for full screen toggling

I have my full screen toggle tied to the key combo Meta-[RET]. That’s command+return on a mac. To use this add the following to your .emacs file and restart or refresh emacs.

;; full screen toggle using command+[RET]
(defun toggle-fullscreen () 
  (set-frame-parameter nil 'fullscreen (if (frame-parameter nil 'fullscreen) 
(global-set-key [(meta return)] 'toggle-fullscreen) 

In the coming posts in this emacs series I’ll break down dired and the use of shell (or terminal) and how to use these tools effectively.

[Update: i’ve made my dotemacs available in case anyone wants to take a peek. Suggestions are welcome]