Jim Smith <3.141592six <at> gmail.com> writes:

> ...
> Basically, this means I need to
> invoke emacs from the command line with two file arguments and have
> emacs open an ediff session on those two files.  How do I do that?

Here is how I do this on so called "Windows" OSes.  Use at your own risk!

#!/usr/bin/env perl

# Time-stamp: <2003-08-22 13:57:12 Emilio C. Lopes>

use strict;
use warnings;

use Getopt::Long;
use File::Spec;

use vars qw( $emacs_client $ediff_fun $verbose $help $version );

$version="1.0";

{
  GetOptions(   'verbose|v'               => \$verbose
                ,'help|h'                  => \$help
            ) or usage(1);
  usage(0) if ($help);
  usage(1) if (@ARGV lt 2);


  $emacs_client = 'gnudoit';

  if (@ARGV == 2) {
    $ediff_fun = 'ediff-files';
  } elsif (@ARGV == 3) {
    $ediff_fun = 'ediff-files3';
  } else {
    die "Error: Expecting two or three arguments.\n"
  }

  ## Convert to absolute filenames; Translate backslashes to forward
  ## slashes; Quote the arguments.
  map { $_= File::Spec->rel2abs( $_ ) ; tr /\\/\// ; $_ = "\\\"$_\\\""} @ARGV;

  my $cmd="$emacs_client ($ediff_fun " . join (" ", @ARGV) . ") > " .
File::Spec->devnull();

  print "$cmd\n" if ($verbose);
  system "$cmd";
}

sub usage {
  print <<"EOF";
Ediff version $version: Frontend to Emacs' ediff package.

Usage:

  $0 file1 file2 [file3]
EOF

  exit $_[0];
}







_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to