views:

65

answers:

2

I am working on an emacs mode for a review tool, and want to use ediff for viewing diffs... the problem is that the review tool only yields a diff, rather than old and new files. I'd like to put the old file in a buffer and apply a diff rather than copying the file, calling out to diff as a subprocess and loading it into a separate buffer.

Can this be done without writing it myself, does anyone know?

+4  A: 

Depending on what your workflow is this may or may not apply.

Try

M-x diff-mode

From which you can do commands like:

C-c C-a         diff-apply-hunk
C-c C-b         diff-refine-hunk
C-c C-c         diff-goto-source
C-c C-d         diff-unified->context
C-c C-e         diff-ediff-patch

The most intuitive flow for me is the 'diff-ediff-patch.

When you're looking at a patch, run C-c C-e, enter the file name to patch (say file.to.patch). Emacs will then set you up with an ediff of two buffers file.to.patch.orig and file.to.patch containing the original file and the patched version. You then use ediff as you would regularly. At the end of the flow, you have the patched version in the filename you want.

Check out the documentation for diff-mode.

Trey Jackson
+4  A: 

ediff-patch-buffer can be used to patch a buffer in ediff-mode

Jürgen Hötzel