unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* ediff from command line?
@ 2005-07-08 13:01 Jim Smith
  2005-07-08 13:26 ` N. Raghavendra
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jim Smith @ 2005-07-08 13:01 UTC (permalink / raw)



I would like to use emacs/ediff as an external diff program with
tortoise CVS on the windows platform.  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?  I
know I can specifiy a function to be evaluated on the command line,
but how do I pass the two file args to ediff-files?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: ediff from command line?
  2005-07-08 13:01 ediff from command line? Jim Smith
@ 2005-07-08 13:26 ` N. Raghavendra
  2005-07-08 16:11   ` Eli Zaretskii
  2005-07-08 13:47 ` Klaus Zeitler
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: N. Raghavendra @ 2005-07-08 13:26 UTC (permalink / raw)


At 2005-07-08T18:31:59+05:30, Jim Smith <3.141592six@gmail.com> wrote:

> I would like to use emacs/ediff as an external diff program with
> tortoise CVS on the windows platform.  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?  I
> know I can specifiy a function to be evaluated on the command line,
> but how do I pass the two file args to ediff-files?

FWIW, this works on Unix:

  emacs --eval '(ediff "/tmp/foo.el" "/tmp/bar.el")'

I don't know about Windows.

Raghavendra.

-- 
N. Raghavendra <raghu@mri.ernet.in> | See message headers for contact
Harish-Chandra Research Institute   | and OpenPGP details.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: ediff from command line?
  2005-07-08 13:01 ediff from command line? Jim Smith
  2005-07-08 13:26 ` N. Raghavendra
@ 2005-07-08 13:47 ` Klaus Zeitler
  2005-07-08 17:08 ` Emilio Lopes
  2005-07-08 17:32 ` Johan Bockgård
  3 siblings, 0 replies; 7+ messages in thread
From: Klaus Zeitler @ 2005-07-08 13:47 UTC (permalink / raw)


>>>>> "Jim" == Jim Smith <3.141592six@gmail.com> writes:
    Jim> 
    Jim> I would like to use emacs/ediff as an external diff program with
    Jim> tortoise CVS on the windows platform.  Basically, this means I need to
    Jim> invoke emacs from the command line with two file arguments and have
    Jim> emacs open an ediff session on those two files.


Here's an excerpt from my edif shell script. Note that since I don't want a
new emacs all the time, I use "gnuclient -batch" instead of emacs:

if [ -n "$3" ]
then
    gnuclient -batch -eval "(ediff-files3 \"$1\" \"$2\" \"$3\")"
else
    gnuclient -batch -eval "(ediff-files \"$1\" \"$2\")"
fi

HTH

Klaus

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
Ich bin dafuer, die Dinge soweit wie moeglich zu vereinfachen.
Aber nicht weiter.			    -- Albert Einstein

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: ediff from command line?
  2005-07-08 13:26 ` N. Raghavendra
@ 2005-07-08 16:11   ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2005-07-08 16:11 UTC (permalink / raw)


> From: "N. Raghavendra" <raghu@mri.ernet.in>
> Date: 08 Jul 2005 18:56:33 +0530
> 
> FWIW, this works on Unix:
> 
>   emacs --eval '(ediff "/tmp/foo.el" "/tmp/bar.el")'
> 
> I don't know about Windows.

Quoting with '...' won't work on Windows (unless one uses a port of
Unixy shell).  You need to quote with "..." (and backslash-escape the
inner quotes).  Otherwise, this command should work on Windows as
well.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: ediff from command line?
  2005-07-08 13:01 ediff from command line? Jim Smith
  2005-07-08 13:26 ` N. Raghavendra
  2005-07-08 13:47 ` Klaus Zeitler
@ 2005-07-08 17:08 ` Emilio Lopes
  2005-07-08 17:32 ` Johan Bockgård
  3 siblings, 0 replies; 7+ messages in thread
From: Emilio Lopes @ 2005-07-08 17:08 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: ediff from command line?
  2005-07-08 13:01 ediff from command line? Jim Smith
                   ` (2 preceding siblings ...)
  2005-07-08 17:08 ` Emilio Lopes
@ 2005-07-08 17:32 ` Johan Bockgård
  2005-07-11 10:22   ` Jim Smith
  3 siblings, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2005-07-08 17:32 UTC (permalink / raw)


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

> I would like to use emacs/ediff as an external diff program with
> tortoise CVS on the windows platform. 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.

(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

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: ediff from command line?
  2005-07-08 17:32 ` Johan Bockgård
@ 2005-07-11 10:22   ` Jim Smith
  0 siblings, 0 replies; 7+ messages in thread
From: Jim Smith @ 2005-07-11 10:22 UTC (permalink / raw)


bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

> Jim Smith <3.141592six@gmail.com> writes:
>
>> I would like to use emacs/ediff as an external diff program with
>> tortoise CVS on the windows platform. 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.
>
> (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
>

Thanks for all the replys.  I won't be able to try them out until next
week, but so far It looks like this is exactly what I was looking for.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-07-11 10:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-08 13:01 ediff from command line? Jim Smith
2005-07-08 13:26 ` N. Raghavendra
2005-07-08 16:11   ` Eli Zaretskii
2005-07-08 13:47 ` Klaus Zeitler
2005-07-08 17:08 ` Emilio Lopes
2005-07-08 17:32 ` Johan Bockgård
2005-07-11 10:22   ` Jim Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).