bug-indent
[Top][All Lists]
Advanced

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

Re: Feature request: style consistency checking and mimicking an existin


From: Dan Hipschman
Subject: Re: Feature request: style consistency checking and mimicking an existing file's style
Date: Mon, 9 Jun 2008 17:05:56 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

On Mon, Jun 09, 2008 at 08:13:11PM +0200, david ingamells wrote:
> >  
> It looks to me like you're proposing something larger than indent itself!
> I can't see anyone taking up the challenge, however if they do I'd suggest
> that they write an independent program to generate the indent command line
> from a given source file.

I don't think it would be that hard.  I haven't looked at the indent
source, but it seems it must include a C parser that is at least complex
enough to understand what a function looks like, where a block of code
that needs to be indented starts and ends, and things like that.  All
this new feature would require would be to keep track of whitespace in
the input as well, which indent already seems to do a little bit of, at
least WRT newlines.

For example, when indent comes across, say, a comment in the input, it
must be smart enough to know how much to indent it based on the value of
the -c option.  All it would need to do to fill this value in itself is
see how far it is already indented in the mimicked input.  Replace "look
up value of -c and output indented comment" with "check consistency with
existing value of -c if any, and set value of -c."

I haven't gone through every option in the man page and thought about
how to implement it, but skimming through them it seems they mostly fit
the approach above.  It would be a bit of grunt work, but not hard, and
certainly not doubling the size of indent.

This would require far too much duplication to justify a separate
program, and would also require maintenance to be kept up-to-date with
indent.




reply via email to

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