* Re: syncing ediff
@ 2012-03-08 13:52 Douglas Lewan
0 siblings, 0 replies; only message in thread
From: Douglas Lewan @ 2012-03-08 13:52 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1968 bytes --]
Well, I couldn't find what I want, so here is a little hack that is adequate. It's definitely geared toward C code.
If anyone would like to make it good, I'd be very happy.
;;; 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:
;;
;; Dependencies
;;
(require 'which-func)
;;
;; Vars
;;
(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.")
;;
;; 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))))
,Doug
Douglas Lewan
(908) 720-7908
d_lewan2000@yahoo.com
[-- Attachment #2: Type: text/html, Size: 2749 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-08 13:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-08 13:52 syncing ediff Douglas Lewan
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).