From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: htbest2000 Newsgroups: gmane.emacs.help Subject: Re: function needed (to simplify diff output) Date: Thu, 25 Dec 2008 18:33:25 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1230259253 28775 80.91.229.12 (26 Dec 2008 02:40:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Dec 2008 02:40:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 26 03:42:00 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LG2eE-0005Hx-KC for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Dec 2008 03:41:58 +0100 Original-Received: from localhost ([127.0.0.1]:44131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LG2d1-0000Gx-JP for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Dec 2008 21:40:43 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!g39g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 114 Original-NNTP-Posting-Host: 220.191.185.66 Original-X-Trace: posting.google.com 1230258806 12325 127.0.0.1 (26 Dec 2008 02:33:26 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 26 Dec 2008 02:33:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g39g2000pri.googlegroups.com; posting-host=220.191.185.66; posting-account=vjPv_woAAACRbHlAUee1GeafN1KLQK6P User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:165598 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60930 Archived-At: apologize for my misunderstand, maybe diff-mode is what you need. On Dec 26, 8:38=A0am, "Samuel Wales" 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: > > =A0 =A01. =A0Process the text after the + or - with PROCESSOR. > =A0 =A0 =A0 =A0Default: no processing. > =A0 =A02. =A0Of the + and - lines, show only those with unique > =A0 =A0 =A0 =A0text. > =A0 =A03. =A0Replace lines like "@@ -1,3 +1,6 @@" with "...". > > The unique lines step detects line moves. =A0It will also > eliminate duplicated lines, but that's OK. > > The processing step lets you specify what else is trivial > besides line moves. =A0For example, if you don't need to see > changes that involve commenting and uncommenting, you pass a > function that deletes "^#". =A0This makes both sides of the > diff uncommented. > > As another example, you can tell diff to ignore headline > level changes in org mode by deleting "^\*+ ". =A0Your diffs > will not show any changes in the headline structure, but > will show other changes. =A0This 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 =A0 =A0 =A0 2008-12-25 11:06:12.000000000 -0700 > +++ bbbbb =A0 =A0 =A0 2008-12-25 11:06:11.000000000 -0700 > @@ -1,3 +1,6 @@ > +will be moved > +will also be moved > +this will be moved > =A0the same > =A0the same again 1 > =A0the same again 2 > @@ -5,12 +8,8 @@ > =A0the same again 4 > =A0the same again 5 > =A0still 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 > =A0another identical line > =A0another identical line > > The output will be the following if the preprocessor removes > comment-start from every line that has it. =A0Note that the > "will be commented" line and the moved lines are eliminated. > > diff -u ????? > --- aaaaa =A0 =A0 =A0 2008-12-25 11:06:12.000000000 -0700 > +++ bbbbb =A0 =A0 =A0 2008-12-25 11:06:11.000000000 -0700 > ... > =A0the same > =A0the same again 1 > =A0the same again 2 > ... > =A0the same again 4 > =A0the same again 5 > =A0still the same > -only in aaaaa > -will be deleted > +only in bbbbb! > =A0another identical line > =A0another identical line > > Here is what I have so far: > > (defun fix-diff (&optional processor) > =A0 "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." > =A0 (interactive) > =A0 ;;this is the part i can't do > =A0 ) > > Thanks. > > -- > Myalgic encephalomyelitis denialists are knowingly causing further > suffering and death by opposing biomedical research on this serious > infectious disease. =A0Do you care about the world?http://www.meactionuk.= org.uk/What_Is_ME_What_Is_CFS.htm