Indentation Hell

I'm currently working on a Python application that has about 1500 lines of code. The whole stuff was in one file and it was a pain maintaining it in this form so I decided to make separate files per classes. At the same time a class browser would really skyrocket my productivity, I thought. Throughout the development I used mcedit, later Emacs, then Kwrite and my last choice is eric3, a fascinating Python IDE with class browser and lots of goodies. The only thing I don't like in it is the Qt GUI, but user interface inconsistency probably won't kill me.

My switch from mcedit to Emacs is not hard to understand I guess considering its features and the fact that I love it. But my next switch from Emacs to Kwrite doesn't make much sense, right? I can justify my decision with one word: Indentation.

When I moved to Emacs and visited the original source file, I observed that the lines are incorrectly indented in it. When I changed several of them, Python immediately reported the indentation errors as soon as I executed the script. At that time I just wanted to get over the whole thing, tried Kwrite and it handled the indentation correctly. After that when the code has grown bigger and I needed eric3, the same problem happened and I had no choice then. I had to investigate this problem.

After some time, I realized that a lot of *nix editors (like mcedit) uses half-tabs. That's an evil concept. It's basically the most stupid way one can encode indentation.

In the simplest case, there were only tabs or spaces. In a more complex case, there were both tabs and spaces and tabs had a fixed size. And finally in the braindead case, there were half-tabs. I've written that solves this problem by converting half-tabs to spaces.

Update: In the meantime I've realized that the GNU expand utility does the same thing and is much more mature than my spacify script, so you should probably use expand.

Leave a Reply

Your email address will not be published.