Five Minute Posts: The Hacker Within

Today’s topic: compiling in Emacs

Dude! Why didn’t I learn to do this a long time ago? I can’t believe how much it’s helped my productivity. I thought it would be all kinds of work, but that’s not so.

“M-x compile” will open a shell (in your present working directory) and let you edit the default compile command, which is “make -k”. (That’s an intentional outside-the-quotation-marks period, by the way. We’re talking syntax, after all.) Just edit that compile command (something to your compiler if you don’t have a Makefile) and press enter. Your code will be compiled in a special window called “compilation”. Now the super-exciting part. You can use the next-error and previous-error functions to move between the different compiler errors (and warnings). Your cursor jumps automatically to the place in your source code where the compiler’s reporting the error is located. As usual in these situations, I shudder to think about the cumulative time I’ve lost over the last year or so jumping between source code files manually in all the programming setups I’ve tried.

Here’s a screenshot and a link to my new .emacs file. I’ve bound the compile, next-error, and previous-error commands to Ctrl-o, Ctrl-p, and Ctrl-Shift-p, respectively.

(Click to enlarge.)

The Hacker Within IV

Today’s subject: Emacs matlab-mode, THW III update

Just a quick one right now. I needed to take a look at a MATLAB function today but didn’t want to have to look at it in MATLAB to get the syntax-highlighting right. Check out this link if you’ve had the same problem and want a matlab-mode customization in Emacs.

Also, someone on the Internet was wrong: me. Special thanks to Rob Kennedy for catching a bug in my SQLite sample application. Turns out I’d made a similar error in my “real” application using SQLite as well. Score one for the idea of blogs as a productivity tool, at least if you’re lucky enough to have smart friends and readers.

The Hacker Within I

I only blog from the office when I have something work-related to share. Now is one of those times.

Because code development is part and parcel of our work as computational researchers, my advisor encourages our group to unleash and cultivate “The Hacker Within” (THW). THW is always trying to improve his or her computing experience–customizing, automating, and navigating parts of the digital landscape in new (and hopefully more productive) ways. Plus, messing with THW-related projects is usually more fun than doing whatever work you’re supposed to be doing.

My THW project the last day or so has been switching over to using Emacs, which I have to say has already yielded some nice results. The learning curve on the key bindings is a little steep, but I’m getting better.

One of my long-time complaints with Emacs (or rather short-time, since I’ve only been using Linux for a year or so, which while I’m at it I should say that this and probably most future THW content will probably seem extremely lame to people who actually know what they’re doing) was that there is no single-keystroke way to switch between open files, at least none that I could find. That functionality is extremely important when you’re working with source code that’s spread out over a bunch of classes (and hence files).

Well, today my HW fixed that, or rather he found the code someone else’s HW had already written to fix that. I highly recommend Adrian Quark‘s Emacs customization buffer-stack, which brings Windows-Alt-Tab-like switching to Emacs buffers. I chose Ctrl-Tab for my key binding to his main function, as you can see from my .emacs file, which I include in the hope that it might be helpful to other new Emacs customizers-in-training.

Note: Other THW posts will be much shorter and to the point. I don’t take blogging at work lightly, but I do think that since I get so much help with code development from online sources, I have the responsibility to “give back” once in a while, to the pathetic extent that I’m able to. In this longish post, I just wanted to sort of establish the context of THW.