Is there a way to start emacs in ediff mode and pass along with it
through the command line, the two files I want to ediff? If the
command line is unwieldy, I can always wrap it up in a script.
thanks.
emacs --eval '(ediff-files "file_1" "file_2")'
--
Kevin Rodgers
Denver, Colorado, USA
Thanks. It works from the command line, but when I put it in a shell,
it doesn't seem to work. Do you know what is going on?
#!/bin/bash
fileA=$1
fileB=$2
if [[ -z "$fileA" && -z "$fileB" ]]
then
echo "Need two files to ediff."
exit 1
fi
evalArg="'(ediff-files \"$fileA\" \"$fileB\" )'"
echo emacs --geometry 150x80 --eval $evalArg
emacs --geometry 150x80 --eval $evalArg
exit 0
It is a bit more difficult on Windows:
@rem Put this file (ediff.cmd) in your PATH.
@rem (Created by Setup Helper at Tue Apr 03 20:48:56 2007)
@rem -----------------------------
@rem Starts Emacs ediff (through gnuserv) from command line.
@rem Takes the two file to compare as parameters.
@setlocal
@set f1=%1
@set f2=%2
@set f1=%f1:\=/%
@set f2=%f2:\=/%
@set emacs_cd=%CD:\=/%
@set emacs_client="c:\emacs\p\070403\emacs\bin\emacsclient.exe"
@%emacs_client% -n
@%emacs_client% -e "(setq default-directory \"%emacs_cd%\")"
@%emacs_client% -n -e "(ediff-files \"%f1%\" \"%f2%\")"
echo emacs --geometry 150x80 --eval $evalArg
this command displays the "emacs ..." command,
but does not invoke it. try removing the "echo".
thi
[...]
> Thanks. It works from the command line, but when I put it in a shell,
> it doesn't seem to work. Do you know what is going on?
>
> #!/bin/bash
>
> fileA=$1
> fileB=$2
>
> if [[ -z "$fileA" && -z "$fileB" ]]
> then
> echo "Need two files to ediff."
> exit 1
> fi
>
>
>
> evalArg="'(ediff-files \"$fileA\" \"$fileB\" )'"
>
> echo emacs --geometry 150x80 --eval $evalArg
>
> emacs --geometry 150x80 --eval $evalArg
>
> exit 0
Try this:
emacs --geometry 150x80 --eval "(ediff-files \"$fileA\" \"$fileB\")"
HTH,
Rob
And who doubts that, if we dreamt in company, and the dreams chanced to
agree, which is common enough, and if we were always alone when awake, we
should believe that matters were reversed? In short, as we often dream that
we dream, heaping dream upon dream, may it not be that this half of our
life, wherein we think ourselves awake, is itself only a dream on which the
others are grafted, from which we wake at death, during which we have as few
principles of truth and good as during natural sleep, these different
thoughts which disturb us being perhaps only illusions like the flight of
time and the vain fancies of our dreams?
These are the chief arguments on one side and the other.
I omit minor ones, such as the sceptical talk against the impressions of
custom, education, manners, country and the like. Though these influence the
majority of common folk, who dogmatise only on shallow foundations, they are
upset by t
193Luke 22:66. "Art thou the Christ? tell us."
194John 5:36. "The works which the father hath given me to finish... bear
witness of me." John 10:26-27. "But ye believe not, because ye are not of my
sheep... My sheep hear my voice.
[195]"What sign shewest thou then, that we may see, and believe thee. (They
do not say: What doctrine do you preach?)"
196John 3:2. "No man can do these miracles that thou doest, except God be
with him."
[197]"The Lord, making manifest his presence, upholdeth them that are his
own portion."
198"And others, tempting him, sought of him a sign from heaven."
199Matt. 12:39. "An evil generation seeketh after a sign; and there shall no
sign be given to it."
200"And he sighed deeply in his spirit, and saith, why doth this generation
seek after a sign?"
201"Mark 6:5. "And he could there do no mighty work."
202John 4:48. "Except ye see... ye will not believe."
2039. "In signs and lying wonders."
204II Thess. 2:9-11 "After the working of Satan... and with all
deceivableness of unrighteousness in them that perish, because they received
not the love of the truth, that they might be saved. And for this cause God
shall send them strong delusion, that they should believe a lie."
205Deut. 13:3. "for the Lord your God proveth you, to know whether ye love
the Lord."
206Matt. 24:25-26. "Behold, I have told you b
When David foretold that the Messiah would deliver His people from their
enemies, one can believe that in the flesh these would be the Egyptians; and
then I
464. Philosophers.--We are full of things which take us out of ourselves.
Our instinct makes us feel that we must seek our happiness outside
ourselves. Our passions impel us outside, even when no objects present
themselves to excite them. External objects tempt us of themselves, and call
to us, even when we are not thinking of them. And thus philosophers have
said in vain: "Retire within yourselves, you will find your good there." We
do not believe them, and those who believe them are the most empty and the
most foolish.
465. The Stoics say, "Retire within yourselves; it is there you will find
your rest."
And that is not true.
Others say, "Go out of yourselves; seek happiness
401. Glory.--The brutes do not admire each other. A horse does not admire
his companion. Not that there is no rivalry between them in a race, but that
is of no consequence; for, when in the stable, the heaviest and most
ill-formed does not give up his oats to another, as men would have others do
to them. Their virtue is satisfied with itself.
402. The greatness of man even in his lust, to have known how to extract
from it a wonderful code, and to have drawn from it a picture of
benevolence.
403. Greatness.--The reasons of effects indicate the greatness of man, in
having extracted so fair an order from lust.
404. The greatest baseness of man is the pursuit of glory. But is the
greatest mark of his excellence; for whatever possessions he may have on
earth, whatever health and essential comfort, he is not satisfied if he has
not the esteem of men. He values human reason so highly that, whatever
advantages he may have on earth, he is not content if he is not also ranked
highly in the judgement of man. This is the finest position in the world.
Nothing can turn him from that desire, which is the most indelible quality
of man's heart.
And those who must despise men, and put them on a level with the brutes, yet
wish to be admired and believed by men, and contradict themselves by their
own feelings; th
This works for me on Windows:
emacs --eval "(ediff-files \"file_1\" \"file_2\")"
> @rem Put this file (ediff.cmd) in your PATH.
> @rem (Created by Setup Helper at Tue Apr 03 20:48:56 2007)
> @rem -----------------------------
> @rem Starts Emacs ediff (through gnuserv) from command line.
> @rem Takes the two file to compare as parameters.
> @setlocal
> @set f1=%1
> @set f2=%2
> @set f1=%f1:\=/%
> @set f2=%f2:\=/%
> @set emacs_cd=%CD:\=/%
> @set emacs_client="c:\emacs\p\070403\emacs\bin\emacsclient.exe"
> @%emacs_client% -n
> @%emacs_client% -e "(setq default-directory \"%emacs_cd%\")"
> @%emacs_client% -n -e "(ediff-files \"%f1%\" \"%f2%\")"
Can you explain what did you need all this complexity for?
Sure:
- Emacs client is used.
- File names given need not be absolute.
- You can not give use \ in the file names.
- Be nice, do not put env variables in the users environment
The rest is just comments ;-)
Which of these problems are relevant to the simple invocation of Emacs
that I suggested:
> > emacs --eval "(ediff-files \"file_1\" \"file_2\")"
As for this one:
> - Emacs client is used.
I don't see how is this relevant to the OP's question: if they already
have Emacs running, they could simply invoke Ediff from within that
Emacs session. And if Emacs is not running, what's the advantage of
using emacsclient?
> > - File names given need not be absolute.
> > - You can not give use \ in the file names.
> > - Be nice, do not put env variables in the users environment
>
> Which of these problems are relevant to the simple invocation of Emacs
> that I suggested:
>
> > > emacs --eval "(ediff-files \"file_1\" \"file_2\")"
I think Lennart is saying that if file_1 and file_2 are relative,
Emacs does not find them, and if they are absolute, the backslashes in
the paths cause problems (at the very least, they must be escaped
themselves).
> I don't see how is this relevant to the OP's question: if they already
> have Emacs running, they could simply invoke Ediff from within that
> Emacs session. And if Emacs is not running, what's the advantage of
> using emacsclient?
Lennart's patched emacsclient starts Emacs automatically.
Juanma
That did work. Thanks!!
And thanks everyone for helping me out.
You guys are too smart for me. I can't follow your arguments. :)
But if this helps, the reason why I wanted to know how to start emacs
in ediff mode is so that I can use it with svn (revision source
control.) svn's diff program isn't very good. However, svn allows
you to fire up your own diff program to do the diffs.
svn has a graphical version which I hear is more user friendly.
However, making a long story short, I can't effectively control what
software gets installed on my devbox. So that's why I was hoping to
use emacs for my diff program.
Do you use psvn.el ? with it when you are in svn-status, you just have
to hit E to ediff your file with the last commited version.
If you prefix your command with C-u you can ediff with the version of the file
you want.
psvn.el is installed with subversion you just have to require it.
Have a look in your site-emacs/subversion.
--
A + Thierry
Pub key: http://pgp.mit.edu
Really? It works for me with relative file names (of course, I used
"-q" as well, so if someone changes directory in their .emacs, that
could be a problem).
> Emacs does not find them, and if they are absolute, the backslashes in
> the paths cause problems (at the very least, they must be escaped
> themselves).
Or use forward slashes; nothing new here.
> > I don't see how is this relevant to the OP's question: if they already
> > have Emacs running, they could simply invoke Ediff from within that
> > Emacs session. And if Emacs is not running, what's the advantage of
> > using emacsclient?
>
> Lennart's patched emacsclient starts Emacs automatically.
That's fine, but I asked what was the _advantage_ of using
emacsclient instead of invoking Emacs itself?
> Really? It works for me with relative file names (of course, I used
> "-q" as well, so if someone changes directory in their .emacs, that
> could be a problem).
You're right.
> Or use forward slashes; nothing new here.
That' a bit more difficult if the Emacs invocation is not typed into
the command line, but comes from another tool.
> That's fine, but I asked what was the _advantage_ of using
> emacsclient instead of invoking Emacs itself?
That it works in both cases. So you can have a .BAT somewhere (perhaps
called from another tool) that runs emacsclient to do a diff, and it
does not need to know whether Emacs is already running or not, and
does not start multiple Emacs instances. I'd say that's an advantage.
Juanma
But also of course if emacs client is used you do not know which
directory Emacs has as default. So you have to tell Emacs which
directory the file names are relative to.
>> Or use forward slashes; nothing new here.
>
> That' a bit more difficult if the Emacs invocation is not typed into
> the command line, but comes from another tool.
A fairly common case could be that you do file name completion in
cmd.exe. Then you will get backward slashes. Putting these inside "..."
will make Emacs interpret them as they should escape the next character
in the string.
No: emacsclient takes care of that already, of course.
Stefan
For opening a file, yes. But not for --eval AFAICS. Perhaps it should do
it for that case too?
> For opening a file, yes. But not for --eval AFAICS.
Oh, that's right, sorry 'bout that.
> Perhaps it should do it for that case too?
Yes, probably. I believe I just fixed it in the trunk.
Stefan
The same advantage of ever using emacsclient one would have thought.
Personally I must admit to being surprised that emacsclient doesn't
invoke emacs if there is not an existing emacs running - that one
ommission makes it tricky to set up emacsclient as default viewer/editor
in many cases. One could always turn off that default behaviour for more
advanced use. I've read reasonings as to why it doesn't launch emacs if
not already done, but, well, it just seems quite wrong and I guess why
lennart changed the default in his distribution.
> Personally I must admit to being surprised that emacsclient doesn't
> invoke emacs if there is not an existing emacs running - that one
> ommission makes it tricky to set up emacsclient as default viewer/editor
> in many cases.
Of course you can run emacsclient so it will start Emacs if it is not
running; that's what the --alternate-editor option is for. The trick,
of course, is that --alternate-editor doesn't run Emacs as a server
connected to the emacsclient instance that started it. That does not
preclude using it as default viewer/editor in all cases, just the ones
where it is automatically run from a tool that expects it to be done
when emacsclient returns (for example, in many VCS when emacsclient is
used as the editor for the commit logs).
> I've read reasonings as to why it doesn't launch emacs if
> not already done, but, well, it just seems quite wrong
I haven't read (in the emacs-devel list) reasonings as to why it
*shouldn't* do it, just as to why it is not yet implemented.
Juanma
Juanma, it might be time to start looking at it again, or? As you know I
have code for this. I have tried to break the
"start-emacs-automatically" part from the gui part now.
I would be glad to get your help to get this into Emacs. Even if another
implementation for it is choosen later that will not be very hard to
change (if we structure the code so that it can easily be changed
later). What do you say, Juanma?
> I would be glad to get your help to get this into Emacs. Even if another
> implementation for it is choosen later that will not be very hard to
> change (if we structure the code so that it can easily be changed
> later). What do you say, Juanma?
Send me the patch. But please, try to make it as simple as possible.
Juanma
> On Jan 27, 2008 2:17 PM, Richard G Riley <riley...@gmail.com> wrote:
>
>> Personally I must admit to being surprised that emacsclient doesn't
>> invoke emacs if there is not an existing emacs running - that one
>> ommission makes it tricky to set up emacsclient as default viewer/editor
>> in many cases.
>
> Of course you can run emacsclient so it will start Emacs if it is not
> running; that's what the --alternate-editor option is for. The trick,
> of course, is that --alternate-editor doesn't run Emacs as a server
> connected to the emacsclient instance that started it.
Thanks for mentioning that. Staring right there at me - I had completely
missed that option. Suddenly all my defaults work a lot better :-;
> Of course you can run emacsclient so it will start Emacs if it is not
> running; that's what the --alternate-editor option is for. The trick,
> of course, is that --alternate-editor doesn't run Emacs as a server
> connected to the emacsclient instance that started it. That does not
> preclude using it as default viewer/editor in all cases, just the ones
> where it is automatically run from a tool that expects it to be done
> when emacsclient returns (for example, in many VCS when emacsclient is
> used as the editor for the commit logs).
Sorry to butt in here... I'm a (lightweight) user of emacs considering
starting to use emacsclient.
What does your comment mean practically (aside from VCS usage).
My usage is pretty basic. Scripting, gnus, file and directory
manipulation, bbdb, tramp.... probably a few other things I forgot.
Actually:
when you use emacsclient, this one use a running emacs session.
if there is no emacs session it fail, except if you use the -a option
(alternate editor)
you can use a script to do that:(you can assign your script to $EDITOR)
emacsclient -a emacs "$@"
Look on emacswiki for more sophisticated scripts.
What they want to do (i think):
when you start emacsclient, if no emacs session is found, start an emacs
session with the server corresponding to the emacsclient you have
already started (ouf!).
It should be great. :)
> What they want to do (i think):
> when you start emacsclient, if no emacs session is found, start an emacs
> session with the server corresponding to the emacsclient you have
> already started (ouf!).
That's it.
What the stock Emacs' emacsclient does today:
- Try to connect with the Emacs server.
- If it can connect, great, that's all folks.
- If it cannot, and there's an alternate editor, start that editor
(it could be Emacs), passing it the file arguments, etc.
- Otherwise fail.
What would be nice (and Lennart's EmacsW32 emacsclient more or less
does, I think):
- Try to connect with the Emacs server
- If it can connect, great, that's all folks
- If it cannot, start Emacs and wait until Emacs starts the server
- Retry connecting with Emacs
- If it can connect, great.
- If not, start an alternate editor if defined (passing the file args, etc.)
- Otherwise fail
The difference is that, in the first case, emacsclient starts the
alternate Emacs and then finishes. It does not maintain a connection
with Emacs or waits until the user signals (from inside Emacs) that
he's done with the buffer/file. That is not good when the one calling
emacsclient was not the user, but a process that starts emacsclient to
get a user-edited file (for example, a commit log) and considers that
emacsclient finishing means that the user-edited file is ready to be
used.
Juanma