From 48d513550d16f5ab49e56eb4bdccd1d9cdf67b44 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 6 Nov 2020 16:42:58 -0800 Subject: Add support to call ediff through emacsclient This way Emacs can be used in Perforce, for example, as the diff program: Location: C:/msys64/mingw64/bin/emacsclientw.exe Arguments: diff %1 %2 --- oni-ediff.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'oni-ediff.el') diff --git a/oni-ediff.el b/oni-ediff.el index 6d87d27..b18e625 100644 --- a/oni-ediff.el +++ b/oni-ediff.el @@ -47,6 +47,22 @@ (`(,fileA ,fileB ,fileC) (ediff-files3 fileA fileB fileC)) (_ (error "Invalid number of arguments, need either 2 or 3 files")))) +;;;###autoload +(defun oni-ediff-server (fun files proc &optional nowait) + (pcase files + ((and `((,fileB) (,fileA) (,command)) + (guard (string= (file-name-nondirectory command) "diff"))) + (select-frame-set-input-focus (selected-frame)) + (ediff-files (expand-file-name fileA) + (expand-file-name fileB)) + nil) + (_ + (message "Got args: \"%s\"" (list files proc nowait)) + (funcall fun files proc nowait)))) + +;;;###autoload +(advice-add 'server-visit-files :around #'oni-ediff-server) + (setq ediff-window-setup-function 'ediff-setup-windows-plain) (setq ediff-split-window-function 'split-window-horizontally) -- cgit v1.2.3-54-g00ecf