1
0
Fork 0

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
This commit is contained in:
Tom Willemse 2020-11-06 16:42:58 -08:00
parent db42ad1a17
commit 48d513550d

View file

@ -47,6 +47,22 @@
(`(,fileA ,fileB ,fileC) (ediff-files3 fileA fileB fileC)) (`(,fileA ,fileB ,fileC) (ediff-files3 fileA fileB fileC))
(_ (error "Invalid number of arguments, need either 2 or 3 files")))) (_ (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-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally) (setq ediff-split-window-function 'split-window-horizontally)