当初我有这个想法。但是仔细研究代码后发觉ediff只能支持特定格式的diff输出,而git diff
目前我没有找到可以以这样特定格式输出的选项。
以下是ediff的代码,注意其说明了对diff的-u
和-c
不支持
(defcustom ediff-diff-options
(if (memq system-type '(ms-dos windows-nt)) "--binary" "")
"Options to pass to `ediff-diff-program'.
If Unix diff is used as `ediff-diff-program',
then a useful option is `-w', to ignore space.
Options `-c', `-u', and `-i' are not allowed. Case sensitivity can be
toggled interactively using \\[ediff-toggle-ignore-case].
Do not remove the default options. If you need to change this variable, add new
options after the default ones.
This variable is not for customizing the look of the differences produced by
the command \\[ediff-show-diff-output]. Use the variable
`ediff-custom-diff-options' for that."
:set 'ediff-set-diff-options
:type 'string)
我使用ediff很有限,主要是用作mergetool的除了vimdiff外一个备选工具。所以ediff是否使用git对我效率影响不大。不过这个思想也没有完全浪费。
在我的工作流中比较两段相似代码是非常频繁的操作,所以我把git diff的命令和magit结合起来了,
见 emacs.d/init-misc.el at master · redguardtoo/emacs.d · GitHub 中的diff-region-compare-with-b