Spacing issues

Ryan Schmidt ryandesign at macports.org
Fri Feb 9 09:53:19 PST 2007


On Feb 9, 2007, at 11:43, Kevin Ballard wrote:

> On Feb 9, 2007, at 12:39 PM, Ryan Schmidt wrote:
>
>> I assume that's due to the stupid setting available in emacs or vi  
>> or whatever editor it is that actually encourages that behavior.  
>> The one where they've said "We want to indent to 4-space tabs.  
>> However, the editor is configured to print 8 spaces for a tab.  
>> Therefore, when we want to indent one level, we will use 4 spaces,  
>> and when we want to indent 2 levels, we will use one tab, and when  
>> we want to indent three levels, we will use one tab and then 4  
>> spaces." And so forth. I'm convinced such an editor setting exists  
>> somewhere, because I have seen this nonsense in other projects  
>> too, even to the extreme of 2-space indentation. (Indent sequence:  
>> 2 spaces, 4 spaces, 6 spaces, one tab, one tab and 2 spaces, etc.)
>
> I doubt that's the case. I see this in places where there's 2 tabs  
> followed by 4 spaces. Why would somebody have their tabs set to  
> width 8 and then want to indent 4 for a nesting level? That makes  
> no sense.

It makes no sense to me either, but I have seen it occur, and hadn't  
come up with another explanation for how it could come about. Perhaps  
it comes about from one person using an editor that uses tabs, and  
then someone else who uses an editor that uses spaces. I don't know.


>> No, not really a problem. I would accept extra disk space if this  
>> solution brought significant advantages, but I'm saying it brings  
>> drawbacks.
>
> Do you view commenting code as a drawback as well? That adds far  
> more disk space than changing tabs to spaces does. The disk space  
> is simply a non-issue.

No, if course I don't object to comments, and I meant to say that I  
would happily accept the extra disk space needed by using only  
spaces, if using only spaces brought only advantages. However, I had  
intended to point out in the rest of my email that I see some  
disadvantages as a result of this practice.


>> I use TextWrangler, the free sibbling of BBEdit.
>>
>> Also, if I press the Tab key on the keyboard, it inserts a tab  
>> character. Even if I could tell the editor to insert spaces  
>> instead, I would not configure my editor this way, because that is  
>> not how I want to use my editor in every other text file that I edit.
>
> Funny, I use soft tabs almost exclusively, and dislike it when I  
> have to switch back to hard tabs just to fit the indentation used  
> by a particular text file.
>
>> Now I'm curious: What editor do other people use to edit their  
>> portfiles?
>
> Usually TextMate, but sometimes vim.
>
>> I'm just saying that you may like 2-space tabs, but I don't. If  
>> that's what we standardize on, I'll be unhappy. Someone else may  
>> like 3-space tabs, and they'll be unhappy unless we choose that.  
>> Why choose at all? Why not let the user choose with their editor's  
>> tab width setting? That's what it's for.
>
> Sure, that's what it's for, but it doesn't work. Go look around at  
> the current source. Sure, it's mostly tabs, but I routinely run  
> into spaces mixed among the tabs and it causes indentation problems.
>
> There's a reason that software projects often standardize their  
> coding style, including spacing conventions.

I agree that standardizing the spacing of a software project can be  
beneficial. I just want to encourage debate about the specific  
conventions you're proposing.


If we do decide on an indentation convention, then a pre-commit hook  
in the repository should probably enforce it. One point in favor of  
your suggestion is that it makes the hook script very easy: if the  
file contains any tab character at all, it does not conform to your  
conventions. Writing a hook to verify conformance to my suggestion  
would be more complicated, though I think not impossible.





More information about the macports-dev mailing list