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

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?
Previous: Jonathan del StrotherNext: Jonathan del Strother
Message 12 of 23 in “Teach git diff about Objective-C syntax”
  1. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 16, 2008
  2. Miklos VajnaSep 16, 2008
  3. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 17, 2008
  4. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 17, 2008
  5. Johannes SchindelinSep 17, 2008
  6. Jonathan del StrotherSep 17, 2008
  7. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 17, 2008
  8. Andreas EricssonSep 17, 2008
  9. Jonathan del StrotherSep 17, 2008
  10. Miklos VajnaSep 17, 2008
  11. Jonathan del StrotherSep 17, 2008
  12. Junio C HamanoSep 17, 2008
  13. Jonathan del StrotherSep 17, 2008
  14. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 30, 2008
  15. Brandon CaseyOct 1, 2008
  16. xdiff-interface.c: strip newline (and cr) from line before pattern matchingBrandon Casey, Oct 1, 2008
  17. Johannes SchindelinOct 1, 2008
  18. Jonathan del StrotherOct 2, 2008
  19. Jonathan del StrotherOct 2, 2008
  20. Andreas EricssonSep 18, 2008
  21. Jonathan del StrotherSep 17, 2008
  22. Johannes SchindelinSep 17, 2008
  23. Jonathan del StrotherSep 17, 2008

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.