From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Doug Lewan Newsgroups: gmane.emacs.help Subject: Re Resyncing in ediff Date: Fri, 9 Mar 2012 14:57:48 +0000 Message-ID: <495248DFDEA08C469BBDED2D4AA6C6143653CD@DAKIYA1.pegasus.local> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1331304961 8775 80.91.229.3 (9 Mar 2012 14:56:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Mar 2012 14:56:01 +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 Mar 09 15:55:56 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 1S61EY-0006Tf-Sf for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Mar 2012 15:55:55 +0100 Original-Received: from localhost ([::1]:58076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S61EY-0005Rz-B0 for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Mar 2012 09:55:54 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S61EQ-0005Ri-2v for help-gnu-emacs@gnu.org; Fri, 09 Mar 2012 09:55:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S61EJ-0002nS-Rk for help-gnu-emacs@gnu.org; Fri, 09 Mar 2012 09:55:45 -0500 Original-Received: from mailhost.shubertorg.com ([207.246.209.200]:59139 helo=webmail.shubertorg.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S61EJ-0002hH-OA for help-gnu-emacs@gnu.org; Fri, 09 Mar 2012 09:55:39 -0500 Original-Received: from dakiya1.pegasus.local ([fe80::5ce2:4641:22cf:ff1f]) by DAKIYA1.pegasus.local ([fe80::5ce2:4641:22cf:ff1f%15]) with mapi id 14.01.0339.001; Fri, 9 Mar 2012 09:57:49 -0500 Thread-Topic: Re Resyncing in ediff Thread-Index: Acz+BK7hOPVEyeLrSYWmOWMsjzfwcA== Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.21.202] X-detected-operating-system: by eggs.gnu.org: Windows XP/2000 (RFC1323+, w+, tstamp-) X-Received-From: 207.246.209.200 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:83986 Archived-At: A few days ago I asked: > Is there a "nice" way to get ediff to resync? Drew Adams had a suggestion that was close to what I already do: Narrow fro= m point to end of buffer in both buffers of interest and ediff from there. = Thank you Drew. Since my current world is in C, I've written a little hack that [mostly] wo= rks for C. It works on a per function basis. It's not ideal, but it seems a= dequate. I freely invite anyone to turn it into something that's actually g= ood. ,Doug Here's the code: ;;; Commentary: ;; Sometimes ediff gets confused about which regions should correspond. ;; (This seems most common around blank or effectively blank lines.) ;; The problem really only arises from diffing long things (usually files). ;; This file contains code 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 those windows. ;; (4) M-x ediff-defun-at-point ;;; Code: ;;=20 ;; Dependencies ;; (require 'which-func) ;;=20 ;; Vars ;;=20 (defvar *ca-symbol-re* "\\sw\\(?:\\sw\\|\\s_\\|_\\)*" "RE to match a symbol in C.") (defvar *ca-type-re* (concat "\\(?:static\\|extern\\s-+\\)?" ;Maybe it's qualified *ca-symbol-re* "\\s-*" ;A type "\\**" ;Maybe it's a pointer ) "RE to match a type in a C declaration.") ;;=20 ;; Commands ;; (defun narrow-to-this-defun-in-both-windows () "Do that. CAVEAT: Different packages have different ideas about what function they're in at the beginning of a function declaration." (interactive) (let ((function-name (which-function))) (widen) (narrow-to-defun) (other-window 1) (widen) (goto-char (point-min)) (if (re-search-forward (format (concat "^" *ca-type-re* "\\s-+" "%s" "\= \s-*(") function-name (point-max) t)) (narrow-to-defun) (error "That function doesn't exist in the other window.")) (previous-window))) (defun ediff-defun-at-point () (interactive) (narrow-to-this-defun-in-both-windows) (ediff-buffers (window-buffer) (window-buffer (next-window))))