;;; syd-ediff.el -*- lexical-binding: t; -*-

(require 'syd-prelude)

(with-eval-after-load 'ediff
  (setq ediff-diff-options "-w" ; Ignore whitespace
        ediff-window-setup-function #'ediff-setup-windows-plain)
  (defvar syd--ediff-saved-wconf nil)

  ;; Restore window config after quitting Ediff.
  (syd-add-hook 'ediff-before-setup-hook
    (defun syd--ediff-save-wconf-h ()
      (setq syd--ediff-saved-wconf (current-window-configuration))))
  (syd-add-hook '(ediff-quit-hook ediff-suspend-hook)
    (defun syd--ediff-restore-wconf-h ()
      (when (window-configuration-p syd--ediff-saved-wconf)
        (set-window-configuration syd--ediff-saved-wconf)))))

(provide 'syd-ediff)
