Opened 6 years ago

Last modified 5 years ago

#787 new enhancement

Change source code to not use mixed spaces and tabs indentation

Reported by: German M. Bravo Owned by: Olly Betts
Priority: low Milestone:
Component: Other Version:
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description

There are a few drawbacks about using mixed spaces and tabs in the code, but most of all, there are two main reasons: First, it's very annoying as many editors/IDEs don't support it. Secondly, you have no visual clue if it's using spaces or tabs, so it gets very easy to mix-indent things, and harder to receive properly formatted patches and pull requests. I propose just using regular tabs instead.

Change History (2)

comment:1 by German M. Bravo, 6 years ago

Summary: Change source code to not use mixed spaces and tabsChange source code to not use mixed spaces and tabs indentation

comment:2 by Olly Betts, 5 years ago

Changing the rule for what the indent should be doesn't change the lack of a visible clue for what the indent is composed of, so I don't see changing this as a magic solution to solving people sending in mis-indented patches. If you require only tabs, people will send patches using spaces. If you require only spaces, you'll get patches using tabs.

Are there really very many editors/IDEs which are aimed at people writing code that don't support it? As a convention it's certainly far from being unique to the Xapian codebase.

This would also change almost every line of code, which is disruptive to branches and patches in progress. It's certainly not something to do in the middle of GSoC, and I think would need to be carefully timed relative to a release cycle to avoid a lot of extra pain with backporting changes to the stable release.

If we are going to change, I think it has to be to spaces-only. Using tabs for indent then gets you into disagreements about how wide a tab character should display, and requires users to configure their editor tab display width, which not everyone submitting patches will do. And it's not just editors - command line tools and online code and patch viewers all need to know the tab width, so git, more, less, and also trac, github, etc all need configuring. At least if the indent is spaces only, what you write is what somebody else sees, no matter how the tool they are using is configured.

Note: See TracTickets for help on using tickets.