Strange indentations in JODE's source code

Help
2006-12-16
2013-05-02
  • Trevor Harmon
    Trevor Harmon
    2006-12-16

    JODE's source code uses a mixture of tabs and spaces for indentation. This wouldn't be a problem, except that the space and tab settings do not match. For example, take a look at the static initializer of the LocalVariableInfo class. The static block delimiter (lines 43 and 45) is indented with four spaces. However, the body of the block (line 44) is indented with a single tab. Shouldn't it be indented with two tabs instead?

    I find that if I change my tab settings such that each tab expands to 8 spaces, then all indentation appears correct. However, using an 8-space tab in my text editor causes lots of problems because JODE's source code occasionally uses 4 spaces (not 8) for indentation.

    Is there a reason for this strange indentation?

     
    • The size of a tab defaults to 8 under many unix utilities (even xterm uses this).  On the other hand 8 space indentation is too much to fit everything in 80 columns, so I used 4 space indentation.  Emacs has the feature to automatically indentate either with tabs or spaces (i.e. replacing two indentation steps with a tab), so this is used throughout the source code. 

      In the mean-time I tried eclipse.  After a bit of trial I found out how to change tabs to 8 spaces in the editor, so that it is usable with jode's source code.

       
      • Trevor Harmon
        Trevor Harmon
        2006-12-17

        "The size of a tab defaults to 8 under many unix utilities (even xterm uses this). On the other hand 8 space indentation is too much to fit everything in 80 columns, so I used 4 space indentation."

        That's all fine. I don't care whether it's tabs or spaces or 8 or 4. But the problem I see is that the spaces don't match the tabs. In some places, two indentations = 8 spaces, while in other places, two indentations = 1 tab. And therefore one indentation = 1/2 tab, which doesn't make sense.

        "Emacs has the feature to automatically indentate either with tabs or spaces (i.e. replacing two indentation steps with a tab), so this is used throughout the source code."

        That's very strange. Why would one tab equal two indentations?

        "In the mean-time I tried eclipse. After a bit of trial I found out how to change tabs to 8 spaces in the editor, so that it is usable with jode's source code."

        Yes, in my text editor as well, changing the tab setting to 8 spaces makes the indentation look consistent (that is, 4 spaces throughout). But unfortunately it doesn't solve the problem. That's because if I hit tab to indent, my cursor moves 8 spaces (since the tab setting is 8). And that's different from the rest of the file, which is 4 spaces.

        Doesn't Eclipse have the same problem?

         
        • Eclipse has the "Mixed" mode, which is just like in emacs.  One can say indentation=4 spaces, tab=8 spaces. Pressing tab inserts 4 spaces, pressing tab a second time removes the 4 spaces and inserts a tab.  It's not exactly like in emacs.  In emacs pressing tab autoindents the current line according to the current indentation scheme.  If the line is correctly indented, pressing tab has no effect.

          I even used this scheme of different tab and indent size in the TabbedPrintWriter (although you can easily reconfigure it, e.g. to not use tabs at all, or you can set indent=tab size).

          Maybe it is the best to change tabs to spaces some day.  However, then there is still the problem that other developers use 4-space tabs, which looks good in their editor, but not when looking at the file on the console.

           
          • Trevor Harmon
            Trevor Harmon
            2006-12-17

            Interesting, I get it now. Thanks for the clarification.

            Unfortunately my text editor does not support mixed mode, although somebody wrote a script that can manually convert selected text to and from it:

            http://comox.textdrive.com/pipermail/textmate/2006-November/015565.html

             
          • Trevor Harmon
            Trevor Harmon
            2006-12-20

            "Maybe it is the best to change tabs to spaces some day."

            I'd be in favor of that. In fact, I think Sun's Java coding standard requires spaces instead of tabs. If you like, I could submit a patch that performs this conversion on the entire trunk.

            "However, then there is still the problem that other developers use 4-space tabs, which looks good in their editor, but not when looking at the file on the console."

            I don't see this as a problem. I like to use 4-space tabs, but when I'm editing someone else's code, I simply adjust the settings in my editor so that it fits their coding style.