When using ediff, I find it annoying that when I use a or b to copy from one buffer to another, the region remains highlighted despite the fact that the two files now match in those regions. I don't know if I'm the only one who expects the highlighting to always reflect the actual differences between the files or what.

I can use ! to call ediff-update-diffs after each such call, but that doesn't seem like the right solution because it updates the diff of the entire buffer, not just the region that was just pasted. I thought about

  • remapping a and b to lambdas that call ediff-copy-B-to-A and then ediff-update-diffs. One problem with that is that if I make some edits by hand, the highlighting will not be updated. Still the best thing I have thought of, though.
  • Calling ediff-update-diffs from a hook that runs any time the buffer is changed, but it seems like that would call it after every keystroke.

What's the best practice that ensures the highlighting in ediff always reflects the actual differences between the files, while retaining performance?

  • If you set ediff-auto-refine to 'on the vanishing of all fine changes indicates the equal regions. If the diff region is removed all following diff indexes must be corrected. So, ediff-update-diffs is maybe the best shoot.
    – Tobias
    Commented Sep 19, 2022 at 10:12
  • On rare occasions I change my mind after selecting an option, and it would be super annoying in those cases if the conflict in question was no longer interactive. If you're going to do this I suggest that you make it something which can be toggled on and off.
    – phils
    Commented Feb 12 at 3:53

1 Answer 1


Here is what I'm using at the moment to update the regions after each copy. It doesn't update the diffs if I edit by hand, but it's a step in the right direction.

(defun ediff-copy-A-to-B-and-update(arg)
  (interactive "P")
  (ediff-diff-to-diff arg "ab")
(defun ediff-copy-B-to-A-and-update(arg)
  (interactive "P")
  (ediff-diff-to-diff arg "ba")
(defun add-update-to-ediff-mode ()
  (define-key ediff-mode-map "a" 'ediff-copy-A-to-B-and-update)
  (define-key ediff-mode-map "b" 'ediff-copy-B-to-A-and-update))
(add-hook 'ediff-keymap-setup-hook 'add-update-to-ediff-mode)

I'm kind of new to elisp so I'd appreciate any feedback on it.

I was trying to save the number of the current diff and go to it after the change because right now the behavior is a little spotty in terms of whether it moves to the next diff or not after the change. Sadly, the solutions I have attempted only made the behavior yet more erratic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.