0

I would like to launch emacs to ediff either files or directories. For example, I'd like something like:

emacs -f ediff-files file1 file2

But when I do this, it doesn't take file1 and file2 as the two files to diff. Rather, emacs prompts me for the files to difference.

Does anyone know how to do this in one command line?

1 Answer 1

0

Given the command line option description from Emacs manual:

‘-f function’ ‘--funcall=function’ Call Lisp function function. If it is an interactive function (a command), it reads the arguments interactively just as if you had called the same function with a key sequence. Otherwise, it calls the function with no arguments.

this is expected. You can try using -e instead:

‘--eval=expression’ ‘--execute=expression’ Evaluate Lisp expression expression.

You'll probably need something like this:

emacs --eval '(ediff-files "file1" "file2")'

Check this for something that looks like a ready-made script you can use:

An alternative is shown on the Ediff mode manual page:

which adds a command line switch -diff:

(defun command-line-diff (switch)
  (let ((file1 (pop command-line-args-left))
        (file2 (pop command-line-args-left)))
    (ediff file1 file2)))

(add-to-list 'command-switch-alist '("diff" . command-line-diff))

;; Usage: emacs -diff file1 file2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .