unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: htbest2000 <htbest2000@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: function needed (to simplify diff output)
Date: Thu, 25 Dec 2008 18:33:25 -0800 (PST)	[thread overview]
Message-ID: <a1e889a0-a75d-4280-83f2-74ff340e7972@g39g2000pri.googlegroups.com> (raw)
In-Reply-To: mailman.3361.1230251889.26697.help-gnu-emacs@gnu.org

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	other threads:[~2008-12-26  2:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3361.1230251889.26697.help-gnu-emacs@gnu.org>
2008-12-26  2:33 ` htbest2000 [this message]
2008-12-26  4:27   ` function needed (to simplify diff output) Samuel Wales
2008-12-26  0:38 Samuel Wales

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1e889a0-a75d-4280-83f2-74ff340e7972@g39g2000pri.googlegroups.com \
    --to=htbest2000@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).