Uncategorized

Filling code in Emacs

Emacs is great, but one of my pet peeves is that while it can fill (ie wrap) plain text, it can’t fill source code.

I’ve recently been working on fillcode, an Emacs minor mode that does this. It’s best described by example. Fillcode fills this:

public static void foo(int i, float f, String s) {

to this:

public static void foo(int i, float f,
                       String s) {

Fillcode can fill any parenthesized expression, including function prototypes, function calls, and conditional expressions. It only breaks lines at commas and binary operators, and correctly preserves embedded comments and string literals. It also normalizes existing whitespace and line breaks.

It’s not perfect yet, but I’ve put up an initial release. Feel free to check it out, or just download fillcode.el and go to town. And if you do, please let me know what you think!

Standard

One thought on “Filling code in Emacs

Leave a Reply

Your email address will not be published.