bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature request: style consistency checking and mimicking an existing fi


From: Dan Hipschman
Subject: Feature request: style consistency checking and mimicking an existing file's style
Date: Sat, 7 Jun 2008 23:00:51 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

Hi all.

This is just a thought, and I know it would be a fair bit of work, which
I don't myself have time for right now, but what do you think of two new
options for GNU indent, --check and --mimic?  First I'll describe
--mimic.  It would read in a sample C file, figure out the style options
that would be used to produce such output, and then use those options
for the remaining (normal) input files.

For example, if foo.c is:

void foo(void)
{
  if (blah) {
    bonk();
  }
}

then 'indent --mimic foo.c' would be equivalent to
'indent -br -npcs -npsl'.  This makes it a lot easier to figure out the
correct options to indent since it's WYSIWYG.  Of course, the style that
is being mimicked needs to be consistent, which brings me to --check.
This would not output anything, but would check that the input has a
consistent style.  That is, there exists a single set of options that
could produce that style.  Implementing --check and --mimic boil down to
pretty much the same thing since to check for consistency we need to
remember what style we see in the file, and once we have that it is not
hard to use it for the output.

Of course, trying to understand arbitrary style could be difficult, if
it happens to fall outside the range of what indent can currently
produce yet still be consistent.  However in that case it could be fair
to simply report that there are no set of options to produce such
output, since we are not really losing any functionality over what we
currently have, but it would reduce headaches for people searching for a
nonexistent set of options.

Apologies if something like this has been proposed; I didn't go through
all the mailing list archives.

Dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]