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
Stefan Beller <sbeller@google.com>
Date
Nov 20, 2017, 20:39 UTC
Message-ID
<CAGZ79kZxiEPE4LPEo-eb4Ta4bYXVr9xQM0dFeiJk9XXKU4AR+w@mail.gmail.com>
In-Reply-To
<9c3462e3-2d1d-05bc-9f7d-4bc93d32e7ff@web.de>
On Sat, Nov 18, 2017 at 10:08 AM, René Scharfe <l.s.r@web.de> wrote:
Show 7 quoted lines
> 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.

Previous: René ScharfeNext: René Scharfe
Message 13 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.