Archive for the ‘emacs’ Category

C++ Syntax Highlighting for GNU Emacs/XEmacs

Tuesday, June 23rd, 2009

Several years ago the C++ syntax highlighting support in Emacs was pretty terrible.  The XEmacs support was particularly atrocious (and still may be).  To remedy that, I wrote my own syntax highlighting package for XEmacs originally, and then I ported it to GNU Emacs.  Back then I cared a lot more about the schism between XEmacs and Gnu Emacs.  Writing this package is one of the major impetuses for getting me to care a whole lot less about the politics of free software.


Custom Coding Style

Monday, June 22nd, 2009

If you are a programmer canny enough to use Emacs, chances are your skills are in high demand.  That being the case, you will likely work for several different companies or at least for several development projects — and each will of course have different coding styles.  I personally feel strongly about how code should look, but I feel even more strongly that all code for a project should look the same.  And old formatting habits die hard, so just let your editor/ide do the the tabbing and spacing for you.  So, here is the code style customization script I wrote when I worked at Stronghold Technologies, Inc.:


With this little bit of lisp, I could toggle my coding styles depending on whether I was working on Stronghold’s software or tweaking my own projects.

Emacs Configuration File

Sunday, June 21st, 2009

In the past, I was a devotee of the Emacs editor for all of my programming tasks.  Emacs is not easy to master, but it really isn’t that bad to learn if you have someone to show you a little bit at the start.  I learned it because the only other option was vi, and I don’t enjoy vi.  But there are plenty of other reasons to learn Emacs, including as a step toward learning elisp, Emacs’ very own version of the lisp programming language.

One problem with Emacs is, that out of the box, it doesn’t come configured particularly usefully.  Here is a config file to get you started.  It used to work on both Emacs and XEmacs, but I stopped using XEmacs entirely about 5 years ago, so there is probably stuff in the file that will not work in XEmacs.  I won’t go into all the details, but it uses conditional loading, and lots of other goodies to avoid the problem where Emacs won’t finish loading the config when it encounters an error.  You should probably use this, as it configures basic support for many common programmer packages.  Additionally, I sat down and worked
out good color schemes for everything.  The only caveat is that it no longer supports every flavor of emacs I could find, just too much of a headache to test.  Just download it, and rename it to .emacs in your home directory, and away you go:

.emacs customization file

I still use Emacs, and I certainly appreciate it’s existence, but for programming I now use Eclipse.  As of Europa, Eclipse has surpassed Emacs as a programming environment — finally.  It really was ridiculous that Eclipse couldn’t surpass simple, old Emacs for the longest time.  I still use Emacs for editing Latex documents, and when I need to do some serious scripting, Emacs tends to get used as well.