When I issue M-x ediff-buffersI'd like ediff to create a new frame with the two buffers (and close this frame when done with the comparison). How can I customise ediff to do so?

I tried

(defun leo-ediff-before-setup ()
(add-hook 'ediff-before-setup-hook 'leo-ediff-before-setup)

but this sets the initial frame and a new frame up for the comparison.

  • make-frame just creates a frame displaying the current buffer. Is that what you want? Is the current buffer what you want in the new frame? – Drew Sep 10 '20 at 19:25
  • I would like ediff to use the new frame for its buffer-window arrangements plus I want ediff not to fiddle with the window layout in the old frame. Does this make sense? – halloleo Sep 10 '20 at 22:42
  • 1
    Read all of C-h v ediff-window-setup-function and go from there. (You can answer your own question if you get that working.) – phils Sep 11 '20 at 3:39
  • @phils thanks for chiming in! I've just tried to advise ediff-setup-windows-multiframe (which is called fromediff-window-setup-function) to make a frame before all the setup, but it seems to be already too late: the new frame is made, but ediff arranges the buffer still in the old frame. :-( – halloleo Sep 11 '20 at 5:02
  • I believe you'll want to write a new function which does exactly what you want it to do. – phils Sep 11 '20 at 5:02

The problem with the code in the question is that the newly made frame is not selected - and ediff operates on the selected frame. So, correct is:

(defun leo-ediff-before-setup ()
  (select-frame (make-frame)))
(add-hook 'ediff-before-setup-hook 'leo-ediff-before-setup)

Of course there's more customisation needed if the frame is to be closed at the end of the ediff session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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