Re: [PATCH] Teach git diff about Objective-C syntax
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 17, 2008, 20:44 UTC
- Message-ID
- <7vljxq4i5p.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <57518fd10809171214u3b5b3b96yc432c1c410faf8b4@mail.gmail.com>
"Jonathan del Strother" <maillist@steelskies.com> writes:
> Johannes already convinced me to do it as a separate patch. Andreas > seems to think that even if that change were in a separate patch, it > is pure nonsense. I think it's pretty subjective - I was just making > things consistent.
I think the discussion is getting into personal preference, but I do agree making things consistent is good.
Short and simple ones can stay the same as before, but I'd actually prefer doing ones on multiple lines like this:
{ "java",
/* Do not match these keywords */
"!^[ \t]*\\(catch\\|do\\|for\\|if\\|instanceof\\|"
"new\\|return\\|switch\\|throw\\|while\\)\n" /* possibly indented "foo bar(..." */
"^[ \t]*\\(\\([ \t]*[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}[ \t]*([^;]*\\)$"
}, { "objc",
/* Do not match with these C statements */
"!^[ \t]*\\(do\\|for\\|if\\|else\\|return\\|switch\\|while\\)\n"/* Objective-C methods "-(fo*&^)%*&%$^" or "+(bar&^)%$#$%" */ "^[ \t]*\\([-+][ \t]*([ \t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\)$"
"\\|" /* C functions "foo bar(..." */
"^[ \t]*\\(\\([ \t]*[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}[ \t]*([^;]*\\)$""\\|" /* Objective-C class/protocol definitions */ "^@\\(implementation\\|interface\\|protocol\\).*" },
That is:
- The pattern string indented to align with the pattern name; - Indent second and later lines of a single alternatives list that is split over multiple physical lines;
Are you sure the regexp you have for Objective-C methods quotes a dot "." correctly, by the way? It appears to match almost anything enclosed in a pair of parentheses, as long as you have two alpha after open paren.
Also I am not sure if you can do the pattern alternates the way you did. If you have this:
"...\\(A\\|B\\)$"
"\\|"
"...\\(C\\|D\\)$"A and B will be captured as $1 but wouldn't C or D captured as $2?