C-x s 使用diff
来显示更改。我该如何使用ediff
?
答案 0 :(得分:3)
我可以看到这样做的几种方法。第一种是用修改后的代码替换save-some-buffers-action-alist
变量,这更简单。第二个是建议save-some-buffers
并重新定义这些操作调用的函数,但这有点棘手。
我尝试了两种方式,我认为这是最佳选择:
;; Use ediff instead of diff in `save-some-buffers'
(eval-after-load "files"
'(progn
(setcdr (assq ?d save-some-buffers-action-alist)
`(,(lambda (buf)
(if (null (buffer-file-name buf))
(message "Not applicable: no file")
(add-hook 'ediff-after-quit-hook-internal
'my-save-some-buffers-with-ediff-quit t)
(save-excursion
(set-buffer buf)
(let ((enable-recursive-minibuffers t))
(ediff-current-file)
(recursive-edit))))
;; Return nil to ask about BUF again.
nil)
,(purecopy "view changes in this buffer")))
(defun my-save-some-buffers-with-ediff-quit ()
"Remove ourselves from the ediff quit hook, and
return to the save-some-buffers minibuffer prompt."
(remove-hook 'ediff-after-quit-hook-internal
'my-save-some-buffers-with-ediff-quit)
(exit-recursive-edit))))
我尝试使用建议是有缺陷的(它打破了 Cr 行为也会调用view-buffer
,这导致我重新考虑使用建议用于此目的),但FWIW:
(defadvice save-some-buffers (around my-save-some-buffers-with-ediff)
"Use ediff instead of diff."
(require 'cl)
(flet ((view-buffer (&rest) nil)
(diff-buffer-with-file
(buf)
(add-hook 'ediff-after-quit-hook-internal
'my-save-some-buffers-with-ediff-quit t)
(save-excursion
(set-buffer buf)
(ediff-current-file))))
(let ((enable-recursive-minibuffers t))
ad-do-it)))
(ad-activate 'save-some-buffers)
(defun my-save-some-buffers-with-ediff-quit ()
"Remove ourselves from the ediff quit hook, and
return to the save-some-buffers minibuffer prompt."
(remove-hook 'ediff-after-quit-hook-internal
'my-save-some-buffers-with-ediff-quit)
(exit-recursive-edit))
答案 1 :(得分:1)
变量diff-command
是可自定义的,文档说。但是,请记住它指向外部程序,而不是elisp函数。 ediff
是ediff.el中的elisp函数。您可能需要将diff.el编辑为(require 'ediff)
然后在diff.el中进行调整,以确定您没有其他任何内容。