Re: [PATCH 6/6] grep: show non-empty lines before functions with -W
- From
Stefan Beller <sbeller@google.com>
- Date
- Nov 21, 2017, 23:35 UTC
- Message-ID
- <CAGZ79kbL-oXPTgB+tzAUEVJ7K=F44883bW1u93UYgp4kp8r=fA@mail.gmail.com>
- In-Reply-To
- <55af5442-c22a-342e-edbd-02a776228345@web.de>
On Mon, Nov 20, 2017 at 2:07 PM, René Scharfe <l.s.r@web.de> wrote:
Show 27 quoted lines
> Am 20.11.2017 um 21:39 schrieb Stefan Beller:
>> On Sat, Nov 18, 2017 at 10:08 AM, René Scharfe <l.s.r@web.de> wrote:
>>> Non-empty lines before a function definition are most likely comments
>>> for that function and thus relevant. Include them in function context.
>>>
>>> Such a non-empty line might also belong to the preceding function if
>>> there is no separating blank line. Stop extending the context upwards
>>> also at the next function line to make sure only one extra function body
>>> is shown at most.
>>
>> Can we add another heuristic, that checks for common function body ends, e.g.
>> if the preceding line contains '}' but is not commented (the line doesn't
>> contain '*/' '//', '#'), we have a strong hint that it is a function, not an
>> additional comment.
>
> C comments containing "}" as part of the text would only be shown
> partially, e.g:
>
> /*
> * Not shown because of the curly closing brace in ${PATH}.
> * Shown.
> */
>
> Two examples in git's repo are in refs.h and sha1-lookup.c.
>
> Before diving deeper: Is it worth it? Does the heuristic in this series
> produce excessive context often? Enough to be annoying?We'll find out... I was just spurting out my thought of the day. Sorry for the noise.