Function: magit-ediff-buffers

magit-ediff-buffers is a byte-compiled function defined in magit-ediff.el.

Signature

(magit-ediff-buffers A B &optional C SETUP QUIT FILE)

Documentation

Run Ediff on two or three buffers A, B and C.

If optional FILE is non-nil, then perform a merge. The merge result is put in FILE.

Neutralize the hooks ediff-quit-hook and ediff-quit-merge-hook because they usually feature functions that do not work for Magit. Instead run optional QUIT (if non-nil), magit-ediff--cleanup-buffers and magit-ediff-quit-hook, with no arguments.

Optional SETUP, if non-nil, is called with no arguments after Ediff is done setting up buffers.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-ediff.el
;;; Setup

(defun magit-ediff-buffers (a b &optional c setup quit file)
  "Run Ediff on two or three buffers A, B and C.

If optional FILE is non-nil, then perform a merge.  The merge result
is put in FILE.

Neutralize the hooks `ediff-quit-hook' and `ediff-quit-merge-hook'
because they usually feature functions that do not work for Magit.
Instead run optional QUIT (if non-nil), `magit-ediff--cleanup-buffers'
and `magit-ediff-quit-hook', with no arguments.

Optional SETUP, if non-nil, is called with no arguments after Ediff
is done setting up buffers."
  (magit-with-toplevel
    (ediff-buffers-internal
     a b c
     (let ((winconf (current-window-configuration)))
       (list (lambda ()
               (when setup
                 (funcall setup))
               (setq-local ediff-quit-merge-hook nil)
               (setq-local ediff-quit-hook nil)
               (when quit
                 (add-hook 'ediff-quit-hook quit nil t))
               (add-hook 'ediff-quit-hook #'magit-ediff--cleanup-buffers t t)
               (add-hook 'ediff-quit-hook
                         (lambda ()
                           (let ((magit-ediff-previous-winconf winconf))
                             (run-hooks 'magit-ediff-quit-hook)))
                         t t))))
     (pcase (list (and c t) (and file t))
       ('(nil nil) 'ediff-buffers)
       ('(nil t)   'ediff-merge-buffers)
       ('(t   nil) 'ediff-buffers3)
       ('(t   t)   'ediff-merge-buffers-with-ancestor))
     file)))