Other Help with emacs command line

balanga

Son of Beastie

Reaction score: 227
Messages: 4,067

I'm trying to start up emacs and run the ediff-files command to compare two files passed via the command line, but haven't figured it out yet.

I think this must be somewhere close:-
emacs -nw --eval "(ediff-files)" $1 $2

Can anyone help me get this working?
 

NapoleonWils0n

Well-Known Member

Reaction score: 151
Messages: 275

Have you tried using Meld as an alternative

Meld is a visual diff and merge tool targeted at developers.
Meld helps you compare files, directories, and version controlled projects.
 

jb_fvwm2

Daemon

Reaction score: 217
Messages: 1,852

Code:
sort file1.txt file1.txt file2.txt | uniq -u
or some variant may suffice in some use cases.
 

Bobi B.

Well-Known Member

Reaction score: 198
Messages: 418

Try this: emacs -nw --eval '(ediff-files "path/to/file1" "path/to/file2")'.
 
OP
B

balanga

Son of Beastie

Reaction score: 227
Messages: 4,067

Try this: emacs -nw --eval '(ediff-files "path/to/file1" "path/to/file2")'.


Thanks. That works great but I'd like to pass the filenames to the command as parameters.

Just using $1 $2 doesn't work. Don't know if the $ needs to be escaped...
 

Bobi B.

Well-Known Member

Reaction score: 198
Messages: 418

There you go:
Bash:
#!/bin/sh
if [ $# -eq 2 ] ; then
    cmd=\(ediff-files\ \""$1"\"\ \""$2"\"\)
    emacs -nw --eval "${cmd}"
else
    echo usage: idiff file1 file2
fi

PS: Not bulletproof, tho :)
 
OP
B

balanga

Son of Beastie

Reaction score: 227
Messages: 4,067

Thanks, that works, I'm just a little surprised that it is so difficult escape the $ signs...
 
Top