From: Doug Lewan <dougl@shubertticketing.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re Resyncing in ediff
Date: Fri, 9 Mar 2012 14:57:48 +0000 [thread overview]
Message-ID: <495248DFDEA08C469BBDED2D4AA6C6143653CD@DAKIYA1.pegasus.local> (raw)
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 from 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] works for C. It works on a per function basis. It's not ideal, but it seems adequate. I freely invite anyone to turn it into something that's actually good.
,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:
;;
;; 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))))
reply other threads:[~2012-03-09 14:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=495248DFDEA08C469BBDED2D4AA6C6143653CD@DAKIYA1.pegasus.local \
--to=dougl@shubertticketing.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.