elisp 中是否有函数可以将补丁应用于缓冲区?

发布于 2024-09-14 23:02:57 字数 153 浏览 1 评论 0原文

我正在为审查工具开发 emacs 模式,并希望使用 ediff 来查看差异...问题是审查工具仅产生差异,而不是旧文件和新文件。我想将旧文件放入缓冲区并应用 diff,而不是复制文件,将 diff 作为子进程调用并将其加载到单独的缓冲区中。

不用自己写也能做到吗,有人知道吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

┈┾☆殇 2024-09-21 23:02:57

ediff-patch-buffer 可用于在 ediff 模式下修补缓冲区

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

怎樣才叫好 2024-09-21 23:02:57

根据您的工作流程,这可能适用也可能不适用。

尝试

M-x diff-mode

从中执行以下命令:

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

对我来说最直观的流程是'diff-ediff-patch

当您查看补丁时,运行Cc Ce,输入要补丁的文件名(例如file.to.patch)。然后,Emacs 将为您设置两个缓冲区 file.to.patch.origfile.to.patch 的 ediff,其中包含原始文件和修补版本。然后您可以像平常一样使用 ediff。在流程结束时,您将获得所需文件名的修补版本。

查看diff-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.

失而复得 2024-09-21 23:02:57

还有 Mx epatch 请求包含补丁的缓冲区(例如 Gnus 邮件),然后请求要修补的文件/目录。非常方便。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文