开发者

Is there a function in elisp to apply a patch to a buffer?

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,开发者_Go百科 does anyone know?


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


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.


There is also M-x epatch that asks for a buffer containing a patch (Gnus mail for example) and then asks for a file/directory to patch. Very handy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜