2012-06-27

Using Emacs and ediff as an external diff tool

At work we have a program where one can configure an external diff tool to diff source code changes. Since I am used to work with ediff in Emacs I wanted to use it from that program as well. I ended up making a wrapper cmd file for it and thought I should share it in case someone else wants to solve the same problem.

Here is the script:


@echo off
REM c:\batfiles\ediff.cmd
set file1=%1
set file2=%2
REM Must convert the backslashes to slashes, otherwise they will be
REM interpreted as escape characters in the elisp strings. One can
REM also replace each backlslash with two backslashes to solve the
REM problem, but I like slashes better. Looks less messy.
set file1=%file1:\=/%
set file2=%file2:\=/%
%PATHTOEMACS%\bin\emacsclientw.exe -n -e "(ediff-files ""%file1%"" ""%file2%"")"

Replace %PATHTOEMACS% above with the real path to where you have installed Emacs. After that it's just a matter of selecting this cmd script as the diff tool.

Enjoy!

No comments: