Only indent once for continuation lines when not lining up with

parentheses if the continuation indent is exactly half of the main
indent.  Indenting one contination indent for every level of
parentheses gives bad results in most cases and is not what is done
in about 90% of properly hand-formatted KNF code (sys/kern/*.c,
nvi/common/*.c).  The main advantage of the non-default KNF options
-nlp -ci4 is that continuation lines don't accidentally line up with
the next main indentation level or march to the right, and increasing
their indentation defeats this.

This behaviour change is limited to when the continuation indent is
exactly half of the main indent to avoid adding yet another option.
This commit is contained in:
Bruce Evans 2004-02-12 16:25:12 +00:00
parent 321fd46031
commit a55a608e71
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125736
2 changed files with 5 additions and 3 deletions

View File

@ -34,7 +34,7 @@
.\" @(#)indent.1 8.1 (Berkeley) 7/1/93
.\" $FreeBSD$
.\"
.Dd July 1, 1993
.Dd Februrary 13, 2004
.Dt INDENT 1
.Os
.Sh NAME
@ -196,7 +196,8 @@ lines will be indented that far from the beginning of the first line of the
statement. Parenthesized expressions have extra indentation added to
indicate the nesting, unless
.Fl \&lp
is in effect.
is in effect
or the contination indent is exactly half of the main indent.
.Fl \&ci
defaults to the same value as
.Fl i .

View File

@ -295,7 +295,8 @@ compute_code_target(void)
if (ps.paren_level)
if (!lineup_to_parens)
target_col += continuation_indent * ps.paren_level;
target_col += continuation_indent
* (2 * continuation_indent == ps.ind_size ? 1 : ps.paren_level);
else {
int w;
int t = paren_target;