Ionrock Dot Org

by Eric Larson

My Weblog

Emacs: For Those Not Command Line Inclined

At work most folks use Vim. I use Emacs. We have fun debates all the time regarding why each other's editors are better. Nothing serious, just fun. One of the things I've realized is that I do most of my work within Emacs, which is a pretty common sentiment for Emacs users. I run servers, ipython, diffs, irc, tweet, etc. all in Emacs. I'm realizing part of the reason Emacs appeals to me in such a way is that it effectively has become my desktop environment through the shell. To put it another way, my command line skills suck, so Emacs is my GUI.

This became extremely clear to me when I was going to apply a diff. I had started working on a feature around the same time we were going to make a release. I was bouncing back and forth between branches, making fixes and moving forward a new feature. At one point, I realized I was working in the wrong branch. I needed to move my uncommitted work to the default branch and push my release branch changes. I didn't want to commit and then transplant the changes. That seemed like a bad idea because that would be a commit and then revert of the code in the log. It seemed like a good time to try and learn how to really work with diffs and patches so I did a quick "hg diff > release_to_default.diff" and was on my way.

After pushing my release changes, I needed to figure how to apply the patches in the diff. I started looking at the patch command. Back in the day, I used to try and do things like patch my kernel, but the whole patching experience was never very fluid to me. I didn't do nearly enough to become proficient. Realizing my desire not to actually use the patch command, I went ahead and opened the diff file in Emacs. Sure enough there was syntax highlighting for diff output along with a diff-mode menu. I took a quick look at the menu, saw C-a C-c applies a patch to a file. One keyboard command later, I had applied part of the diff file. A few more commands later and I was done! Very nice.

I'm obviously avoiding some potentially important information here by choosing the Emacs way over learning something about the patch command. I can't say I'd reccommend the same steps. At the same time, it was so easy! Some day I'm really hoping I'll get my head wrapped around using a shell like a real guru, but for the time being, I don't mind a little magic in my editor... Even if the Vim folks make fun of me for it!

Posted Fri Feb 13 16:36:11 2009 by Eric Larson

Twitter

Links

Reading

Created using Python, jQuery and Emacs