From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Douglas Lewan Newsgroups: gmane.emacs.help Subject: Re: syncing ediff Date: Thu, 8 Mar 2012 05:52:08 -0800 (PST) Message-ID: <1331214728.14106.YahooMailNeo@web161505.mail.bf1.yahoo.com> Reply-To: Douglas Lewan NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="1679980782-814361580-1331214728=:14106" X-Trace: dough.gmane.org 1331229246 10391 80.91.229.3 (8 Mar 2012 17:54:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Mar 2012 17:54:06 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 08 18:54:03 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S5hXL-00038O-2v for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Mar 2012 18:53:59 +0100 Original-Received: from localhost ([::1]:54262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5hXK-0002fY-HP for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Mar 2012 12:53:58 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5dlQ-0004fw-Uj for help-gnu-emacs@gnu.org; Thu, 08 Mar 2012 08:52:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5dlK-0003cr-ED for help-gnu-emacs@gnu.org; Thu, 08 Mar 2012 08:52:16 -0500 Original-Received: from nm27-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.139]:45943) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1S5dlK-0003cO-57 for help-gnu-emacs@gnu.org; Thu, 08 Mar 2012 08:52:10 -0500 Original-Received: from [98.139.214.32] by nm27.bullet.mail.bf1.yahoo.com with NNFMP; 08 Mar 2012 13:52:08 -0000 Original-Received: from [98.139.212.224] by tm15.bullet.mail.bf1.yahoo.com with NNFMP; 08 Mar 2012 13:52:08 -0000 Original-Received: from [127.0.0.1] by omp1033.mail.bf1.yahoo.com with NNFMP; 08 Mar 2012 13:52:08 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 382562.80552.bm@omp1033.mail.bf1.yahoo.com Original-Received: (qmail 18928 invoked by uid 60001); 8 Mar 2012 13:52:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1331214728; bh=K6M4blofQ56UEAOnNcLejUZdQYjiU+znNT+jsg5qMZ8=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=XuDx32PoaiE/+c2wfh3AWivkIKNRsiVNnuoshHvQxTe5FDS7pDyzdIb6w8AStR/6HCD6PaqwlelgMu1k7Mi7OFhWiF4mkmuXzOdKhGWxnZDNPRlHviPBAhwEE+NVpGEFMSU5AtJjLFKELM7kgicpoXMvsmTpHdc0fFj+Fr33EsE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=2/nJgdl86t5CS8BTsDS52e5m3D5scZ5IgxT1EFVPXehmPWi7J5UMPuspcYrHvUmwCDqpm3SDqdBhR0CtG0frqInvgAtdbaAzsMwer8tQi2cleeblPqkBBFBkkzAtrCjwDBP1+k4n/AHgq4Mt1Vc9tgk3TRiFXvOov5qVrvI22XQ=; X-YMail-OSG: Wm.PrUcVM1lc8wGmocqjQt4NA2jEG0EZNZ4i_70o4QivMlj KDXO4StMGl.61wQ3hVWYoMRxBEHWd1iRdNpleATuu92NVRqE0b8cTFgPHLDj iqwfhNJFWiw1pMzufhIFJR_3iu3s.5oZHTSDRZt5peVzY9eyqyGdjNSj2Ogf 8WXMENxF2NyoUTuYGgQeD8MsGdJHRdMPw9lW_Gniyomryl7QMungeuTaeJ9B QXbbBje6Pj3bxK2SPN1GaMCv0qkwA_bLmvTZ72E0NoJxcXvaXUR_DU9dHhJv 5bRGOqmaPtSbQ_eV3J4rJZ4q6V6p8pcFBbyobH2StdyRaIawzPYnhiGEIGRg LxFLuh3AcsuILm1GmwStvL22.Fazk6DEqiXsxIcVx_aiSwsiR8h9ySb8Tg6H uGXEqyyGQiU4DVn1g7fp2o0kzdrUFtO4fLBtBsBbfdgZwcfAvJtChrV4Nvl3 ._uflVmjG6ovywjwXz3Sikkb5Cy68zA-- Original-Received: from [207.246.218.205] by web161505.mail.bf1.yahoo.com via HTTP; Thu, 08 Mar 2012 05:52:08 PST X-Mailer: YahooMailWebService/0.8.116.338427 Original-References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 98.139.213.139 X-Mailman-Approved-At: Thu, 08 Mar 2012 12:53:54 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83983 Archived-At: --1679980782-814361580-1331214728=:14106 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Well, I couldn't find what I want, so here is a little hack that is adequat= e.=A0It's definitely geared toward C code.=0A=0AIf anyone would like to mak= e it good, I'd be very happy.=0A=0A;;; Commentary:=0A=0A;; Sometimes ediff = gets confused about which regions should correspond.=0A;; (This seems most = common around blank or effectively blank lines.)=0A;; The problem really on= ly arises from diffing long things (usually files).=0A;; This file contains= code to help diff two things (usually files)=0A;; just one function at a t= ime.=0A=0A;;; Documentation:=0A=A0=0A;; To use this:=0A;; (1) Load this cod= e.=0A;; (2) Open the two files to be diffed in exactly 2 windows.=0A;; (3) = Put the point in the function of interest in one of those windows.=0A;; (4)= M-x ediff-defun-at-point=0A=A0=0A;;; Code:=0A=0A;; =0A;; Dependencies=0A;;= =0A(require 'which-func)=0A=0A=0A;; =0A;; Vars=0A;; =0A(defvar *ca-symbol-= re* "\\sw\\(?:\\sw\\|\\s_\\)*"=0A=A0 "RE to match a symbol in C.")=0A=0A(de= fvar *ca-type-re*=0A=A0 (concat=0A=A0=A0 "\\(?:static\\|extern\\s-+\\)?"=A0= ;Maybe it's qualified=0A=A0=A0 *ca-symbol-re* "\\s-*"=A0=A0;A type=0A=A0=A0= "\\**"=A0=A0=A0=A0;Maybe it's a pointer=0A=A0=A0 )=0A=A0 "RE to match a ty= pe in a C declaration.")=0A=0A;; =0A;; Commands=0A;; =0A(defun narrow-to-th= is-defun-in-both-windows ()=0A=A0 "Do that.=0ACAVEAT: Different packages ha= ve different ideas=0Aabout what function they're in at the beginning of a f= unction declaration."=0A=A0 (interactive)=0A=A0 (let ((function-name (which= -function)))=0A=A0=A0=A0 (widen)=0A=A0=A0=A0 (narrow-to-defun)=0A=A0=A0=A0 = (other-window 1)=0A=A0=A0=A0 (widen)=0A=A0=A0=A0 (goto-char (point-min))=0A= =A0=A0=A0 (if (re-search-forward (format (concat "^" *ca-type-re* "\\s-+" "= %s" "\\s-*(") function-name (point-max) t))=0A=A0(narrow-to-defun)=0A=A0=A0= =A0=A0=A0 (error "That function doesn't exist in the other window."))=0A=A0= =A0=A0 (previous-window)))=0A=0A(defun ediff-defun-at-point ()=0A=A0 (inter= active)=0A=A0 (narrow-to-this-defun-in-both-windows)=0A=A0 (ediff-buffers (= window-buffer)=0A=A0=A0 (window-buffer (next-window))))=0A=0A=0A,Doug=0ADou= glas Lewan=0A(908) 720-7908=0Ad_lewan2000@yahoo.com --1679980782-814361580-1331214728=:14106 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Well, I couldn't= find what I want, so here is a little hack that is adequate. It's def= initely geared toward C code.

If anyone would like to make it good, = I'd be very happy.

;;; Commentary:

;; Sometimes ediff gets co= nfused about which regions should correspond.
;; (This seems most common= around blank or effectively blank lines.)
;; The problem really only ar= ises from diffing long things (usually files).
;; This file contains cod= e to help diff two things (usually files)
;; just one function at a time= .

;;; Documentation:
 
;; To use this:
;= ; (1) Load this code.
;; (2) Open the two files to be diffed in exactly = 2 windows.
;; (3) Put the point in the function of interest in one of th= ose windows.
;; (4) M-x ediff-defun-at-point
 
;;; Code:

;;
;;= Dependencies
;;
(require 'which-func)


;;
;; Vars
= ;;
(defvar *ca-symbol-re* "\\sw\\(?:\\sw\\|\\s_\\)*"
  "RE to m= atch a symbol in C.")

(defvar *ca-type-re*
  (concat
&nbs= p;  "\\(?:static\\|extern\\s-+\\)?" ;Maybe it's qualified
&nbs= p;  *ca-symbol-re* "\\s-*"  ;A type
   "\\**"&n= bsp;   ;Maybe it's a pointer
   )
  "RE= to match a type in a C declaration.")

;;
;; Commands
;;
(defun narrow-to-this-defun-in-both-windows ()
  "Do that.CAVEAT: Different packages have different ideas
about what function th= ey're in at the beginning of a function declaration."
  (interactiv= e)
  (let ((function-name (which-function)))
    = (widen)
    (narrow-to-defun)
    (other-window 1)
  &n= bsp; (widen)
    (goto-char (point-min))
  &= nbsp; (if (re-search-forward (format (concat "^" *ca-type-re* "\\s-+" "%s" "\\s-*(") function-na= me (point-max) t))
 (narrow-to-defun)
    &n= bsp; (error "That function doesn't exist in the other window."))
 &= nbsp;  (previous-window)))
(defun ediff-defun-at-point (= )
  (interactive)
  (narrow-to-this-defun-in-both-windows)<= br>  (ediff-buffers (window-buffer)
   (window-buffer (ne= xt-window))))


,Doug
Douglas Lewan
(908) 720-7908d_lewan2000@yahoo.com
  
--1679980782-814361580-1331214728=:14106--