help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: function needed (to simplify diff output)


From: htbest2000
Subject: Re: function needed (to simplify diff output)
Date: Thu, 25 Dec 2008 18:33:25 -0800 (PST)
User-agent: G2/1.0

apologize for my misunderstand, maybe diff-mode is what you need.

On Dec 26, 8:38 am, "Samuel Wales" <samolog...@gmail.com> wrote:
> I need a function and hope that somebody can help implement
> it.
>
> The purpose is to simplify diff -u for human viewing by
> eliminating trivial changes, including line moves.
>
> My algorithm is very simple:
>
>    1.  Process the text after the + or - with PROCESSOR.
>        Default: no processing.
>    2.  Of the + and - lines, show only those with unique
>        text.
>    3.  Replace lines like "@@ -1,3 +1,6 @@" with "...".
>
> The unique lines step detects line moves.  It will also
> eliminate duplicated lines, but that's OK.
>
> The processing step lets you specify what else is trivial
> besides line moves.  For example, if you don't need to see
> changes that involve commenting and uncommenting, you pass a
> function that deletes "^#".  This makes both sides of the
> diff uncommented.
>
> As another example, you can tell diff to ignore headline
> level changes in org mode by deleting "^\*+ ".  Your diffs
> will not show any changes in the headline structure, but
> will show other changes.  This is particularly useful.
>
> This command would be useful to assign to a key in a version
> control interface like egg.el.
>
> Example:
>
> Here is a diff hunk that you can call the function on.
>
> diff -u ?????
> --- aaaaa       2008-12-25 11:06:12.000000000 -0700
> +++ bbbbb       2008-12-25 11:06:11.000000000 -0700
> @@ -1,3 +1,6 @@
> +will be moved
> +will also be moved
> +this will be moved
>  the same
>  the same again 1
>  the same again 2
> @@ -5,12 +8,8 @@
>  the same again 4
>  the same again 5
>  still the same
> -only in aaaaa
> -will be deleted
> -will be commented
> -will be moved
> -will also be moved
> -this will be moved
> +only in bbbbb!
> +#will be commented
>  another identical line
>  another identical line
>
> The output will be the following if the preprocessor removes
> comment-start from every line that has it.  Note that the
> "will be commented" line and the moved lines are eliminated.
>
> diff -u ?????
> --- aaaaa       2008-12-25 11:06:12.000000000 -0700
> +++ bbbbb       2008-12-25 11:06:11.000000000 -0700
> ...
>  the same
>  the same again 1
>  the same again 2
> ...
>  the same again 4
>  the same again 5
>  still the same
> -only in aaaaa
> -will be deleted
> +only in bbbbb!
>  another identical line
>  another identical line
>
> Here is what I have so far:
>
> (defun fix-diff (&optional processor)
>   "When point is near a diff -u hunk, pop up a
> buffer with that hunk cleaned up for human viewing.
>
> By default, just eliminate evidence of line moves from the
> diff and replace lines like "@@ -1,3 +1,6 @@" with "...".
> (This also eliminates evidence of duplicated lines.)
>
> With PROCESSOR, first call processor on a temporary buffer
> that consists of the diff hunk with the first column (the
> one that has + and -) removed.
>
> For example, if the diff is of two versions of a shell
> script, and processor deletes all instances of the regexp
> "^#", then the cleaned-up diff output will not have any
> evidence of lines that are commented in one version and
> uncommented in the other."
>   (interactive)
>   ;;this is the part i can't do
>   )
>
> Thanks.
>
> --
> Myalgic encephalomyelitis denialists are knowingly causing further
> suffering and death by opposing biomedical research on this serious
> infectious disease.  Do you care about the 
> world?http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm


reply via email to

[Prev in Thread] Current Thread [Next in Thread]