Re: [PATCH] Make words boundary for --color-words configurable
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 2, 2008, 03:54 UTC
- Message-ID
- <7vprs5xsvi.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <1209699564-2800-1-git-send-email-pkufranky@gmail.com>
Ping Yin <pkufranky@gmail.com> writes:
Show 17 quoted lines
> Previously --color-words only allow spaces as words boundary. However, > just space is not enough. For example, when i rename a function from > foo to bar, following example doesn't show as expected when using > --color-words. > > ------------------ > - if (foo(arg)) > + if (bar(arg)) > ------------------ > > It shows as "if <r>(foo(arg))</r><g>(foo(arg))</g>". Actually, it's the > best to show as "if (<r>foo</r><g>bar</g>(arg))". Here "r" and "g" > represent "red" and "green" separately. > > This patch introduces a configuration diff.wordsboundary to make > --color-words treat both spaces and characters in diff.wordsboundary as > boundary characters.
Just an idle thought.
I suspect a more natural definition of word boundary is between a run of word characters and a run of non-word characters. IOW, instead of saying " " and "(these other)" characters are boundary, you would say
if (foo(arg))
between f and space, open paren and f, second o and open paren, that open paren and a, ... are boundaries.
If you go that route, you would make the definition of "what is the set of word characters" configurable.