help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ediff from command line?


From: Emilio Lopes
Subject: Re: ediff from command line?
Date: Fri, 8 Jul 2005 17:08:36 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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];
}









reply via email to

[Prev in Thread] Current Thread [Next in Thread]