git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 6/6] grep: show non-empty lines before functions with -W

From
René Scharfe <l.s.r@web.de>
Date
Nov 20, 2017, 22:07 UTC
Message-ID
<55af5442-c22a-342e-edbd-02a776228345@web.de>
In-Reply-To
<CAGZ79kZxiEPE4LPEo-eb4Ta4bYXVr9xQM0dFeiJk9XXKU4AR+w@mail.gmail.com>
Am 20.11.2017 um 21:39 schrieb Stefan Beller:
Show 13 quoted lines
> 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?

Thanks, René

Previous: Stefan BellerNext: Stefan Beller
Message 14 of 15 in “show non-empty lines before functions with diff/grep -W”
  1. 0/6 show non-empty lines before functions with diff/grep -WRené Scharfe, Nov 18, 2017
  2. 1/6 t4051: add test for comments preceding function linesRené Scharfe, Nov 18, 2017
  3. Eric SunshineNov 19, 2017
  4. René ScharfeNov 19, 2017
  5. Junio C HamanoNov 20, 2017
  6. René ScharfeNov 20, 2017
  7. Junio C HamanoNov 21, 2017
  8. 3/6 xdiff: show non-empty lines before functions with -WRené Scharfe, Nov 18, 2017
  9. 5/6 grep: update boundary variable for pre-contextRené Scharfe, Nov 18, 2017
  10. 4/6 t7810: improve check of -W with user-defined function linesRené Scharfe, Nov 18, 2017
  11. 2/6 xdiff: factor out is_func_rec()René Scharfe, Nov 18, 2017
  12. 6/6 grep: show non-empty lines before functions with -WRené Scharfe, Nov 18, 2017
  13. Stefan BellerNov 20, 2017
  14. René ScharfeNov 20, 2017
  15. Stefan BellerNov 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.