From: Josh Triplett <josh@freedesktop.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Brian Downing <bdowning@lavos.net>,
dsymonds@gmail.com
Subject: Re: [PATCH 2/2] git-diff: complain about >=8 consecutive spaces in initial indent
Date: Tue, 13 Nov 2007 15:37:54 -0800 [thread overview]
Message-ID: <473A3552.3060907@freedesktop.org> (raw)
In-Reply-To: <7vr6j95c84.fsf@gitster.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]
[CCing David Symonds, because the same comment also applies to his
patches.]
Junio C Hamano wrote:
> This introduces a new whitespace error type, "indent-with-non-tab".
> The error is about starting a line with 8 or more SP, instead of
> indenting it with a HT.
>
> This is not enabled by default, as some projects employ an
> indenting policy to use only SPs and no HTs.
>
> The kernel folks and git contributors may want to enable this
> detection with:
>
> [core]
> whitespace = indent-with-non-tab
This seems somewhat broken, whether a project uses tabs for
indentation or not. Lines can still legitimately start with many
spaces. Tab-based indentation should only use tabs to line up with
other tabs, not with characters. (Unfortunately most editors get this
wrong when indenting with tabs. I use spaces, not because I
ideologically oppose tabs, but because I can't get any editor I want
to use to do the right thing with tabs.)
My standard test case for this:
fprintf("some very long string",
arguments);
Type the first line, and press enter. A good editor should indent to
the open parenthesis. However, it should not use a tab, because it
needs to match up with the length of "fprintf(". All the editors I
know of use a tab; they just blindly replace a tab-width worth of
spaces with a tab in initial indentation.
That statement would normally appear indented in a function, so the
continuation line should have tabs up to the indentation level of the
fprintf, and then 8 spaces. An example more likely to appear at the
start of the line, where this indent-with-non-tab heuristic would flag
it:
#define macro(arg1, arg2) macro_content \
more_macro_content
Another example:
some_type function_name(arg1, arg2, argred, argblue,
argmore, argless)
Again, the indentation should use spaces if it wants to line up after
the open parenthesis, whether the project uses tabs or spaces for indentation.
(Those examples may or may not match all coding styles; some just
indent the continuation lines by a fixed number of tabs, and also
treat the first line as a continuation line to keep the indentation
consistent. Just presenting them as examples.)
- Josh Triplett
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
next prev parent reply other threads:[~2007-11-13 23:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-02 7:34 [PATCH 1/2] War on whitespace: first, a bit of retreat Junio C Hamano
2007-11-02 7:38 ` [PATCH 2/2] git-diff: complain about >=8 consecutive spaces in initial indent Junio C Hamano
2007-11-13 23:37 ` Josh Triplett [this message]
2007-11-14 0:46 ` Junio C Hamano
2007-11-02 10:14 ` [PATCH 1/2] War on whitespace: first, a bit of retreat David Symonds
2007-11-02 10:45 ` Andreas Ericsson
2007-11-02 11:50 ` David Symonds
2007-11-02 12:25 ` Jakub Narebski
2007-11-02 12:53 ` David Symonds
2007-11-02 13:26 ` David Symonds
2007-11-02 17:45 ` J. Bruce Fields
2007-11-03 2:45 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=473A3552.3060907@freedesktop.org \
--to=josh@freedesktop.org \
--cc=bdowning@lavos.net \
--cc=dsymonds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).