Re: [PATCH] xdiff: Show function names in hunk headers.
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:22
Mark Wooding [off-list ref] writes:
Junio C Hamano [off-list ref] wrote:quoted
GNU diff -p does "^[[:alpha:]$_]"; personally I think any line that does not begin with a whitespace is good enough.... The second suggestion is slightly refined, but a little more complicated. We ask for a line which starts /either/ with two non-whitespace characters, or with an alphanumeric. Why? Because text documents have a tendency to have headings of the form `7 Heading!' and I want to catch them.
Asciidoc?
. enumerated one
this is one item
. enumerated two
this is another item
I think I like option 2 best, as a nice compromise between stupidity and actually working. Opinions, anyone?
It's just a heuristic, so there are only two things we could
sensibly do. Either we keep it absolutely stupid to save our
code and sanity, or we give full configurability via -F regexp
to the end users.
I suspect feeping creaturism would eventually push us to go the
latter route, but for now I'd vote for doing exactly the same as
what default GNU does, by looking at the first letter without
using regexps. When we add regexps later, the users can
customize the pattern to match the languages they use, and we
might end up having to have a set of (file-suffix -> default
regexp) mappings, with full end user configurability via
.git/config -- gaaah but true X-<.
[diff]
functionline = "^\w" for .c
functionline = "^(?i)\s*(?:function|procedure)" for .f77
functionline = "^\(defun " for .el
...