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.
neeeeeeeeeeeeeeeeeeeeeeeerd