Re: [PATCH] Per-path attribute based hunk header selection.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



しらいしななこ  <nanako3@xxxxxxxxxxxxxx> writes:

> I would love to see "diff=tex" attribute to work on my manuscripts, but I
> do not write C and do not understand the long length of backslashes very
> well.  I guessed in the source file a backslash needs to be doubled, and
> what I want to match is "\section{", "\subsection{", and "\subsubsection{"
> at the beginning of lines, and attempted to do it like the patch at the
> end.

Heh, I do not speak TeX very well, so we are even ;-)

> It does not work well, however.  It shows only part of lines.
>
> 	@@ -8,7 +8,8 @@ \section{
> 	@@ -224,7 +225,7 @@ sub
> 	@@ -240,7 +241,7 @@ subsub
>
> I have no idea what am I doing wrong (truthfully, I do not know what I am
> doing, period).
>
> diff --git a/diff.c b/diff.c
> index 04e7e91..57f91b0 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1226,6 +1226,8 @@ static const char *diff_hunk_header_regexp(struct diff_filespec *one)
>  			"^[ 	]*\\(\\([ 	]*"
>  			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
>  			"[ 	]*([^;]*$\\)";
> +	if (!strcmp(ident, "tex"))
> +		return "^\\\\\\(sub\\)*section{";
>  
>  	return NULL;
>  }

It's getting late so I won't be testing this myself tonight, but
I think

	return "^\\(\\\\\\(sub\\)*section{.*\\)$";

would do the job.

HOWEVER.

Johannes, it strikes me that it is very odd having to add ".*$"
at the end and to surround the whole thing in a parentheses.
Shouldn't the ff_regexp() grabber simply pick the whole line?
After all, that is what GNU "diff -p -F RE" does.

Also this makes me realize that not all contents in the world
are not programming language source files, and "funcname" is
a misnomer.  For this one, however, we _can_ blame GNU diff, as
they call this --show-function-line option ;-)
 

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux