all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* w32 does not have emacsclient/server
@ 2005-07-15  7:01 Lennart Borgman
  2005-07-15  8:29 ` Jason Rumney
  2005-07-15  8:31 ` David Kastrup
  0 siblings, 2 replies; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15  7:01 UTC (permalink / raw)


I just want to tell that w32 still have no working emacsclient/server. 
Gnuserver/client is a workaround, but as far as I understand this can 
currently not be part of Emacs because of license problems.

This sums up (in my opinion) that we can not distribute a fully working 
Emacs on w32. What should we do about this?

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

* Re: w32 does not have emacsclient/server
  2005-07-15  7:01 Lennart Borgman
@ 2005-07-15  8:29 ` Jason Rumney
  2005-07-15 12:40   ` Lennart Borgman
  2005-07-15  8:31 ` David Kastrup
  1 sibling, 1 reply; 74+ messages in thread
From: Jason Rumney @ 2005-07-15  8:29 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman wrote:

> I just want to tell that w32 still have no working emacsclient/server. 
> Gnuserver/client is a workaround, but as far as I understand this can 
> currently not be part of Emacs because of license problems.
>
> This sums up (in my opinion) that we can not distribute a fully 
> working Emacs on w32. What should we do about this?

Lennart,

I am not sure what you are suggesting here. Are you suggesting that we 
withdraw all support for Windows due to the support we do have not being 
"fully working"? Are you suggesting that someone(TM) should drop every 
thing else in their life and port emacsclient now? If so, are you 
willing to pay for that to happen?

What is wrong with carrying on with what we have been doing for the last 
10 years, ie doing the best we can with the limited resources we have?

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

* Re: w32 does not have emacsclient/server
  2005-07-15  7:01 Lennart Borgman
  2005-07-15  8:29 ` Jason Rumney
@ 2005-07-15  8:31 ` David Kastrup
  2005-07-15 12:21   ` Lennart Borgman
  2005-07-15 17:53   ` Guy Gascoigne - Piggford
  1 sibling, 2 replies; 74+ messages in thread
From: David Kastrup @ 2005-07-15  8:31 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> I just want to tell that w32 still have no working
> emacsclient/server. Gnuserver/client is a workaround, but as far as
> I understand this can currently not be part of Emacs because of
> license problems.
>
> This sums up (in my opinion) that we can not distribute a fully
> working Emacs on w32. What should we do about this?

Well, obviously port emacsclient.  Somebody already took a look of it
IIRC, but nothing has been heard of it since.

And with any other stuff: if nobody does the work, it will not be
done.  As far as I remember, this is a "simple" nobody-did-it-yet
case.  It is not part of any strategy or something.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-07-15  8:31 ` David Kastrup
@ 2005-07-15 12:21   ` Lennart Borgman
  2005-07-15 12:37     ` David Kastrup
  2005-07-15 14:33     ` Jason Rumney
  2005-07-15 17:53   ` Guy Gascoigne - Piggford
  1 sibling, 2 replies; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15 12:21 UTC (permalink / raw)
  Cc: Emacs Devel

David Kastrup wrote:

>Well, obviously port emacsclient.  Somebody already took a look of it
>IIRC, but nothing has been heard of it since.
>
>And with any other stuff: if nobody does the work, it will not be
>done.  As far as I remember, this is a "simple" nobody-did-it-yet
>case.  It is not part of any strategy or something.
>
Yes, nobody has done it yet and I believe there is no one working on it 
actively at the moment. I raised the issue to see if someone could do it.

I have suggested that there might be too few developers on the w32 side. 
In that sense it may actually be part of a strategy. I would be glad to 
be proven wrong.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 12:21   ` Lennart Borgman
@ 2005-07-15 12:37     ` David Kastrup
  2005-07-15 12:50       ` Lennart Borgman
  2005-07-15 14:33     ` Jason Rumney
  1 sibling, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-07-15 12:37 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> David Kastrup wrote:
>
>>Well, obviously port emacsclient.  Somebody already took a look of it
>>IIRC, but nothing has been heard of it since.
>>
>>And with any other stuff: if nobody does the work, it will not be
>>done.  As far as I remember, this is a "simple" nobody-did-it-yet
>>case.  It is not part of any strategy or something.
>>
> Yes, nobody has done it yet and I believe there is no one working on
> it actively at the moment. I raised the issue to see if someone could
> do it.
>
> I have suggested that there might be too few developers on the w32
> side. In that sense it may actually be part of a strategy.

Oh nonsense.  How many developers are _assigned_ to ports of Emacs on
free operating systems?  How many are _assigned_ to ports on
proprietary Unix-like systems?

Who do you think has the power to command all those resources?  Why do
you think we are taking years for the release to finish?  Because the
strategy does not involve assigning resources.  The only way to work a
strategy is to accept, encourage or refuse contributions.  And with
regard to proprietary systems, there is the policy that things like
Windows-only features will not be accepted.

That takes some of the fun out of working on Emacs for Windows, and so
might account for a smaller number of developers.  Frankly, I find it
surprising that the Windows port runs as well as it seemingly does,
given the minuscule amount of Windows-focused developers.

But that does not change that things like porting emacsclient don't
happen by either magic or decree.

> I would be glad to be proven wrong.

Before you can be proven wrong, you need to come up with a coherent
theory.  General moping around that stuff gets not done all by itself
on your platform is not something that is worth a proof.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-07-15  8:29 ` Jason Rumney
@ 2005-07-15 12:40   ` Lennart Borgman
  2005-07-15 15:07     ` David Kastrup
  2005-07-15 18:21     ` Eli Zaretskii
  0 siblings, 2 replies; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15 12:40 UTC (permalink / raw)
  Cc: Emacs Devel

Jason Rumney wrote:

> Lennart Borgman wrote:
>
>> I just want to tell that w32 still have no working 
>> emacsclient/server. Gnuserver/client is a workaround, but as far as I 
>> understand this can currently not be part of Emacs because of license 
>> problems.
>>
>> This sums up (in my opinion) that we can not distribute a fully 
>> working Emacs on w32. What should we do about this?
>
>
> Lennart,
>
> I am not sure what you are suggesting here. Are you suggesting that we 
> withdraw all support for Windows due to the support we do have not 
> being "fully working"? Are you suggesting that someone(TM) should drop 
> every thing else in their life and port emacsclient now? If so, are 
> you willing to pay for that to happen?

Please don't shoot the messenger.

>
> What is wrong with carrying on with what we have been doing for the 
> last 10 years, ie doing the best we can with the limited resources we 
> have? 

I know we have done as much as we can but I do not think we have reached 
our goal in this case. I am looking for a way to handle this and I hope 
for good suggestions.

The first thing is to hope for someone who can and want to do this. If 
this fail I think we at least should tell the truth about the state of 
Emacs in this respect. Maybe that could be done by simply writing that 
special documentation for w32 that someone (Eli?) suggested.

I think this is very important. On my first tries with Emacs on w32 I 
just came to the conclusion that it was badly broken. Without the 
client/server capabilities it is not of much use for me. I did not found 
those so I just left.

The actual reason I was looking at Emacs was that I was trying to get 
rid of a proprietary implementation of vi that actually had the 
client/server capabilities. I tried Vim which was better in some 
respect, but it did not have sufficiently good integration with w32 and 
therefore lacked good client/server capabilities. It took me too much 
time to use Vim therefore. When trying Emacs I got into the same problem.

I saw these difficulties as failures of Emacs and Vim. Some people might 
see them as failures of w32, but I think that does not lead to anything 
useful.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 12:37     ` David Kastrup
@ 2005-07-15 12:50       ` Lennart Borgman
  2005-07-15 15:12         ` David Kastrup
  0 siblings, 1 reply; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15 12:50 UTC (permalink / raw)
  Cc: Emacs Devel

David Kastrup wrote:

>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>  
>
>>Yes, nobody has done it yet and I believe there is no one working on
>>it actively at the moment. I raised the issue to see if someone could
>>do it.
>>
>>I have suggested that there might be too few developers on the w32
>>side. In that sense it may actually be part of a strategy.
>>    
>>
>
>Oh nonsense.  How many developers are _assigned_ to ports of Emacs on
>free operating systems?  How many are _assigned_ to ports on
>proprietary Unix-like systems?
>  
>
Sorry, I think you are misunderstanding me.

>Who do you think has the power to command all those resources?  Why do
>you think we are taking years for the release to finish?  Because the
>strategy does not involve assigning resources.  The only way to work a
>strategy is to accept, encourage or refuse contributions.  And with
>regard to proprietary systems, there is the policy that things like
>Windows-only features will not be accepted.
>
>That takes some of the fun out of working on Emacs for Windows, and so
>might account for a smaller number of developers.  Frankly, I find it
>surprising that the Windows port runs as well as it seemingly does,
>given the minuscule amount of Windows-focused developers.
>  
>
You make the same guess as I do. What should be allowed and what should 
not be allowed must be handled with care otherwise it will not make 
sense. Not doing that is just exercising power without saying so.

I personally find it quite disturbing that the policies do not allow for 
fetching for example paper size from within Emacs. You can work around 
that, but in the end you have done far less useful work than if it was 
allowed from withing Emacs. This and the small amount of developers I 
believe can cause trouble.

>But that does not change that things like porting emacsclient don't
>happen by either magic or decree.
>  
>
I do not believe in either magic or decree ;-)

>  
>
>>I would be glad to be proven wrong.
>>    
>>
>
>Before you can be proven wrong, you need to come up with a coherent
>theory.  General moping around that stuff gets not done all by itself
>on your platform is not something that is worth a proof.
>
I try to share my thoughts on this. Others before me have preferred to 
leave. Since I believe GNU is a good thing I am staying.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 12:21   ` Lennart Borgman
  2005-07-15 12:37     ` David Kastrup
@ 2005-07-15 14:33     ` Jason Rumney
  2005-07-15 14:52       ` Lennart Borgman
  2005-07-15 15:13       ` Juanma Barranquero
  1 sibling, 2 replies; 74+ messages in thread
From: Jason Rumney @ 2005-07-15 14:33 UTC (permalink / raw)
  Cc: Emacs Devel


> I have suggested that there might be too few developers on the w32 
> side. In that sense it may actually be part of a strategy.


There is no conspiracy here. The number of developers reflects the 
number of volunteers.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 14:33     ` Jason Rumney
@ 2005-07-15 14:52       ` Lennart Borgman
  2005-07-15 15:15         ` David Kastrup
  2005-07-15 15:13       ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15 14:52 UTC (permalink / raw)
  Cc: Emacs Devel

Jason Rumney wrote:

>
>> I have suggested that there might be too few developers on the w32 
>> side. In that sense it may actually be part of a strategy.
>
>
>
> There is no conspiracy here. The number of developers reflects the 
> number of volunteers. 

I am not at all talking about conspiracy. I am trying to tell what I 
suspect the current strategy leads to. (I e too few volunteers.) Sorry 
if my words where misleading, no insult was meant.

However that was not the main purpose of my message. Please write about 
the problem I took up (no emacsclient/server on w32) and possible solutions.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 12:40   ` Lennart Borgman
@ 2005-07-15 15:07     ` David Kastrup
  2005-07-15 16:52       ` Lennart Borgman
  2005-07-15 18:21     ` Eli Zaretskii
  1 sibling, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-07-15 15:07 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Jason Rumney wrote:
>
>> Lennart Borgman wrote:
>>
>>> I just want to tell that w32 still have no working
>>> emacsclient/server. Gnuserver/client is a workaround, but as far as
>>> I understand this can currently not be part of Emacs because of
>>> license problems.
>>>
>>> This sums up (in my opinion) that we can not distribute a fully
>>> working Emacs on w32. What should we do about this?
>>
>> I am not sure what you are suggesting here. Are you suggesting that
>> we withdraw all support for Windows due to the support we do have
>> not being "fully working"? Are you suggesting that someone(TM)
>> should drop every thing else in their life and port emacsclient now?
>> If so, are you willing to pay for that to happen?
>
> Please don't shoot the messenger.

There is no message worth noting.  We don't have a working emacsclient
on w32, and that's well-known.  It won't magically come into being by
throwing a tantrum.

>> What is wrong with carrying on with what we have been doing for the
>> last 10 years, ie doing the best we can with the limited resources
>> we have?
>
> I know we have done as much as we can but I do not think we have
> reached our goal in this case.  I am looking for a way to handle
> this and I hope for good suggestions.

The way to handle this is to create a working implementation of
emacsclient.  Feel free to go ahead.

> The first thing is to hope for someone who can and want to do
> this. If this fail I think we at least should tell the truth about
> the state of Emacs in this respect.

Where do we lie about it?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-07-15 12:50       ` Lennart Borgman
@ 2005-07-15 15:12         ` David Kastrup
  0 siblings, 0 replies; 74+ messages in thread
From: David Kastrup @ 2005-07-15 15:12 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> David Kastrup wrote:
>
>>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>>  
>>
>>>Yes, nobody has done it yet and I believe there is no one working on
>>>it actively at the moment. I raised the issue to see if someone could
>>>do it.
>>>
>>>I have suggested that there might be too few developers on the w32
>>>side. In that sense it may actually be part of a strategy.
>>>    
>>>
>>
>>Oh nonsense.  How many developers are _assigned_ to ports of Emacs on
>>free operating systems?  How many are _assigned_ to ports on
>>proprietary Unix-like systems?
>>  
>>
> Sorry, I think you are misunderstanding me.

So how about actually saying what you mean?

> You make the same guess as I do. What should be allowed and what
> should not be allowed must be handled with care otherwise it will
> not make sense. Not doing that is just exercising power without
> saying so.

If you have a concrete complaint to make about anything in particular
that is not handled with care, feel free to do so.  But general
insinuations are completely useless.

> I personally find it quite disturbing that the policies do not allow
> for fetching for example paper size from within Emacs.

Nonsense.  If they are implemented as a general feature that would,
for example, consult LC_PAPER on Posix-compliant systems, there is
nothing speaking about doing this.

But there will be no Windows-only features.  If people want an Emacs
that is fully useful only on Windows, then they can create their own
fork instead of demand that their Winmacs be maintained and catered
for by free software developers.

> You can work around that, but in the end you have done far less
> useful work than if it was allowed from within Emacs.

It is not prohibited at all, as far as I can see.

>>But that does not change that things like porting emacsclient don't
>>happen by either magic or decree.
>
> I do not believe in either magic or decree ;-)

Fine, then what are you complaining about?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-07-15 14:33     ` Jason Rumney
  2005-07-15 14:52       ` Lennart Borgman
@ 2005-07-15 15:13       ` Juanma Barranquero
  2005-07-15 15:48         ` David Kastrup
  2005-07-15 17:15         ` Lennart Borgman
  1 sibling, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-07-15 15:13 UTC (permalink / raw)
  Cc: Lennart Borgman, Emacs Devel

On 7/15/05, Jason Rumney <jasonr@gnu.org> wrote:

> There is no conspiracy here. The number of developers reflects the
> number of volunteers.

I absolutely agree with David and you on this issue.

OTOH, as in any volunteer development effort, people often feels a bit
left out. Warnock applies much more that many of us would like. That's
totally justified (no one has the obligation to answer, or even read,
every email), but sometimes it *is* a bit discouraging. God knows I'd
like to finish the issue of the JPEG image libraries crashing on MSVC
builds, but repeated requests for help or comment had gone
unnoticed...

So my (possibly wrong) personal take on Lennart's words is that he's
simply venting out a little bit of frustration.

-- 
                    /L/e/k/t/u


  The problem with no response is that there are five possible
interpretations:
  1) The post is correct, well-written information that needs no
follow-up commentary.  There's nothing more to say except "Yeah,
what he said."
  2) The post is complete and utter nonsense, and no one wants to
waste the energy or bandwidth to even point this out.
  3) No one read the post, for whatever reason.
  4) No one understood the post, but won't ask for clarification,
for whatever reason.
  5) No one cares about the post, for whatever reason.
                         -- Bryan C. Warnock, "Warnock's Dilemma"

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

* Re: w32 does not have emacsclient/server
  2005-07-15 14:52       ` Lennart Borgman
@ 2005-07-15 15:15         ` David Kastrup
  2005-07-15 20:28           ` Stefan Monnier
  0 siblings, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-07-15 15:15 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Jason Rumney wrote:
>
>>
>>> I have suggested that there might be too few developers on the w32
>>> side. In that sense it may actually be part of a strategy.
>>
>>
>>
>> There is no conspiracy here. The number of developers reflects the
>> number of volunteers. 
>
> I am not at all talking about conspiracy. I am trying to tell what I
> suspect the current strategy leads to. (I e too few volunteers.)

If we have an abundance of volunteers that refuse to improve Emacs
except on proprietary platforms, we are worse off than we are now.

> However that was not the main purpose of my message. Please write
> about the problem I took up (no emacsclient/server on w32) and
> possible solutions.

The solution is that somebody write a working emacsclient/server.
Obviously, this someone is to be looked for among people actually
using Windows.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* RE: w32 does not have emacsclient/server
@ 2005-07-15 15:36 klaus.berndl
  2005-07-16 13:28 ` Juanma Barranquero
  0 siblings, 1 reply; 74+ messages in thread
From: klaus.berndl @ 2005-07-15 15:36 UTC (permalink / raw)
  Cc: emacs-devel

Lennart Borgman wrote:
> Jason Rumney wrote:
> 
>> 
>>> I have suggested that there might be too few developers on the w32
>>> side. In that sense it may actually be part of a strategy.
>> 
>> 
>> 
>> There is no conspiracy here. The number of developers reflects the
>> number of volunteers.
> 
> I am not at all talking about conspiracy. I am trying to tell what I
> suspect the current strategy leads to. (I e too few volunteers.) Sorry
> if my words where misleading, no insult was meant.
> 
> However that was not the main purpose of my message. Please write
> about 
> the problem I took up (no emacsclient/server on w32) and possible
> solutions. 

Whats wrong with the situation extisting the last 10 years (estimated ;-):
1. Installing w32-emacs
2. Installing gnuserv/gnuclient
3. setting up gnuserv/gnuclient (AFAIK ~ 2 line in .emacs)
4. Having a well working Emacs-server on w32...

This is fully sufficient until a working emacsserver/client comes
up for w32 - at least for me ;-)

Ciao,
Klaus

> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: w32 does not have emacsclient/server
  2005-07-15 15:13       ` Juanma Barranquero
@ 2005-07-15 15:48         ` David Kastrup
  2005-07-18  6:22           ` Juanma Barranquero
  2005-07-15 17:15         ` Lennart Borgman
  1 sibling, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-07-15 15:48 UTC (permalink / raw)
  Cc: Lennart Borgman, Emacs Devel, Jason Rumney

Juanma Barranquero <lekktu@gmail.com> writes:

> On 7/15/05, Jason Rumney <jasonr@gnu.org> wrote:
>
>> There is no conspiracy here. The number of developers reflects the
>> number of volunteers.
>
> I absolutely agree with David and you on this issue.
>
> OTOH, as in any volunteer development effort, people often feels a
> bit left out. Warnock applies much more that many of us would
> like. That's totally justified (no one has the obligation to answer,
> or even read, every email), but sometimes it *is* a bit
> discouraging. God knows I'd like to finish the issue of the JPEG
> image libraries crashing on MSVC builds, but repeated requests for
> help or comment had gone unnoticed...

Well, again this is an issue that the only people qualified to comment
on are those that have actually experience with Windows, MSVC and the
JPEG libraries, and it is likely that pretty much the only person
qualified to comment on it is the one posting the questions in the
first place.  So nobody else chimes in.  It basically becomes largely
a one-man show of one person who keeps a record of his doubts and
struggles in public.

Actually, at the current point of time, I see this much more with Luc
than with any Windows developer.  He is working on a lot of things
that nobody else seemingly has touched for quite a while.  It is does
no harm asking for second opinions and documenting what you are doing,
but expecting continuous feedback for something where others are at
least equally out of depth is a recipe for misery, and stumbling
through foreign code is misery, anyway.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-07-15 15:07     ` David Kastrup
@ 2005-07-15 16:52       ` Lennart Borgman
  0 siblings, 0 replies; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15 16:52 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

David Kastrup wrote:

>The way to handle this is to create a working implementation of
>emacsclient.  Feel free to go ahead.
>  
>
Sorry, I do not know network programming enough. Someone who could 
implement this must know this on both the unix style and winsock.

>>The first thing is to hope for someone who can and want to do
>>this. If this fail I think we at least should tell the truth about
>>the state of Emacs in this respect.
>>    
>>
>
>Where do we lie about it?
>
I just looked again at all the files in CVS to see where 
gnuclient/server is mentioned. As far as I can see it is not mentioned 
anywhere that you should use gnuclient/server on w32. Beside this there 
is no pointer at all to the w32 version of gnuclient/server.

Maybe all we can do at this stage is mention in Info how to get around 
the missing emacsclient/server on w32 and where to find gnuclient/server 
for w32? I think this is a minimum and I also think that this really 
should help new users on w32.

Could this suggestion be accepted? I can of try writing this info.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 15:13       ` Juanma Barranquero
  2005-07-15 15:48         ` David Kastrup
@ 2005-07-15 17:15         ` Lennart Borgman
  2005-07-15 23:24           ` Robert J. Chassell
  1 sibling, 1 reply; 74+ messages in thread
From: Lennart Borgman @ 2005-07-15 17:15 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

Juanma Barranquero wrote:

>On 7/15/05, Jason Rumney <jasonr@gnu.org> wrote:
>
>  
>
>>There is no conspiracy here. The number of developers reflects the
>>number of volunteers.
>>    
>>
>
>I absolutely agree with David and you on this issue.
>  
>
No problems. I do too. I am talking about consequences, not intentions.

>So my (possibly wrong) personal take on Lennart's words is that he's
>simply venting out a little bit of frustration.
>  
>
Yes, and I think when I now look at the answers that I was maybe more 
frustrated than I was aware of. Frustration wakes more frustration. BTW 
that was not my intention but it was a consequence of the way I wrote.

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

* Re: w32 does not have emacsclient/server
  2005-07-15  8:31 ` David Kastrup
  2005-07-15 12:21   ` Lennart Borgman
@ 2005-07-15 17:53   ` Guy Gascoigne - Piggford
  1 sibling, 0 replies; 74+ messages in thread
From: Guy Gascoigne - Piggford @ 2005-07-15 17:53 UTC (permalink / raw)
  Cc: Lennart Borgman, Emacs Devel

Well that someone was me.

The short version is that I completely dropped the ball on this and
after volunteering to look at porting emacsclient to Windows never had
the time to actually do it.  I updated gnuclient at the time and then
ran out of time when looking at all of the changes in the new emacsclient.

Many moons ago when I looked at emacsclient it was a C client and a C
server in a very similar pattern to gnuclient, now it's a lisp server
wrapping core emacs functionality and a C client.  Whilst I'm probably
quite capable of dealing with the C code, I'm a complete neophyte when
it comes to lisp and so part of my problem is not really having the time
to learn enough lisp to add the support needed to get an acceptable 
working version.

I feel pretty bad about this, but can't really kid myself that I'll
suddenly get or make time.

Guy

David Kastrup wrote:

>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>
>  
>
>>I just want to tell that w32 still have no working
>>emacsclient/server. Gnuserver/client is a workaround, but as far as
>>I understand this can currently not be part of Emacs because of
>>license problems.
>>
>>This sums up (in my opinion) that we can not distribute a fully
>>working Emacs on w32. What should we do about this?
>>    
>>
>
>Well, obviously port emacsclient.  Somebody already took a look of it
>IIRC, but nothing has been heard of it since.
>
>And with any other stuff: if nobody does the work, it will not be
>done.  As far as I remember, this is a "simple" nobody-did-it-yet
>case.  It is not part of any strategy or something.
>
>  
>

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

* Re: w32 does not have emacsclient/server
  2005-07-15 12:40   ` Lennart Borgman
  2005-07-15 15:07     ` David Kastrup
@ 2005-07-15 18:21     ` Eli Zaretskii
  2005-07-16 20:45       ` Richard M. Stallman
  1 sibling, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-07-15 18:21 UTC (permalink / raw)
  Cc: emacs-devel, jasonr

> Date: Fri, 15 Jul 2005 14:40:09 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> Cc: Emacs Devel <emacs-devel@gnu.org>
> 
> The first thing is to hope for someone who can and want to do this. If 
> this fail I think we at least should tell the truth about the state of 
> Emacs in this respect. Maybe that could be done by simply writing that 
> special documentation for w32 that someone (Eli?) suggested.

Yes, I think Windows-specific appendix in the manual is sorely needed,
to at least describe all those w32-SOMETHING functions and variables,
if nothing else.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 15:15         ` David Kastrup
@ 2005-07-15 20:28           ` Stefan Monnier
  2005-07-27 14:34             ` Juanma Barranquero
  2005-08-05  1:43             ` Juanma Barranquero
  0 siblings, 2 replies; 74+ messages in thread
From: Stefan Monnier @ 2005-07-15 20:28 UTC (permalink / raw)
  Cc: Lennart Borgman, Jason Rumney, Emacs Devel

> The solution is that somebody write a working emacsclient/server.
> Obviously, this someone is to be looked for among people actually
> using Windows.

Actually, I don't think so.  IIRC What we need for emacsclient/server to
work on Windows is to make it work over TCP sockets rather than only over
Unix sockets (because Windows supports TCL sockets but not Unix sockets).

A good approach could be something like: in server.el, use a TCP server
socket (on a non-specified port).  Once opened, check to see which port was
used.  Write the port and hostname together with a secret random string into
~/.emacs_server.  When a connection comes in, check that the first bytes
sent are exactly the same as the random string (authentication).


        Stefan

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

* Re: w32 does not have emacsclient/server
  2005-07-15 17:15         ` Lennart Borgman
@ 2005-07-15 23:24           ` Robert J. Chassell
  0 siblings, 0 replies; 74+ messages in thread
From: Robert J. Chassell @ 2005-07-15 23:24 UTC (permalink / raw)
  Cc: emacs-devel

    >>There is no conspiracy here. The number of developers reflects the
    >>number of volunteers.

Perhaps developers, if they have the opportunity, prefer freedom:
freedom to develop regardless of what it is, even an operating system.

Obviously, people choose order and law before they choose justice 
-- people want to live -- but Maslow's hierarchy of needs is
straightforward.

Very few will volunteer to help the owners of a company that uses a
government, or several governments, to enforce non-freedom, even if
they think that their actions may help those who, willy-nilly, use
that company's software.

-- 
    Robert J. Chassell                         
    bob@rattlesnake.com                         GnuPG Key ID: 004B4AC8
    http://www.rattlesnake.com                  http://www.teak.cc

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

* Re: w32 does not have emacsclient/server
  2005-07-15 15:36 w32 does not have emacsclient/server klaus.berndl
@ 2005-07-16 13:28 ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-07-16 13:28 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel, jasonr

On 7/15/05, klaus.berndl@sdm.de <klaus.berndl@sdm.de> wrote:

> Whats wrong with the situation extisting the last 10 years (estimated ;-):
> 1. Installing w32-emacs
> 2. Installing gnuserv/gnuclient
> 3. setting up gnuserv/gnuclient (AFAIK ~ 2 line in .emacs)
> 4. Having a well working Emacs-server on w32...

Nothing, except:

 1.1 Locating gnuserv/gnuclient.
 1.2 Determining which one of the several available versions is best/newest.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-07-15 18:21     ` Eli Zaretskii
@ 2005-07-16 20:45       ` Richard M. Stallman
  2005-07-17  3:33         ` Eli Zaretskii
  0 siblings, 1 reply; 74+ messages in thread
From: Richard M. Stallman @ 2005-07-16 20:45 UTC (permalink / raw)
  Cc: lennart.borgman.073, jasonr, emacs-devel

    Yes, I think Windows-specific appendix in the manual is sorely needed,
    to at least describe all those w32-SOMETHING functions and variables,
    if nothing else.

I would rather not put them in the printed Lisp Manual.
A separate manual that we don't print would be better.

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

* Re: w32 does not have emacsclient/server
  2005-07-16 20:45       ` Richard M. Stallman
@ 2005-07-17  3:33         ` Eli Zaretskii
  2005-07-17 17:36           ` Richard M. Stallman
  0 siblings, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-07-17  3:33 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> From: "Richard M. Stallman" <rms@gnu.org>
> CC: lennart.borgman.073@student.lu.se, emacs-devel@gnu.org,
> 	jasonr@gnu.org
> Date: Sat, 16 Jul 2005 16:45:32 -0400
> 
>     Yes, I think Windows-specific appendix in the manual is sorely needed,
>     to at least describe all those w32-SOMETHING functions and variables,
>     if nothing else.
> 
> I would rather not put them in the printed Lisp Manual.

I was talking about user-level features and the User's Manual, not the
Lisp Manual.

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

* Re: w32 does not have emacsclient/server
  2005-07-17  3:33         ` Eli Zaretskii
@ 2005-07-17 17:36           ` Richard M. Stallman
  2005-07-17 18:09             ` Eli Zaretskii
  0 siblings, 1 reply; 74+ messages in thread
From: Richard M. Stallman @ 2005-07-17 17:36 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    >     Yes, I think Windows-specific appendix in the manual is sorely needed,
    >     to at least describe all those w32-SOMETHING functions and variables,
    >     if nothing else.
    > 
    > I would rather not put them in the printed Lisp Manual.

    I was talking about user-level features and the User's Manual, not the
    Lisp Manual.

The appendix that is suggested does not belong in the Emacs Manual.

There already is a section on Windows usage in the Emacs Manual.  But
it is not the mission of the Emacs Manual to "describe all those
w32-SOMETHING functions and variables", any more than it is its mission
to describe all the functions and variables that are NOT specifically
for Windows.

In nearly every aspect of Emacs, _completeness is not the goal_.
Would people please stop making suggestions that we aim to do this or
that in _complete_ manner?

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

* Re: w32 does not have emacsclient/server
  2005-07-17 17:36           ` Richard M. Stallman
@ 2005-07-17 18:09             ` Eli Zaretskii
  2005-07-18 16:33               ` Richard M. Stallman
  0 siblings, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-07-17 18:09 UTC (permalink / raw)
  Cc: emacs-devel

> From: "Richard M. Stallman" <rms@gnu.org>
> CC: lennart.borgman.073@student.lu.se, emacs-devel@gnu.org
> Date: Sun, 17 Jul 2005 13:36:19 -0400
> 
>     I was talking about user-level features and the User's Manual, not the
>     Lisp Manual.
> 
> The appendix that is suggested does not belong in the Emacs Manual.

Why not, if it describes user-level features?

> There already is a section on Windows usage in the Emacs Manual.

No, there's an appendix called "MS-DOS" which describes mostly the DOS
port and a small number of Windows related issues.

> But
> it is not the mission of the Emacs Manual to "describe all those
> w32-SOMETHING functions and variables", any more than it is its mission
> to describe all the functions and variables that are NOT specifically
> for Windows.
> 
> In nearly every aspect of Emacs, _completeness is not the goal_.

This is not about completeness in any sense; perhaps the word "all" in
"all those w32-SOMETHING functions" misled you to think that is what I
was asking for.  It isn't.  There's a large number of issues specific
to using Emacs on Windows that is not explained anywhere in the Emacs
Manual.  Some of the w32-SOMETHING functions and variables should be
made known to Emacs users because they provide essential features
without which some users would be simply lost.  In addition, there are
quite a few Windows-specific issues not related directly to any
function or variable that should also be available in the manual.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 15:48         ` David Kastrup
@ 2005-07-18  6:22           ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-07-18  6:22 UTC (permalink / raw)
  Cc: Lennart Borgman, Emacs Devel, Jason Rumney

On 7/15/05, David Kastrup <dak@gnu.org> wrote:

> Well, again this is an issue that the only people qualified to comment
> on are those that have actually experience with Windows, MSVC and the
> JPEG libraries, and it is likely that pretty much the only person
> qualified to comment on it is the one posting the questions in the
> first place.  So nobody else chimes in.  It basically becomes largely
> a one-man show of one person who keeps a record of his doubts and
> struggles in public.

I think you're right on the general principle. But I'm talking of one
specific problem (the JPEG/filehandle issue) that does not match your
explanation:

  - The main issue I'm expecting to hear comments about is *legal*,
not technical: whether the code from a file in jpeglib can be used or
not (there are reasons why I think it could, that I did explain in my
original message).
 - The change is not Windows-specific: it would affect every platform
(in trivial ways, in fact).
 - The fix is not Windows-specific: the code has no Windows
particularities of any kind, it's just a relatively straight change to
call FILE*-oriented read/write functions directly instead of relying
on the ones embedded in the image library.
  - If the decision of the legal issue is that the code in my patch
can not be used (because it is lifted from a file in jpeglib), I can
no re-code it (I think) because I'm "tainted" by having read and
copied the original. Someone else should have to write three or four
functions, no more than twenty or thirty lines of code.

So, any kind of input on this issue, and pointers on how to approach
it to push it to a conclusion, would be very appreciated.

> It is does
> no harm asking for second opinions and documenting what you are doing,
> but expecting continuous feedback for something where others are at
> least equally out of depth is a recipe for misery, and stumbling
> through foreign code is misery, anyway.

Of course. In fact, the problem with library image crashes consisted
of two similar, though unrelated, issues: one with jpeglib, the other
with pnglib. I asked about both, and after a while I installed the
pnglib patch, because it had no legal implications. So I'm fully aware
that sometimes the answer to Warnock's Dilemma is: "6) Some people
understood the question just fine, but had no insight to share, for
whatever reason". I have no problem committing the code in this case,
and I've done quite a few times.

My comment about feeling a little left out is about the *other* cases,
the ones where the feedback *is* important. That's why I've brought
this up about... what, four times now?

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-07-17 18:09             ` Eli Zaretskii
@ 2005-07-18 16:33               ` Richard M. Stallman
  0 siblings, 0 replies; 74+ messages in thread
From: Richard M. Stallman @ 2005-07-18 16:33 UTC (permalink / raw)
  Cc: emacs-devel

      There's a large number of issues specific
    to using Emacs on Windows that is not explained anywhere in the Emacs
    Manual.

I would not be opposed to adding a certain amount of material
to the existing section.  However, if it is going to become large,
it should be moved out of the manual.

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

* Re: w32 does not have emacsclient/server
  2005-07-15 20:28           ` Stefan Monnier
@ 2005-07-27 14:34             ` Juanma Barranquero
  2005-07-27 15:45               ` Jason Rumney
  2005-08-05  1:43             ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-07-27 14:34 UTC (permalink / raw)
  Cc: Emacs Devel

On 7/15/05, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Actually, I don't think so.  IIRC What we need for emacsclient/server to
> work on Windows is to make it work over TCP sockets rather than only over
> Unix sockets (because Windows supports TCL sockets but not Unix sockets).

I'm taking a stab at this. Modifying server.el to use TCP sockets is
trivial, and modifying emacsclient.c should not be hard *if* the Unix
socket support is to be scrapped.

> in server.el, use a TCP server socket (on a non-specified port).
> Once opened, check to see which port was used.  Write the port
> and hostname together with a secret random string into
> ~/.emacs_server.  When a connection comes in, check that the
> first bytes sent are exactly the same as the random string

I suppose this is to avoid choosing a port number as the standard
"Emacs server port"? I'd rather choose a number, and let the user set
it up on server.el and pass it to emacsclient.c in case there's a
conflict on her system...

Another parameter to pass would be the ip address, wouldn't? I'm
assuming it's frequent on non-Windows environments to emacsclient
against an Emacs server at another machine...

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-07-27 14:34             ` Juanma Barranquero
@ 2005-07-27 15:45               ` Jason Rumney
  2005-07-27 16:16                 ` Juanma Barranquero
  0 siblings, 1 reply; 74+ messages in thread
From: Jason Rumney @ 2005-07-27 15:45 UTC (permalink / raw)
  Cc: Stefan Monnier, Emacs Devel

Juanma Barranquero wrote:

>>in server.el, use a TCP server socket (on a non-specified port).
>>Once opened, check to see which port was used.  Write the port
>>and hostname together with a secret random string into
>>~/.emacs_server.  When a connection comes in, check that the
>>first bytes sent are exactly the same as the random string
>>    
>>
>I suppose this is to avoid choosing a port number as the standard
>"Emacs server port"? I'd rather choose a number, and let the user set
>it up on server.el and pass it to emacsclient.c in case there's a
>conflict on her system...
>  
>
Multiple users can start servers on the same machine, so assigning a 
"standard" port is likely to conflict. It is better to let the socket 
library choose a free socket. The client will be reading it from a file 
anyway, so the user does not need to know what port has been chosen.

>Another parameter to pass would be the ip address, wouldn't?
>
Stefan's spec above already includes the hostname.

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

* Re: w32 does not have emacsclient/server
  2005-07-27 15:45               ` Jason Rumney
@ 2005-07-27 16:16                 ` Juanma Barranquero
  2005-07-27 16:31                   ` Jason Rumney
  2005-07-28 17:20                   ` Stefan Monnier
  0 siblings, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-07-27 16:16 UTC (permalink / raw)
  Cc: Stefan Monnier, Emacs Devel

On 7/27/05, Jason Rumney <jasonr@gnu.org> wrote:

> Multiple users can start servers on the same machine, so assigning a
> "standard" port is likely to conflict. It is better to let the socket
> library choose a free socket. The client will be reading it from a file
> anyway, so the user does not need to know what port has been chosen.

OK but, what about connecting to a remote server? You don't need read
access to the filesystem to do it, do you? How's that currently done?

> Stefan's spec above already includes the hostname.

Yeah, you're right. Sorry.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-07-27 16:16                 ` Juanma Barranquero
@ 2005-07-27 16:31                   ` Jason Rumney
  2005-07-28 17:20                   ` Stefan Monnier
  1 sibling, 0 replies; 74+ messages in thread
From: Jason Rumney @ 2005-07-27 16:31 UTC (permalink / raw)
  Cc: Stefan Monnier, Emacs Devel


[-- Attachment #1.1: Type: text/plain, Size: 597 bytes --]

Juanma Barranquero wrote:

>On 7/27/05, Jason Rumney <jasonr@gnu.org> wrote:
>
>  
>
>>Multiple users can start servers on the same machine, so assigning a
>>"standard" port is likely to conflict. It is better to let the socket
>>library choose a free socket. The client will be reading it from a file
>>anyway, so the user does not need to know what port has been chosen.
>>    
>>
>
>OK but, what about connecting to a remote server? You don't need read
>access to the filesystem to do it, do you? How's that currently done?
>  
>
You need to be able to transfer the authorization file somehow.

[-- Attachment #1.2: Type: text/html, Size: 1071 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: w32 does not have emacsclient/server
  2005-07-27 16:16                 ` Juanma Barranquero
  2005-07-27 16:31                   ` Jason Rumney
@ 2005-07-28 17:20                   ` Stefan Monnier
  1 sibling, 0 replies; 74+ messages in thread
From: Stefan Monnier @ 2005-07-28 17:20 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

> OK but, what about connecting to a remote server? You don't need read
> access to the filesystem to do it, do you? How's that currently done?

Currently it doesn't work.  It'd be a new feature provided by TCP sockets.
But for it to work safely, it needs authentication, which is what the random
string is for.  Since you need to get the random string, you may as well get
the port number with it.


        Stefan

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

* Re: w32 does not have emacsclient/server
  2005-07-15 20:28           ` Stefan Monnier
  2005-07-27 14:34             ` Juanma Barranquero
@ 2005-08-05  1:43             ` Juanma Barranquero
  2005-08-05  7:59               ` Juanma Barranquero
  2005-08-08 23:49               ` Stefan Monnier
  1 sibling, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-05  1:43 UTC (permalink / raw)
  Cc: Emacs Devel

On 7/15/05, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Actually, I don't think so.  IIRC What we need for emacsclient/server to
> work on Windows is to make it work over TCP sockets rather than only over
> Unix sockets (because Windows supports TCL sockets but not Unix sockets).
> 
> A good approach could be something like: in server.el, use a TCP server
> socket (on a non-specified port).  Once opened, check to see which port was
> used.  Write the port and hostname together with a secret random string into
> ~/.emacs_server.  When a connection comes in, check that the first bytes
> sent are exactly the same as the random string (authentication).

The following is a first cut at implementing this.

server.el now creates an AF_INET socket, at an unspecified port. The
host address is local (127.0.0.1) unless the user customizes the
variable `server-host' to the IP or name to use to bind the socket.
The server generates a 64-byte random string (not random bytes, but
printable characters in the range `!'..`~'; it's still about 420 bits
of entropy) and writes in `server-file' (by default "~/.emacs.server")
the host, port and authentication string. Connections are expected to
pass as the first thing in a communication exchange the string "-auth
AUTHENTICATION-STRING" where AUTHENTICATION-STRING is the 64-byte
secret key; otherwise the connection is closed immediately.

In emacsclient.c I've got rid of all AF_UNIX stuff. I've also changed
the code to use send/recv instead of writing to a file handle (was
easier than fighting two Windows C compilers' idiosincrasies) and
added buffering so data is only sent on receiving "\n" or filling the
buffer. Argument `socket-name' has been replaced by `server-file', to
indicate the path to the server config/auth file (alternatively, the
variable EMACS_SERVER_FILE can be set to point to the file; and BTW, a
better name for the variable would be very welcome). The last change
has been to make it consider \path and c:path as absolute paths
(previously it would prepend the current directory to Windows-style
absolute paths).

As it stands, it builds on Windows XP with GCC and MSVC. I'd like help with:

 - testing on other Windows environments
 - building *and* testing on non-Windows environments (it should work, but...)
 - configuration of lib-src/Makefile.w32-in (my change is a bit of a
mess, I think)

To do:

 - more testing
 - a bit of a cleanup, perhaps
 - documentation changes

and of course any change, fix or redesign that is deemed necessary.
Personally I'd like to add an option to force the host port and allow
alternative (or even null) authentication strings, so in secure
environments it'd be posible to use emacsclient/server.el with a fixed
address/port and no .emacs.server file (emacsclient would have to grow
--server-address and --server-port options, of course). But I
digress...

-- 
                    /L/e/k/t/u


Index: lib-src/emacsclient.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.74
diff -c -r1.74 emacsclient.c
*** lib-src/emacsclient.c	4 Jul 2005 15:24:11 -0000	1.74
--- lib-src/emacsclient.c	5 Aug 2005 00:33:54 -0000
***************
*** 20,25 ****
--- 20,28 ----
  Boston, MA 02110-1301, USA.  */
  
  
+ #define AUTH_STRING_LENGTH   64
+ #define SEND_BUFFER_SIZE   4096
+ 
  #define NO_SHORTNAMES
  
  #ifdef HAVE_CONFIG_H
***************
*** 30,45 ****
  
  #include <ctype.h>
  #include <stdio.h>
! #include <getopt.h>
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
  
  #ifdef VMS
! # include "vms-pwd.h"
  #else
! # include <pwd.h>
  #endif /* not VMS */
  
  char *getenv (), *getwd ();
  char *(getcwd) ();
--- 33,53 ----
  
  #include <ctype.h>
  #include <stdio.h>
! #include "getopt.h"
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
  
+ #ifdef WINDOWSNT
+ #include <winsock2.h>
+ #else /* not WINDOWSNT */
+ #include <sys/socket.h>
  #ifdef VMS
! #include "vms-pwd.h"
  #else
! #include <pwd.h>
  #endif /* not VMS */
+ #endif /* not WINDOWSNT */
  
  char *getenv (), *getwd ();
  char *(getcwd) ();
***************
*** 47,52 ****
--- 55,72 ----
  #ifndef VERSION
  #define VERSION "unspecified"
  #endif
+ 
+ #define SEND_STRING(data) (send_to_emacs (s, (data), 0))
+ #define SEND_QUOTED(data) (quote_file_name (s, (data)))
+ 
+ #ifndef EXIT_SUCCESS
+ #define EXIT_SUCCESS 0
+ #endif
+ 
+ #ifndef EXIT_FAILURE
+ #define EXIT_FAILURE 1
+ #endif
+ 
  \f
  /* Name used to invoke this program.  */
  char *progname;
***************
*** 61,71 ****
  char *display = NULL;
  
  /* If non-NULL, the name of an editor to fallback to if the server
!    is not running.  --alternate-editor.   */
! const char * alternate_editor = NULL;
  
! /* If non-NULL, the filename of the UNIX socket.  */
! char *socket_name = NULL;
  
  void print_help_and_exit ();
  
--- 81,96 ----
  char *display = NULL;
  
  /* If non-NULL, the name of an editor to fallback to if the server
!    is not running.  --alternate-editor.  */
! const char *alternate_editor = NULL;
  
! /* If non-NULL, the filename to use as configuration and
!    authentication file.  --server-file.  */
! const char *server_file = NULL;
! 
! /* Buffer to accumulate data to send.  */
! char send_buffer[SEND_BUFFER_SIZE+1];
! int sblen = 0;
  
  void print_help_and_exit ();
  
***************
*** 76,82 ****
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
!   { "socket-name",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
--- 101,107 ----
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
!   { "server-file",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
***************
*** 90,95 ****
--- 115,121 ----
       char **argv;
  {
    alternate_editor = getenv ("ALTERNATE_EDITOR");
+   server_file = getenv("EMACS_SERVER_FILE");
  
    while (1)
      {
***************
*** 111,117 ****
  	  break;
  
  	case 's':
! 	  socket_name = optarg;
  	  break;
  
  	case 'd':
--- 137,143 ----
  	  break;
  
  	case 's':
! 	  server_file = optarg;
  	  break;
  
  	case 'd':
***************
*** 157,164 ****
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
! -s, --socket-name=FILENAME\n\
!                         Set the filename of the UNIX socket for
communication\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  \n\
--- 183,190 ----
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
! -s, --server-file=FILENAME\n\
!                         Server configuration and authentication file\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  \n\
***************
*** 166,179 ****
    exit (EXIT_SUCCESS);
  }
  
  /* In NAME, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.  */
  
  void
! quote_file_name (name, stream)
       char *name;
-      FILE *stream;
  {
    char *copy = (char *) malloc (strlen (name) * 2 + 1);
    char *p, *q;
--- 192,242 ----
    exit (EXIT_SUCCESS);
  }
  
+ \f
+ /* Let's send the data to Emacs when either
+    - the data ends in "\n", or
+    - the buffer is full (but this shouldn't happen)
+    Otherwise, we just accumulate it.  */
+ 
+ void send_to_emacs (s, data, force)
+      SOCKET s;
+      char *data;
+      int force;
+ {
+   int dlen = strlen (data);
+   int sent;
+ 
+   while (force || (dlen + sblen >= SEND_BUFFER_SIZE))
+     {
+       sent = send (s, send_buffer, sblen, 0);
+       if (sent != sblen)
+         strcpy (send_buffer, &send_buffer[sent]);
+ 
+       sblen -= sent;
+ 
+       if (force)
+         /* Just the first time around.  */
+         force = 0;
+     }
+ 
+   if (dlen)
+     {
+       strcpy (&send_buffer[sblen], data);
+       sblen += dlen;
+     }
+ 
+   if (sblen && (send_buffer[sblen-1] == '\n'))
+     send_to_emacs (s, "\0", 1);
+ }
+ 
  /* In NAME, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.  */
  
  void
! quote_file_name (s, name)
!      SOCKET s;
       char *name;
  {
    char *copy = (char *) malloc (strlen (name) * 2 + 1);
    char *p, *q;
***************
*** 203,227 ****
      }
    *q++ = 0;
  
!   fprintf (stream, "%s", copy);
  
    free (copy);
  }
  
- /* Like malloc but get fatal error if memory is exhausted.  */
- 
- long *
- xmalloc (size)
-      unsigned int size;
- {
-   long *result = (long *) malloc (size);
-   if (result == NULL)
-   {
-     perror ("malloc");
-     exit (EXIT_FAILURE);
-   }
-   return result;
- }
  \f
  /*
    Try to run a different command, or --if no alternate editor is
--- 266,276 ----
      }
    *q++ = 0;
  
!   SEND_STRING (copy);
  
    free (copy);
  }
  
  \f
  /*
    Try to run a different command, or --if no alternate editor is
***************
*** 244,459 ****
      }
  }
  
- 
  \f
- #if !defined (HAVE_SOCKETS) || defined (NO_SOCKETS_IN_FILE_SYSTEM)
  
! int
! main (argc, argv)
       int argc;
!      char **argv;
  {
!   fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
! 	   argv[0]);
!   fprintf (stderr, "on systems with Berkeley sockets.\n");
  
!   fail (argc, argv);
! }
  
! #else /* HAVE_SOCKETS */
  
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/un.h>
! #include <sys/stat.h>
! #include <errno.h>
  
! extern char *strerror ();
! extern int errno;
  
! /* Three possibilities:
!    2 - can't be `stat'ed		(sets errno)
!    1 - isn't owned by us
!    0 - success: none of the above */
  
! static int
! socket_status (socket_name)
!      char *socket_name;
  {
!   struct stat statbfr;
  
!   if (stat (socket_name, &statbfr) == -1)
!     return 2;
  
!   if (statbfr.st_uid != geteuid ())
!     return 1;
  
!   return 0;
  }
  
! int
! main (argc, argv)
!      int argc;
!      char **argv;
  {
!   int s, i, needlf = 0;
!   FILE *out, *in;
!   struct sockaddr_un server;
!   char *cwd, *str;
!   char string[BUFSIZ];
! 
!   progname = argv[0];
  
!   /* Process options.  */
!   decode_options (argc, argv);
  
!   if ((argc - optind < 1) && !eval)
      {
!       fprintf (stderr, "%s: file name or argument required\n", progname);
!       fprintf (stderr, "Try `%s --help' for more information\n", progname);
        exit (EXIT_FAILURE);
      }
  
!   /*
!    * Open up an AF_UNIX socket in this person's home directory
!    */
  
!   if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
      {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("socket");
!       fail (argc, argv);
      }
  
!   server.sun_family = AF_UNIX;
  
!   {
!     int sock_status = 0;
!     int default_sock = !socket_name;
!     int saved_errno;
!     char *server_name = "server";
! 
!     if (socket_name && !index (socket_name, '/') && !index
(socket_name, '\\'))
!       { /* socket_name is a file name component.  */
! 	server_name = socket_name;
! 	socket_name = NULL;
! 	default_sock = 1;	/* Try both UIDs.  */
!       }
! 
!     if (default_sock)
!       {
! 	socket_name = alloca (100 + strlen (server_name));
! 	sprintf (socket_name, "/tmp/emacs%d/%s",
! 		 (int) geteuid (), server_name);
!       }
! 
!     if (strlen (socket_name) < sizeof (server.sun_path))
!       strcpy (server.sun_path, socket_name);
!     else
!       {
! 	fprintf (stderr, "%s: socket-name %s too long",
! 		 argv[0], socket_name);
! 	exit (EXIT_FAILURE);
!       }
! 
!     /* See if the socket exists, and if it's owned by us. */
!     sock_status = socket_status (server.sun_path);
!     saved_errno = errno;
!     if (sock_status && default_sock)
!       {
! 	/* Failing that, see if LOGNAME or USER exist and differ from
! 	   our euid.  If so, look for a socket based on the UID
! 	   associated with the name.  This is reminiscent of the logic
! 	   that init_editfns uses to set the global Vuser_full_name.  */
! 
! 	char *user_name = (char *) getenv ("LOGNAME");
! 
! 	if (!user_name)
! 	  user_name = (char *) getenv ("USER");
! 
! 	if (user_name)
! 	  {
! 	    struct passwd *pw = getpwnam (user_name);
! 
! 	    if (pw && (pw->pw_uid != geteuid ()))
! 	      {
! 		/* We're running under su, apparently. */
! 		socket_name = alloca (100 + strlen (server_name));
! 		sprintf (socket_name, "/tmp/emacs%d/%s",
! 			 (int) pw->pw_uid, server_name);
! 
! 		if (strlen (socket_name) < sizeof (server.sun_path))
! 		  strcpy (server.sun_path, socket_name);
! 		else
! 		  {
! 		    fprintf (stderr, "%s: socket-name %s too long",
! 			     argv[0], socket_name);
! 		    exit (EXIT_FAILURE);
! 		  }
! 
! 		sock_status = socket_status (server.sun_path);
! 		saved_errno = errno;
! 	      }
! 	    else
! 	      errno = saved_errno;
! 	  }
!       }
! 
!      switch (sock_status)
!        {
!        case 1:
! 	 /* There's a socket, but it isn't owned by us.  This is OK if
! 	    we are root. */
! 	 if (0 != geteuid ())
! 	   {
! 	     fprintf (stderr, "%s: Invalid socket owner\n", argv[0]);
! 	     fail (argc, argv);
! 	   }
! 	 break;
! 
!        case 2:
! 	 /* `stat' failed */
! 	 if (saved_errno == ENOENT)
! 	   fprintf (stderr,
! 		    "%s: can't find socket; have you started the server?\n\
! To start the server in Emacs, type \"M-x server-start\".\n",
! 		    argv[0]);
! 	 else
! 	   fprintf (stderr, "%s: can't stat %s: %s\n",
! 		    argv[0], server.sun_path, strerror (saved_errno));
! 	 fail (argc, argv);
! 	 break;
!        }
!   }
  
!   if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2)
!       < 0)
!     {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("connect");
!       fail (argc, argv);
!     }
  
!   /* We use the stream OUT to send our command to the server.  */
!   if ((out = fdopen (s, "r+")) == NULL)
      {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("fdopen");
!       fail (argc, argv);
      }
  
!   /* We use the stream IN to read the response.
!      We used to use just one stream for both output and input
!      on the socket, but reversing direction works nonportably:
!      on some systems, the output appears as the first input;
!      on other systems it does not.  */
!   if ((in = fdopen (s, "r+")) == NULL)
      {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("fdopen");
!       fail (argc, argv);
      }
  
  #ifdef HAVE_GETCWD
    cwd = getcwd (string, sizeof string);
  #else
--- 293,475 ----
      }
  }
  
  \f
  
! /* Process options and check some sane defaults.  */
! void process_options (argc, argv)
       int argc;
!      char *argv[];
  {
!   decode_options (argc, argv);
  
!   if (!server_file)
!     {
!       fprintf (stderr, "%s: server configuration file required\n", progname);
!       goto error;
!     }
  
!   if ((argc - optind < 1) && !eval)
!     {
!       fprintf (stderr, "%s: file name or argument required\n", progname);
!       goto error;
!     }
  
!   return;
  
!  error:
  
!   fprintf (stderr, "Try `%s --help' for more information\n", progname);
!   exit (EXIT_FAILURE);
! }
  
! #ifdef WINDOWSNT
! /* Wrapper to make WSACleanup a cdecl, as required by atexit().  */
! void close_winsock ()
  {
!   WSACleanup();
! }
! #endif /* WINDOWSNT */
  
! void initialize_sockets ()
! {
! #ifdef WINDOWSNT
! 
!   /* Initialize the WinSock2 library.  */
!   WSADATA wsaData;
  
!   if (WSAStartup (MAKEWORD (2, 0), &wsaData))
!     {
!       fprintf (stderr, "%s: error initializing WinSock2", progname);
!       exit (EXIT_FAILURE);
!     }
  
!   atexit (close_winsock);
! #endif
  }
  
! /*
!  * Read the information needed to set up the comm channel with
!  * the Emacs server: host, port and authentication string.
!  */
! void get_server_config (server, authentication)
!      struct sockaddr_in *server;
!      char *authentication;
  {
!   FILE *config;
!   char dotted[32];
!   char *port;
  
!   if (! (config = fopen (server_file, "rb")))
!     {
!       fprintf (stderr, "%s: cannot read configuration file %s",
!                progname, server_file);
!       exit (EXIT_FAILURE);
!     }
  
!   if (fgets (dotted, sizeof dotted, config)
!       && (port = strchr (dotted, ':')))
      {
!       *port++ = '\0';
!     }
!   else
!     {
!       fprintf (stderr, "%s: invalid configuration info", progname);
        exit (EXIT_FAILURE);
      }
  
!   server->sin_family = AF_INET;
!   server->sin_addr.s_addr = inet_addr (dotted);
!   server->sin_port = htons (atoi (port));
  
!   if (! fread (authentication, AUTH_STRING_LENGTH, 1, config))
      {
!       fprintf (stderr, "%s: cannot read authentication info", progname);
!       exit (EXIT_FAILURE);
      }
  
!   fclose (config);
! }
  
! /*
!  * Perform all required initialization; at the end either the socket
!  * is available and correctly configured, or we've finished with an
!  * error status so the main program can try the alternate editor.
!  */
! SOCKET
! set_socket ()
! {
!   SOCKET s;
!   struct sockaddr_in server;
!   unsigned long c_arg = 0;
!   struct linger l_arg = {1, 1};
!   char auth_string[AUTH_STRING_LENGTH+1];
  
!   initialize_sockets();
! 
!   get_server_config (&server, auth_string);
  
!   /*
!    * Open up an AF_INET socket
!    */
!   if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
      {
!       fprintf (stderr, "%s: ", progname);
!       perror ("socket");
!       return INVALID_SOCKET;
      }
  
!   /*
!    * Set up the socket
!    */
!   if (connect (s, (struct sockaddr *) &server, sizeof server) < 0)
      {
!       fprintf (stderr, "%s: ", progname);
!       perror ("connect");
!       return INVALID_SOCKET;
      }
  
+   /*
+    * Force socket to be blocking and SO_LINGER
+    */
+   ioctlsocket (s, FIONBIO, &c_arg);
+   setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg);
+ 
+   /*
+    * Now, let's send the authentication
+    */
+   auth_string[AUTH_STRING_LENGTH] = '\0';
+   SEND_STRING ("-auth ");
+   SEND_STRING (auth_string);
+   SEND_STRING ("\n");
+ 
+   return s;
+ }
+ 
+ \f
+ #include <sys/types.h>
+ 
+ #include <sys/stat.h>
+ #include <errno.h>
+ 
+ extern char *strerror ();
+ extern int errno;
+ 
+ int
+ main (argc, argv)
+      int argc;
+      char **argv;
+ {
+   SOCKET s;
+   int i, rl, needlf = 0;
+   char *cwd, *str;
+   char string[BUFSIZ+1];
+ 
+   progname = argv[0];
+   process_options (argc, argv);
+ 
+   if ((s = set_socket ()) == INVALID_SOCKET)
+     fail (argc, argv);
+ 
  #ifdef HAVE_GETCWD
    cwd = getcwd (string, sizeof string);
  #else
***************
*** 464,488 ****
        /* getwd puts message in STRING if it fails.  */
  
  #ifdef HAVE_GETCWD
!       fprintf (stderr, "%s: %s (%s)\n", argv[0],
  	       "Cannot get current working directory", strerror (errno));
  #else
!       fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno));
  #endif
        fail (argc, argv);
      }
  
    if (nowait)
!     fprintf (out, "-nowait ");
  
    if (eval)
!     fprintf (out, "-eval ");
  
    if (display)
      {
!       fprintf (out, "-display ");
!       quote_file_name (display, out);
!       fprintf (out, " ");
      }
  
    if ((argc - optind > 0))
--- 480,504 ----
        /* getwd puts message in STRING if it fails.  */
  
  #ifdef HAVE_GETCWD
!       fprintf (stderr, "%s: %s (%s)\n", progname,
  	       "Cannot get current working directory", strerror (errno));
  #else
!       fprintf (stderr, "%s: %s (%s)\n", progname, string, strerror (errno));
  #endif
        fail (argc, argv);
      }
  
    if (nowait)
!     SEND_STRING ("-nowait ");
  
    if (eval)
!     SEND_STRING ("-eval ");
  
    if (display)
      {
!       SEND_STRING ("-display ");
!       SEND_QUOTED (display);
!       SEND_STRING (" ");
      }
  
    if ((argc - optind > 0))
***************
*** 497,556 ****
  	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
  	      if (*p != 0)
  		{
! 		  quote_file_name (cwd, out);
! 		  fprintf (out, "/");
  		}
  	    }
! 	  else if (*argv[i] != '/')
  	    {
! 	      quote_file_name (cwd, out);
! 	      fprintf (out, "/");
  	    }
  
! 	  quote_file_name (argv[i], out);
! 	  fprintf (out, " ");
  	}
      }
    else
      {
        while ((str = fgets (string, BUFSIZ, stdin)))
  	{
! 	  quote_file_name (str, out);
  	}
!       fprintf (out, " ");
      }
  
!   fprintf (out, "\n");
!   fflush (out);
  
!   /* Maybe wait for an answer.   */
!   if (nowait)
!     return EXIT_SUCCESS;
! 
!   if (!eval)
      {
!       printf ("Waiting for Emacs...");
!       needlf = 2;
!     }
!   fflush (stdout);
  
!   /* Now, wait for an answer and print any messages.  */
!   while ((str = fgets (string, BUFSIZ, in)))
!     {
!       if (needlf == 2)
! 	printf ("\n");
!       printf ("%s", str);
!       needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
!     }
  
!   if (needlf)
!     printf ("\n");
!   fflush (stdout);
  
    return EXIT_SUCCESS;
  }
  
- #endif /* HAVE_SOCKETS */
  \f
  #ifndef HAVE_STRERROR
  char *
--- 513,578 ----
  	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
  	      if (*p != 0)
  		{
! 		  SEND_QUOTED (cwd);
! 		  SEND_STRING ("/");
  		}
  	    }
!           /* Absolute paths can also start with backslash or drive
letters.  */
!           else if ((*argv[i] != '/')
!                     && (*argv[i] != '\\')
!                     && (!islower (tolower (*argv[i]))
!                         || (argv[i][1] != ':')))
  	    {
! 	      SEND_QUOTED (cwd);
! 	      SEND_STRING ("/");
  	    }
  
! 	  SEND_QUOTED (argv[i]);
! 	  SEND_STRING (" ");
  	}
      }
    else
      {
        while ((str = fgets (string, BUFSIZ, stdin)))
  	{
! 	  SEND_QUOTED (str);
  	}
!       SEND_STRING (" ");
      }
  
!   SEND_STRING ("\n");
  
!   /* Maybe wait for an answer.  */
!   if (!nowait)
      {
!       if (!eval)
!         {
!           printf ("Waiting for Emacs...");
!           needlf = 2;
!         }
!       fflush (stdout);
  
!       /* Now, wait for an answer and print any messages.  */
  
!       while ((rl = recv (s, string, BUFSIZ, 0)) > 0)
!         {
!           string[rl] = '\0';
!           if (needlf == 2)
!             printf ("\n");
!           printf ("%s", str);
!           needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
!         }
  
+       if (needlf)
+         printf ("\n");
+       fflush (stdout);
+     }
+ 
+   closesocket (s);
    return EXIT_SUCCESS;
+ 
  }
  
  \f
  #ifndef HAVE_STRERROR
  char *
Index: lib-src/makefile.w32-in
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/makefile.w32-in,v
retrieving revision 2.36
diff -c -r2.36 makefile.w32-in
*** lib-src/makefile.w32-in	28 Jul 2005 07:58:52 -0000	2.36
--- lib-src/makefile.w32-in	5 Aug 2005 01:07:33 -0000
***************
*** 19,25 ****
  #  Boston, MA 02110-1301, USA.
  #
  
! ALL	      = make-docfile hexl ctags etags movemail ebrowse
  
  .PHONY: $(ALL)
  
--- 19,25 ----
  #  Boston, MA 02110-1301, USA.
  #
  
! ALL	      = make-docfile hexl ctags etags movemail ebrowse emacsclient
  
  .PHONY: $(ALL)
  
***************
*** 34,40 ****
  #		$(BLD)/server.exe	\
  #		$(BLD)/emacstool.exe	\
  #		$(BLD)/leditcfns.exe	\
- #		$(BLD)/emacsclient.exe	\
  #		$(BLD)/cvtmail.exe	\
  #		$(BLD)/digest-doc.exe	\
  #		$(BLD)/test-distrib.exe	\
--- 34,39 ----
***************
*** 55,60 ****
--- 54,60 ----
  hexl:		$(BLD) $(BLD)/hexl.exe
  movemail:	$(BLD) $(BLD)/movemail.exe
  fakemail:	$(BLD) $(BLD)/fakemail.exe
+ emacsclient:	$(BLD) $(BLD)/emacsclient.exe
  
  GETOPTOBJS = $(BLD)/getopt.$(O) $(BLD)/getopt1.$(O)
  GETOPTDEPS = $(GETOPTOBJS) getopt.h
***************
*** 67,72 ****
--- 67,85 ----
  # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
  		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(MOVEMAILOBJS) $(WSOCK32) $(LIBS)
  
+ ECLIENT_CFLAGS =	-DWINDOWSNT -DHAVE_GETCWD -DHAVE_STRERROR -c
+ ECLIENTOBJS =	$(BLD)/emacsclient.$(O) \
+ 		$(BLD)/getopt.$(O) \
+ 		$(BLD)/getopt1.$(O) \
+ 		$(BLD)/ntlib.$(O)
+ 
+ $(BLD)/emacsclient.exe:	$(ECLIENTOBJS)
+ # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
+ 		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(LIBS)
+ 
+ $(BLD)/emacsclient.$(O):	emacsclient.c
+ 		$(CC) $(ECLIENT_CFLAGS) $(CC_OUT)$@ emacsclient.c
+ 
  ETAGSOBJ      = $(BLD)/etags.$(O) \
  		$(BLD)/getopt.$(O) \
  		$(BLD)/getopt1.$(O) \
***************
*** 76,82 ****
  $(BLD)/etags.exe: 	$(ETAGSOBJ)
  		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ETAGSOBJ) $(LIBS)
  
- 
  EBROWSEOBJ    = $(BLD)/ebrowse.$(O) \
                  $(BLD)/getopt.$(O) \
                  $(BLD)/getopt1.$(O) \
--- 89,94 ----
***************
*** 120,126 ****
  # $(BLD)/server.exe: 		$(BLD)/server.$(O)
  # $(BLD)/cvtmail.exe: 		$(BLD)/cvtmail.$(O)
  # $(BLD)/digest-doc.exe: 	$(BLD)/digest-doc.$(O)
- # $(BLD)/emacsclient.exe: 	$(BLD)/emacsclient.$(O)
  # $(BLD)/test-distrib.exe: 	$(BLD)/test-distrib.$(O)
  
  #
--- 132,137 ----
***************
*** 130,136 ****
  # as it is required by code in doc.c.
  #
  obj=    sunfns.o dosfns.o msdos.o \
! 	xterm.o xfns.o xmenu.o xselect.o xrdb.o  fringe.o image.o \
  	mac.o macterm.o macfns.o macmenu.o fontset.o \
  	w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
  	w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
--- 141,147 ----
  # as it is required by code in doc.c.
  #
  obj=    sunfns.o dosfns.o msdos.o \
! 	xterm.o xfns.o xmenu.o xselect.o xrdb.o fringe.o image.o \
  	mac.o macterm.o macfns.o macmenu.o fontset.o \
  	w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
  	w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
***************
*** 277,282 ****
--- 288,294 ----
  		$(CP) $(BLD)/ctags.exe $(INSTALL_DIR)/bin
  		$(CP) $(BLD)/hexl.exe $(INSTALL_DIR)/bin
  		$(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin
+ 		$(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin
  		- mkdir "$(INSTALL_DIR)/etc"
  		$(CP) $(DOC) $(INSTALL_DIR)/etc
  
Index: lisp/server.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/server.el,v
retrieving revision 1.104
diff -c -r1.104 server.el
*** lisp/server.el	16 Jul 2005 11:58:10 -0000	1.104
--- lisp/server.el	4 Aug 2005 15:07:58 -0000
***************
*** 82,87 ****
--- 82,103 ----
    "Emacs running as a server process."
    :group 'external)
  
+ (defcustom server-host nil
+   "The name or IP address to use as host address of the server process.
+ If set, the server accepts remote connections; otherwise it is local."
+   :group 'server
+   :type '(choice
+           (string :tag "Name or IP address")
+           (const :tag "Local" nil))
+   :version "22.1")
+ 
+ (defcustom server-file "~/.emacs.server"
+   "The server authentication file.
+ Its value will be passed through `expand-file-name'."
+   :group 'server
+   :type 'file
+   :version "22.1")
+ 
  (defcustom server-visit-hook nil
    "*Hook run when visiting a file for the Emacs server."
    :group 'server
***************
*** 100,105 ****
--- 116,124 ----
  (defvar server-process nil
    "The current server process.")
  
+ (defvar server-auth-string nil
+   "The current server authentication string.")
+ 
  (defvar server-clients nil
    "List of current server clients.
  Each element is (CLIENTID BUFFERS...) where CLIENTID is a string
***************
*** 161,194 ****
  
  (defvar server-name "server")
  
- (defvar server-socket-dir
-   (format "/tmp/emacs%d" (user-uid)))
- 
  (defun server-log (string &optional client)
    "If a *server* buffer exists, write STRING to it for logging purposes."
!   (if (get-buffer "*server*")
!       (with-current-buffer "*server*"
! 	(goto-char (point-max))
! 	(insert (current-time-string)
! 		(if client (format " %s:" client) " ")
! 		string)
! 	(or (bolp) (newline)))))
  
  (defun server-sentinel (proc msg)
!   (let ((client (assq proc server-clients)))
!     ;; Remove PROC from the list of clients.
!     (when client
!       (setq server-clients (delq client server-clients))
!       (dolist (buf (cdr client))
! 	(with-current-buffer buf
! 	  ;; Remove PROC from the clients of each buffer.
! 	  (setq server-buffer-clients (delq proc server-buffer-clients))
! 	  ;; Kill the buffer if necessary.
! 	  (when (and (null server-buffer-clients)
! 		     (or (and server-kill-new-buffers
! 			      (not server-existing-buffer))
! 			 (server-temp-file-p)))
! 	    (kill-buffer (current-buffer)))))))
    (server-log (format "Status changed to %s" (process-status proc)) proc))
  
  (defun server-select-display (display)
--- 180,213 ----
  
  (defvar server-name "server")
  
  (defun server-log (string &optional client)
    "If a *server* buffer exists, write STRING to it for logging purposes."
!   (when (get-buffer "*server*")
!     (with-current-buffer "*server*"
!       (goto-char (point-max))
!       (insert (current-time-string)
!               (if client (format " %s:" client) " ")
!               string)
!       (or (bolp) (newline)))))
  
  (defun server-sentinel (proc msg)
!   (if (eq proc server-process)
!       (ignore-errors
!         (delete-file (expand-file-name server-file)))
!     (let ((client (assq proc server-clients)))
!       ;; Remove PROC from the list of clients.
!       (when client
!         (setq server-clients (delq client server-clients))
!         (dolist (buf (cdr client))
!           (with-current-buffer buf
!             ;; Remove PROC from the clients of each buffer.
!             (setq server-buffer-clients (delq proc server-buffer-clients))
!             ;; Kill the buffer if necessary.
!             (when (and (null server-buffer-clients)
!                        (or (and server-kill-new-buffers
!                                 (not server-existing-buffer))
!                            (server-temp-file-p)))
!               (kill-buffer (current-buffer))))))))
    (server-log (format "Status changed to %s" (process-status proc)) proc))
  
  (defun server-select-display (display)
***************
*** 221,241 ****
  	    (t " ")))
     arg t t))
  
! (defun server-ensure-safe-dir (dir)
!   "Make sure DIR is a directory with no race-condition issues.
! Creates the directory if necessary and makes sure:
! - there's no symlink involved
! - it's owned by us
! - it's not readable/writable by anybody else."
!   (setq dir (directory-file-name dir))
!   (let ((attrs (file-attributes dir)))
!     (unless attrs
!       (letf (((default-file-modes) ?\700)) (make-directory dir))
!       (setq attrs (file-attributes dir)))
!     ;; Check that it's safe for use.
!     (unless (and (eq t (car attrs)) (eq (nth 2 attrs) (user-uid))
! 		 (zerop (logand ?\077 (file-modes dir))))
!       (error "The directory %s is unsafe" dir))))
  
  ;;;###autoload
  (defun server-start (&optional leave-dead)
--- 240,254 ----
  	    (t " ")))
     arg t t))
  
! (defun server-auth-string ()
!   (or server-auth-string
!       ;; If the authentication string does not exist, create it on the fly:
!       ;; it's a 64-byte string of random chars in the range `!'..`~'.
!       (setq server-auth-string
!             (loop
!                for i below 64
!                collect (+ 33 (random 94)) into auth
!                finally return (concat auth)))))
  
  ;;;###autoload
  (defun server-start (&optional leave-dead)
***************
*** 247,278 ****
  
  Prefix arg means just kill any existing server communications subprocess."
    (interactive "P")
!   ;; Make sure there is a safe directory in which to place the socket.
!   (server-ensure-safe-dir server-socket-dir)
!   ;; kill it dead!
!   (if server-process
!       (condition-case () (delete-process server-process) (error nil)))
!   ;; Delete the socket files made by previous server invocations.
!   (condition-case ()
!       (delete-file (expand-file-name server-name server-socket-dir))
!     (error nil))
    ;; If this Emacs already had a server, clear out associated status.
    (while server-clients
      (let ((buffer (nth 1 (car server-clients))))
        (server-buffer-done buffer)))
    (unless leave-dead
!     (if server-process
! 	(server-log (message "Restarting server")))
      (letf (((default-file-modes) ?\700))
        (setq server-process
  	    (make-network-process
! 	     :name "server" :family 'local :server t :noquery t
! 	     :service (expand-file-name server-name server-socket-dir)
! 	     :sentinel 'server-sentinel :filter 'server-process-filter
  	     ;; We must receive file names without being decoded.
  	     ;; Those are decoded by server-process-filter according
  	     ;; to file-name-coding-system.
! 	     :coding 'raw-text)))))
  
  ;;;###autoload
  (define-minor-mode server-mode
--- 260,301 ----
  
  Prefix arg means just kill any existing server communications subprocess."
    (interactive "P")
!   ;; Kill it dead!
!   (when server-process
!     (condition-case ()
!         (progn
!           (delete-process server-process)
!           (delete-file (expand-file-name server-file))
!           (setq server-auth-string nil))
!       (error nil)))
    ;; If this Emacs already had a server, clear out associated status.
    (while server-clients
      (let ((buffer (nth 1 (car server-clients))))
        (server-buffer-done buffer)))
    (unless leave-dead
!     (when server-process
!       (server-log (message "Restarting server")))
      (letf (((default-file-modes) ?\700))
        (setq server-process
  	    (make-network-process
!              :name server-name :noquery t :server t
!              :service t :host (or server-host 'local)
!              :filter 'server-process-filter :sentinel 'server-sentinel
!              :plist '(:authenticated nil)
  	     ;; We must receive file names without being decoded.
  	     ;; Those are decoded by server-process-filter according
  	     ;; to file-name-coding-system.
! 	     :coding 'raw-text))
!       (unless server-process
!         (error "Could not start server process"))
!       ;; We must create the server info file, or no one will be able
to contact us
!       (with-temp-file (expand-file-name server-file)
!         (set-buffer-multibyte nil)
!         (setq buffer-file-coding-system 'no-conversion)
!         (insert (format-network-address (cadr (memq :local
!                                                     (process-contact
server-process
!                                                                      t))))
!                 "\n" (server-auth-string))))))
  
  ;;;###autoload
  (define-minor-mode server-mode
***************
*** 287,300 ****
    ;; nothing if there is one (for multiple Emacs sessions)?
    (server-start (not server-mode)))
  \f
! (defun server-process-filter (proc string)
    "Process a request from the server to edit some files.
  PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
    (server-log string proc)
!   (let ((prev (process-get proc 'previous-string)))
      (when prev
        (setq string (concat prev string))
!       (process-put proc 'previous-string nil)))
    ;; If the input is multiple lines,
    ;; process each line individually.
    (while (string-match "\n" string)
--- 310,334 ----
    ;; nothing if there is one (for multiple Emacs sessions)?
    (server-start (not server-mode)))
  \f
! (defun* server-process-filter (proc string)
    "Process a request from the server to edit some files.
  PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
+   ;; First things first: let's check the authentication
+   (unless (process-get proc :authenticated)
+     (if (and (string-match "-auth \\(.*?\\)\n" string)
+              (string= (match-string 1 string) server-auth-string))
+         (progn
+           (setq string (substring string (match-end 0)))
+           (process-put proc :authenticated t)
+           (server-log "Authentication successful" proc))
+       (server-log "Authentication failed" proc)
+       (delete-process proc)
+       (return-from server-process-filter)))
    (server-log string proc)
!   (let ((prev (process-get proc :previous-string)))
      (when prev
        (setq string (concat prev string))
!       (process-put proc :previous-string nil)))
    ;; If the input is multiple lines,
    ;; process each line individually.
    (while (string-match "\n" string)
***************
*** 377,383 ****
        (if tmp-frame (delete-frame tmp-frame))))
    ;; Save for later any partial line that remains.
    (when (> (length string) 0)
!     (process-put proc 'previous-string string)))
  
  (defun server-goto-line-column (file-line-col)
    (goto-line (nth 1 file-line-col))
--- 411,417 ----
        (if tmp-frame (delete-frame tmp-frame))))
    ;; Save for later any partial line that remains.
    (when (> (length string) 0)
!     (process-put proc :previous-string string)))
  
  (defun server-goto-line-column (file-line-col)
    (goto-line (nth 1 file-line-col))

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

* Re: w32 does not have emacsclient/server
  2005-08-05  1:43             ` Juanma Barranquero
@ 2005-08-05  7:59               ` Juanma Barranquero
  2005-08-05  9:02                 ` Eli Zaretskii
  2005-08-05 11:06                 ` Juanma Barranquero
  2005-08-08 23:49               ` Stefan Monnier
  1 sibling, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-05  7:59 UTC (permalink / raw)
  Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

The same patch, but attached (I hate the things Gmail does to patches).

-- 
                    /L/e/k/t/u

[-- Attachment #2: server.patch --]
[-- Type: application/octet-stream, Size: 35905 bytes --]

Index: lib-src/emacsclient.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.74
diff -c -r1.74 emacsclient.c
*** lib-src/emacsclient.c	4 Jul 2005 15:24:11 -0000	1.74
--- lib-src/emacsclient.c	5 Aug 2005 00:33:54 -0000
***************
*** 20,25 ****
--- 20,28 ----
  Boston, MA 02110-1301, USA.  */
  
  
+ #define AUTH_STRING_LENGTH   64
+ #define SEND_BUFFER_SIZE   4096
+ 
  #define NO_SHORTNAMES
  
  #ifdef HAVE_CONFIG_H
***************
*** 30,45 ****
  
  #include <ctype.h>
  #include <stdio.h>
! #include <getopt.h>
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
  
  #ifdef VMS
! # include "vms-pwd.h"
  #else
! # include <pwd.h>
  #endif /* not VMS */
  
  char *getenv (), *getwd ();
  char *(getcwd) ();
--- 33,53 ----
  
  #include <ctype.h>
  #include <stdio.h>
! #include "getopt.h"
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
  
+ #ifdef WINDOWSNT
+ #include <winsock2.h>
+ #else /* not WINDOWSNT */
+ #include <sys/socket.h>
  #ifdef VMS
! #include "vms-pwd.h"
  #else
! #include <pwd.h>
  #endif /* not VMS */
+ #endif /* not WINDOWSNT */
  
  char *getenv (), *getwd ();
  char *(getcwd) ();
***************
*** 47,52 ****
--- 55,72 ----
  #ifndef VERSION
  #define VERSION "unspecified"
  #endif
+ 
+ #define SEND_STRING(data) (send_to_emacs (s, (data), 0))
+ #define SEND_QUOTED(data) (quote_file_name (s, (data)))
+ 
+ #ifndef EXIT_SUCCESS
+ #define EXIT_SUCCESS 0
+ #endif
+ 
+ #ifndef EXIT_FAILURE
+ #define EXIT_FAILURE 1
+ #endif
+ 
  \f
  /* Name used to invoke this program.  */
  char *progname;
***************
*** 61,71 ****
  char *display = NULL;
  
  /* If non-NULL, the name of an editor to fallback to if the server
!    is not running.  --alternate-editor.   */
! const char * alternate_editor = NULL;
  
! /* If non-NULL, the filename of the UNIX socket.  */
! char *socket_name = NULL;
  
  void print_help_and_exit ();
  
--- 81,96 ----
  char *display = NULL;
  
  /* If non-NULL, the name of an editor to fallback to if the server
!    is not running.  --alternate-editor.  */
! const char *alternate_editor = NULL;
  
! /* If non-NULL, the filename to use as configuration and
!    authentication file.  --server-file.  */
! const char *server_file = NULL;
! 
! /* Buffer to accumulate data to send.  */
! char send_buffer[SEND_BUFFER_SIZE+1];
! int sblen = 0;
  
  void print_help_and_exit ();
  
***************
*** 76,82 ****
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
!   { "socket-name",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
--- 101,107 ----
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
!   { "server-file",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
***************
*** 90,95 ****
--- 115,121 ----
       char **argv;
  {
    alternate_editor = getenv ("ALTERNATE_EDITOR");
+   server_file = getenv("EMACS_SERVER_FILE");
  
    while (1)
      {
***************
*** 111,117 ****
  	  break;
  
  	case 's':
! 	  socket_name = optarg;
  	  break;
  
  	case 'd':
--- 137,143 ----
  	  break;
  
  	case 's':
! 	  server_file = optarg;
  	  break;
  
  	case 'd':
***************
*** 157,164 ****
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
! -s, --socket-name=FILENAME\n\
!                         Set the filename of the UNIX socket for communication\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  \n\
--- 183,190 ----
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
! -s, --server-file=FILENAME\n\
!                         Server configuration and authentication file\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  \n\
***************
*** 166,179 ****
    exit (EXIT_SUCCESS);
  }
  
  /* In NAME, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.  */
  
  void
! quote_file_name (name, stream)
       char *name;
-      FILE *stream;
  {
    char *copy = (char *) malloc (strlen (name) * 2 + 1);
    char *p, *q;
--- 192,242 ----
    exit (EXIT_SUCCESS);
  }
  
+ \f
+ /* Let's send the data to Emacs when either
+    - the data ends in "\n", or
+    - the buffer is full (but this shouldn't happen)
+    Otherwise, we just accumulate it.  */
+ 
+ void send_to_emacs (s, data, force)
+      SOCKET s;
+      char *data;
+      int force;
+ {
+   int dlen = strlen (data);
+   int sent;
+ 
+   while (force || (dlen + sblen >= SEND_BUFFER_SIZE))
+     {
+       sent = send (s, send_buffer, sblen, 0);
+       if (sent != sblen)
+         strcpy (send_buffer, &send_buffer[sent]);
+ 
+       sblen -= sent;
+ 
+       if (force)
+         /* Just the first time around.  */
+         force = 0;
+     }
+ 
+   if (dlen)
+     {
+       strcpy (&send_buffer[sblen], data);
+       sblen += dlen;
+     }
+ 
+   if (sblen && (send_buffer[sblen-1] == '\n'))
+     send_to_emacs (s, "\0", 1);
+ }
+ 
  /* In NAME, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.  */
  
  void
! quote_file_name (s, name)
!      SOCKET s;
       char *name;
  {
    char *copy = (char *) malloc (strlen (name) * 2 + 1);
    char *p, *q;
***************
*** 203,227 ****
      }
    *q++ = 0;
  
!   fprintf (stream, "%s", copy);
  
    free (copy);
  }
  
- /* Like malloc but get fatal error if memory is exhausted.  */
- 
- long *
- xmalloc (size)
-      unsigned int size;
- {
-   long *result = (long *) malloc (size);
-   if (result == NULL)
-   {
-     perror ("malloc");
-     exit (EXIT_FAILURE);
-   }
-   return result;
- }
  \f
  /*
    Try to run a different command, or --if no alternate editor is
--- 266,276 ----
      }
    *q++ = 0;
  
!   SEND_STRING (copy);
  
    free (copy);
  }
  
  \f
  /*
    Try to run a different command, or --if no alternate editor is
***************
*** 244,459 ****
      }
  }
  
- 
  \f
- #if !defined (HAVE_SOCKETS) || defined (NO_SOCKETS_IN_FILE_SYSTEM)
  
! int
! main (argc, argv)
       int argc;
!      char **argv;
  {
!   fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
! 	   argv[0]);
!   fprintf (stderr, "on systems with Berkeley sockets.\n");
  
!   fail (argc, argv);
! }
  
! #else /* HAVE_SOCKETS */
  
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/un.h>
! #include <sys/stat.h>
! #include <errno.h>
  
! extern char *strerror ();
! extern int errno;
  
! /* Three possibilities:
!    2 - can't be `stat'ed		(sets errno)
!    1 - isn't owned by us
!    0 - success: none of the above */
  
! static int
! socket_status (socket_name)
!      char *socket_name;
  {
!   struct stat statbfr;
  
!   if (stat (socket_name, &statbfr) == -1)
!     return 2;
  
!   if (statbfr.st_uid != geteuid ())
!     return 1;
  
!   return 0;
  }
  
! int
! main (argc, argv)
!      int argc;
!      char **argv;
  {
!   int s, i, needlf = 0;
!   FILE *out, *in;
!   struct sockaddr_un server;
!   char *cwd, *str;
!   char string[BUFSIZ];
! 
!   progname = argv[0];
  
!   /* Process options.  */
!   decode_options (argc, argv);
  
!   if ((argc - optind < 1) && !eval)
      {
!       fprintf (stderr, "%s: file name or argument required\n", progname);
!       fprintf (stderr, "Try `%s --help' for more information\n", progname);
        exit (EXIT_FAILURE);
      }
  
!   /*
!    * Open up an AF_UNIX socket in this person's home directory
!    */
  
!   if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
      {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("socket");
!       fail (argc, argv);
      }
  
!   server.sun_family = AF_UNIX;
  
!   {
!     int sock_status = 0;
!     int default_sock = !socket_name;
!     int saved_errno;
!     char *server_name = "server";
! 
!     if (socket_name && !index (socket_name, '/') && !index (socket_name, '\\'))
!       { /* socket_name is a file name component.  */
! 	server_name = socket_name;
! 	socket_name = NULL;
! 	default_sock = 1;	/* Try both UIDs.  */
!       }
! 
!     if (default_sock)
!       {
! 	socket_name = alloca (100 + strlen (server_name));
! 	sprintf (socket_name, "/tmp/emacs%d/%s",
! 		 (int) geteuid (), server_name);
!       }
! 
!     if (strlen (socket_name) < sizeof (server.sun_path))
!       strcpy (server.sun_path, socket_name);
!     else
!       {
! 	fprintf (stderr, "%s: socket-name %s too long",
! 		 argv[0], socket_name);
! 	exit (EXIT_FAILURE);
!       }
! 
!     /* See if the socket exists, and if it's owned by us. */
!     sock_status = socket_status (server.sun_path);
!     saved_errno = errno;
!     if (sock_status && default_sock)
!       {
! 	/* Failing that, see if LOGNAME or USER exist and differ from
! 	   our euid.  If so, look for a socket based on the UID
! 	   associated with the name.  This is reminiscent of the logic
! 	   that init_editfns uses to set the global Vuser_full_name.  */
! 
! 	char *user_name = (char *) getenv ("LOGNAME");
! 
! 	if (!user_name)
! 	  user_name = (char *) getenv ("USER");
! 
! 	if (user_name)
! 	  {
! 	    struct passwd *pw = getpwnam (user_name);
! 
! 	    if (pw && (pw->pw_uid != geteuid ()))
! 	      {
! 		/* We're running under su, apparently. */
! 		socket_name = alloca (100 + strlen (server_name));
! 		sprintf (socket_name, "/tmp/emacs%d/%s",
! 			 (int) pw->pw_uid, server_name);
! 
! 		if (strlen (socket_name) < sizeof (server.sun_path))
! 		  strcpy (server.sun_path, socket_name);
! 		else
! 		  {
! 		    fprintf (stderr, "%s: socket-name %s too long",
! 			     argv[0], socket_name);
! 		    exit (EXIT_FAILURE);
! 		  }
! 
! 		sock_status = socket_status (server.sun_path);
! 		saved_errno = errno;
! 	      }
! 	    else
! 	      errno = saved_errno;
! 	  }
!       }
! 
!      switch (sock_status)
!        {
!        case 1:
! 	 /* There's a socket, but it isn't owned by us.  This is OK if
! 	    we are root. */
! 	 if (0 != geteuid ())
! 	   {
! 	     fprintf (stderr, "%s: Invalid socket owner\n", argv[0]);
! 	     fail (argc, argv);
! 	   }
! 	 break;
! 
!        case 2:
! 	 /* `stat' failed */
! 	 if (saved_errno == ENOENT)
! 	   fprintf (stderr,
! 		    "%s: can't find socket; have you started the server?\n\
! To start the server in Emacs, type \"M-x server-start\".\n",
! 		    argv[0]);
! 	 else
! 	   fprintf (stderr, "%s: can't stat %s: %s\n",
! 		    argv[0], server.sun_path, strerror (saved_errno));
! 	 fail (argc, argv);
! 	 break;
!        }
!   }
  
!   if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2)
!       < 0)
!     {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("connect");
!       fail (argc, argv);
!     }
  
!   /* We use the stream OUT to send our command to the server.  */
!   if ((out = fdopen (s, "r+")) == NULL)
      {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("fdopen");
!       fail (argc, argv);
      }
  
!   /* We use the stream IN to read the response.
!      We used to use just one stream for both output and input
!      on the socket, but reversing direction works nonportably:
!      on some systems, the output appears as the first input;
!      on other systems it does not.  */
!   if ((in = fdopen (s, "r+")) == NULL)
      {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("fdopen");
!       fail (argc, argv);
      }
  
  #ifdef HAVE_GETCWD
    cwd = getcwd (string, sizeof string);
  #else
--- 293,475 ----
      }
  }
  
  \f
  
! /* Process options and check some sane defaults.  */
! void process_options (argc, argv)
       int argc;
!      char *argv[];
  {
!   decode_options (argc, argv);
  
!   if (!server_file)
!     {
!       fprintf (stderr, "%s: server configuration file required\n", progname);
!       goto error;
!     }
  
!   if ((argc - optind < 1) && !eval)
!     {
!       fprintf (stderr, "%s: file name or argument required\n", progname);
!       goto error;
!     }
  
!   return;
  
!  error:
  
!   fprintf (stderr, "Try `%s --help' for more information\n", progname);
!   exit (EXIT_FAILURE);
! }
  
! #ifdef WINDOWSNT
! /* Wrapper to make WSACleanup a cdecl, as required by atexit().  */
! void close_winsock ()
  {
!   WSACleanup();
! }
! #endif /* WINDOWSNT */
  
! void initialize_sockets ()
! {
! #ifdef WINDOWSNT
! 
!   /* Initialize the WinSock2 library.  */
!   WSADATA wsaData;
  
!   if (WSAStartup (MAKEWORD (2, 0), &wsaData))
!     {
!       fprintf (stderr, "%s: error initializing WinSock2", progname);
!       exit (EXIT_FAILURE);
!     }
  
!   atexit (close_winsock);
! #endif
  }
  
! /*
!  * Read the information needed to set up the comm channel with
!  * the Emacs server: host, port and authentication string.
!  */
! void get_server_config (server, authentication)
!      struct sockaddr_in *server;
!      char *authentication;
  {
!   FILE *config;
!   char dotted[32];
!   char *port;
  
!   if (! (config = fopen (server_file, "rb")))
!     {
!       fprintf (stderr, "%s: cannot read configuration file %s",
!                progname, server_file);
!       exit (EXIT_FAILURE);
!     }
  
!   if (fgets (dotted, sizeof dotted, config)
!       && (port = strchr (dotted, ':')))
      {
!       *port++ = '\0';
!     }
!   else
!     {
!       fprintf (stderr, "%s: invalid configuration info", progname);
        exit (EXIT_FAILURE);
      }
  
!   server->sin_family = AF_INET;
!   server->sin_addr.s_addr = inet_addr (dotted);
!   server->sin_port = htons (atoi (port));
  
!   if (! fread (authentication, AUTH_STRING_LENGTH, 1, config))
      {
!       fprintf (stderr, "%s: cannot read authentication info", progname);
!       exit (EXIT_FAILURE);
      }
  
!   fclose (config);
! }
  
! /*
!  * Perform all required initialization; at the end either the socket
!  * is available and correctly configured, or we've finished with an
!  * error status so the main program can try the alternate editor.
!  */
! SOCKET
! set_socket ()
! {
!   SOCKET s;
!   struct sockaddr_in server;
!   unsigned long c_arg = 0;
!   struct linger l_arg = {1, 1};
!   char auth_string[AUTH_STRING_LENGTH+1];
  
!   initialize_sockets();
! 
!   get_server_config (&server, auth_string);
  
!   /*
!    * Open up an AF_INET socket
!    */
!   if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
      {
!       fprintf (stderr, "%s: ", progname);
!       perror ("socket");
!       return INVALID_SOCKET;
      }
  
!   /*
!    * Set up the socket
!    */
!   if (connect (s, (struct sockaddr *) &server, sizeof server) < 0)
      {
!       fprintf (stderr, "%s: ", progname);
!       perror ("connect");
!       return INVALID_SOCKET;
      }
  
+   /*
+    * Force socket to be blocking and SO_LINGER
+    */
+   ioctlsocket (s, FIONBIO, &c_arg);
+   setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg);
+ 
+   /*
+    * Now, let's send the authentication
+    */
+   auth_string[AUTH_STRING_LENGTH] = '\0';
+   SEND_STRING ("-auth ");
+   SEND_STRING (auth_string);
+   SEND_STRING ("\n");
+ 
+   return s;
+ }
+ 
+ \f
+ #include <sys/types.h>
+ 
+ #include <sys/stat.h>
+ #include <errno.h>
+ 
+ extern char *strerror ();
+ extern int errno;
+ 
+ int
+ main (argc, argv)
+      int argc;
+      char **argv;
+ {
+   SOCKET s;
+   int i, rl, needlf = 0;
+   char *cwd, *str;
+   char string[BUFSIZ+1];
+ 
+   progname = argv[0];
+   process_options (argc, argv);
+ 
+   if ((s = set_socket ()) == INVALID_SOCKET)
+     fail (argc, argv);
+ 
  #ifdef HAVE_GETCWD
    cwd = getcwd (string, sizeof string);
  #else
***************
*** 464,488 ****
        /* getwd puts message in STRING if it fails.  */
  
  #ifdef HAVE_GETCWD
!       fprintf (stderr, "%s: %s (%s)\n", argv[0],
  	       "Cannot get current working directory", strerror (errno));
  #else
!       fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno));
  #endif
        fail (argc, argv);
      }
  
    if (nowait)
!     fprintf (out, "-nowait ");
  
    if (eval)
!     fprintf (out, "-eval ");
  
    if (display)
      {
!       fprintf (out, "-display ");
!       quote_file_name (display, out);
!       fprintf (out, " ");
      }
  
    if ((argc - optind > 0))
--- 480,504 ----
        /* getwd puts message in STRING if it fails.  */
  
  #ifdef HAVE_GETCWD
!       fprintf (stderr, "%s: %s (%s)\n", progname,
  	       "Cannot get current working directory", strerror (errno));
  #else
!       fprintf (stderr, "%s: %s (%s)\n", progname, string, strerror (errno));
  #endif
        fail (argc, argv);
      }
  
    if (nowait)
!     SEND_STRING ("-nowait ");
  
    if (eval)
!     SEND_STRING ("-eval ");
  
    if (display)
      {
!       SEND_STRING ("-display ");
!       SEND_QUOTED (display);
!       SEND_STRING (" ");
      }
  
    if ((argc - optind > 0))
***************
*** 497,556 ****
  	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
  	      if (*p != 0)
  		{
! 		  quote_file_name (cwd, out);
! 		  fprintf (out, "/");
  		}
  	    }
! 	  else if (*argv[i] != '/')
  	    {
! 	      quote_file_name (cwd, out);
! 	      fprintf (out, "/");
  	    }
  
! 	  quote_file_name (argv[i], out);
! 	  fprintf (out, " ");
  	}
      }
    else
      {
        while ((str = fgets (string, BUFSIZ, stdin)))
  	{
! 	  quote_file_name (str, out);
  	}
!       fprintf (out, " ");
      }
  
!   fprintf (out, "\n");
!   fflush (out);
  
!   /* Maybe wait for an answer.   */
!   if (nowait)
!     return EXIT_SUCCESS;
! 
!   if (!eval)
      {
!       printf ("Waiting for Emacs...");
!       needlf = 2;
!     }
!   fflush (stdout);
  
!   /* Now, wait for an answer and print any messages.  */
!   while ((str = fgets (string, BUFSIZ, in)))
!     {
!       if (needlf == 2)
! 	printf ("\n");
!       printf ("%s", str);
!       needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
!     }
  
!   if (needlf)
!     printf ("\n");
!   fflush (stdout);
  
    return EXIT_SUCCESS;
  }
  
- #endif /* HAVE_SOCKETS */
  \f
  #ifndef HAVE_STRERROR
  char *
--- 513,578 ----
  	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
  	      if (*p != 0)
  		{
! 		  SEND_QUOTED (cwd);
! 		  SEND_STRING ("/");
  		}
  	    }
!           /* Absolute paths can also start with backslash or drive letters.  */
!           else if ((*argv[i] != '/')
!                     && (*argv[i] != '\\')
!                     && (!islower (tolower (*argv[i]))
!                         || (argv[i][1] != ':')))
  	    {
! 	      SEND_QUOTED (cwd);
! 	      SEND_STRING ("/");
  	    }
  
! 	  SEND_QUOTED (argv[i]);
! 	  SEND_STRING (" ");
  	}
      }
    else
      {
        while ((str = fgets (string, BUFSIZ, stdin)))
  	{
! 	  SEND_QUOTED (str);
  	}
!       SEND_STRING (" ");
      }
  
!   SEND_STRING ("\n");
  
!   /* Maybe wait for an answer.  */
!   if (!nowait)
      {
!       if (!eval)
!         {
!           printf ("Waiting for Emacs...");
!           needlf = 2;
!         }
!       fflush (stdout);
  
!       /* Now, wait for an answer and print any messages.  */
  
!       while ((rl = recv (s, string, BUFSIZ, 0)) > 0)
!         {
!           string[rl] = '\0';
!           if (needlf == 2)
!             printf ("\n");
!           printf ("%s", str);
!           needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
!         }
  
+       if (needlf)
+         printf ("\n");
+       fflush (stdout);
+     }
+ 
+   closesocket (s);
    return EXIT_SUCCESS;
+ 
  }
  
  \f
  #ifndef HAVE_STRERROR
  char *
Index: lib-src/makefile.w32-in
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/makefile.w32-in,v
retrieving revision 2.36
diff -c -r2.36 makefile.w32-in
*** lib-src/makefile.w32-in	28 Jul 2005 07:58:52 -0000	2.36
--- lib-src/makefile.w32-in	5 Aug 2005 01:07:33 -0000
***************
*** 19,25 ****
  #  Boston, MA 02110-1301, USA.
  #
  
! ALL	      = make-docfile hexl ctags etags movemail ebrowse
  
  .PHONY: $(ALL)
  
--- 19,25 ----
  #  Boston, MA 02110-1301, USA.
  #
  
! ALL	      = make-docfile hexl ctags etags movemail ebrowse emacsclient
  
  .PHONY: $(ALL)
  
***************
*** 34,40 ****
  #		$(BLD)/server.exe	\
  #		$(BLD)/emacstool.exe	\
  #		$(BLD)/leditcfns.exe	\
- #		$(BLD)/emacsclient.exe	\
  #		$(BLD)/cvtmail.exe	\
  #		$(BLD)/digest-doc.exe	\
  #		$(BLD)/test-distrib.exe	\
--- 34,39 ----
***************
*** 55,60 ****
--- 54,60 ----
  hexl:		$(BLD) $(BLD)/hexl.exe
  movemail:	$(BLD) $(BLD)/movemail.exe
  fakemail:	$(BLD) $(BLD)/fakemail.exe
+ emacsclient:	$(BLD) $(BLD)/emacsclient.exe
  
  GETOPTOBJS = $(BLD)/getopt.$(O) $(BLD)/getopt1.$(O)
  GETOPTDEPS = $(GETOPTOBJS) getopt.h
***************
*** 67,72 ****
--- 67,85 ----
  # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
  		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(MOVEMAILOBJS) $(WSOCK32) $(LIBS)
  
+ ECLIENT_CFLAGS =	-DWINDOWSNT -DHAVE_GETCWD -DHAVE_STRERROR -c
+ ECLIENTOBJS =	$(BLD)/emacsclient.$(O) \
+ 		$(BLD)/getopt.$(O) \
+ 		$(BLD)/getopt1.$(O) \
+ 		$(BLD)/ntlib.$(O)
+ 
+ $(BLD)/emacsclient.exe:	$(ECLIENTOBJS)
+ # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
+ 		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(LIBS)
+ 
+ $(BLD)/emacsclient.$(O):	emacsclient.c
+ 		$(CC) $(ECLIENT_CFLAGS) $(CC_OUT)$@ emacsclient.c
+ 
  ETAGSOBJ      = $(BLD)/etags.$(O) \
  		$(BLD)/getopt.$(O) \
  		$(BLD)/getopt1.$(O) \
***************
*** 76,82 ****
  $(BLD)/etags.exe: 	$(ETAGSOBJ)
  		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ETAGSOBJ) $(LIBS)
  
- 
  EBROWSEOBJ    = $(BLD)/ebrowse.$(O) \
                  $(BLD)/getopt.$(O) \
                  $(BLD)/getopt1.$(O) \
--- 89,94 ----
***************
*** 120,126 ****
  # $(BLD)/server.exe: 		$(BLD)/server.$(O)
  # $(BLD)/cvtmail.exe: 		$(BLD)/cvtmail.$(O)
  # $(BLD)/digest-doc.exe: 	$(BLD)/digest-doc.$(O)
- # $(BLD)/emacsclient.exe: 	$(BLD)/emacsclient.$(O)
  # $(BLD)/test-distrib.exe: 	$(BLD)/test-distrib.$(O)
  
  #
--- 132,137 ----
***************
*** 130,136 ****
  # as it is required by code in doc.c.
  #
  obj=    sunfns.o dosfns.o msdos.o \
! 	xterm.o xfns.o xmenu.o xselect.o xrdb.o  fringe.o image.o \
  	mac.o macterm.o macfns.o macmenu.o fontset.o \
  	w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
  	w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
--- 141,147 ----
  # as it is required by code in doc.c.
  #
  obj=    sunfns.o dosfns.o msdos.o \
! 	xterm.o xfns.o xmenu.o xselect.o xrdb.o fringe.o image.o \
  	mac.o macterm.o macfns.o macmenu.o fontset.o \
  	w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
  	w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
***************
*** 277,282 ****
--- 288,294 ----
  		$(CP) $(BLD)/ctags.exe $(INSTALL_DIR)/bin
  		$(CP) $(BLD)/hexl.exe $(INSTALL_DIR)/bin
  		$(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin
+ 		$(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin
  		- mkdir "$(INSTALL_DIR)/etc"
  		$(CP) $(DOC) $(INSTALL_DIR)/etc
  
Index: lisp/server.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/server.el,v
retrieving revision 1.104
diff -c -r1.104 server.el
*** lisp/server.el	16 Jul 2005 11:58:10 -0000	1.104
--- lisp/server.el	4 Aug 2005 15:07:58 -0000
***************
*** 82,87 ****
--- 82,103 ----
    "Emacs running as a server process."
    :group 'external)
  
+ (defcustom server-host nil
+   "The name or IP address to use as host address of the server process.
+ If set, the server accepts remote connections; otherwise it is local."
+   :group 'server
+   :type '(choice
+           (string :tag "Name or IP address")
+           (const :tag "Local" nil))
+   :version "22.1")
+ 
+ (defcustom server-file "~/.emacs.server"
+   "The server authentication file.
+ Its value will be passed through `expand-file-name'."
+   :group 'server
+   :type 'file
+   :version "22.1")
+ 
  (defcustom server-visit-hook nil
    "*Hook run when visiting a file for the Emacs server."
    :group 'server
***************
*** 100,105 ****
--- 116,124 ----
  (defvar server-process nil
    "The current server process.")
  
+ (defvar server-auth-string nil
+   "The current server authentication string.")
+ 
  (defvar server-clients nil
    "List of current server clients.
  Each element is (CLIENTID BUFFERS...) where CLIENTID is a string
***************
*** 161,194 ****
  
  (defvar server-name "server")
  
- (defvar server-socket-dir
-   (format "/tmp/emacs%d" (user-uid)))
- 
  (defun server-log (string &optional client)
    "If a *server* buffer exists, write STRING to it for logging purposes."
!   (if (get-buffer "*server*")
!       (with-current-buffer "*server*"
! 	(goto-char (point-max))
! 	(insert (current-time-string)
! 		(if client (format " %s:" client) " ")
! 		string)
! 	(or (bolp) (newline)))))
  
  (defun server-sentinel (proc msg)
!   (let ((client (assq proc server-clients)))
!     ;; Remove PROC from the list of clients.
!     (when client
!       (setq server-clients (delq client server-clients))
!       (dolist (buf (cdr client))
! 	(with-current-buffer buf
! 	  ;; Remove PROC from the clients of each buffer.
! 	  (setq server-buffer-clients (delq proc server-buffer-clients))
! 	  ;; Kill the buffer if necessary.
! 	  (when (and (null server-buffer-clients)
! 		     (or (and server-kill-new-buffers
! 			      (not server-existing-buffer))
! 			 (server-temp-file-p)))
! 	    (kill-buffer (current-buffer)))))))
    (server-log (format "Status changed to %s" (process-status proc)) proc))
  
  (defun server-select-display (display)
--- 180,213 ----
  
  (defvar server-name "server")
  
  (defun server-log (string &optional client)
    "If a *server* buffer exists, write STRING to it for logging purposes."
!   (when (get-buffer "*server*")
!     (with-current-buffer "*server*"
!       (goto-char (point-max))
!       (insert (current-time-string)
!               (if client (format " %s:" client) " ")
!               string)
!       (or (bolp) (newline)))))
  
  (defun server-sentinel (proc msg)
!   (if (eq proc server-process)
!       (ignore-errors
!         (delete-file (expand-file-name server-file)))
!     (let ((client (assq proc server-clients)))
!       ;; Remove PROC from the list of clients.
!       (when client
!         (setq server-clients (delq client server-clients))
!         (dolist (buf (cdr client))
!           (with-current-buffer buf
!             ;; Remove PROC from the clients of each buffer.
!             (setq server-buffer-clients (delq proc server-buffer-clients))
!             ;; Kill the buffer if necessary.
!             (when (and (null server-buffer-clients)
!                        (or (and server-kill-new-buffers
!                                 (not server-existing-buffer))
!                            (server-temp-file-p)))
!               (kill-buffer (current-buffer))))))))
    (server-log (format "Status changed to %s" (process-status proc)) proc))
  
  (defun server-select-display (display)
***************
*** 221,241 ****
  	    (t " ")))
     arg t t))
  
! (defun server-ensure-safe-dir (dir)
!   "Make sure DIR is a directory with no race-condition issues.
! Creates the directory if necessary and makes sure:
! - there's no symlink involved
! - it's owned by us
! - it's not readable/writable by anybody else."
!   (setq dir (directory-file-name dir))
!   (let ((attrs (file-attributes dir)))
!     (unless attrs
!       (letf (((default-file-modes) ?\700)) (make-directory dir))
!       (setq attrs (file-attributes dir)))
!     ;; Check that it's safe for use.
!     (unless (and (eq t (car attrs)) (eq (nth 2 attrs) (user-uid))
! 		 (zerop (logand ?\077 (file-modes dir))))
!       (error "The directory %s is unsafe" dir))))
  
  ;;;###autoload
  (defun server-start (&optional leave-dead)
--- 240,254 ----
  	    (t " ")))
     arg t t))
  
! (defun server-auth-string ()
!   (or server-auth-string
!       ;; If the authentication string does not exist, create it on the fly:
!       ;; it's a 64-byte string of random chars in the range `!'..`~'.
!       (setq server-auth-string
!             (loop
!                for i below 64
!                collect (+ 33 (random 94)) into auth
!                finally return (concat auth)))))
  
  ;;;###autoload
  (defun server-start (&optional leave-dead)
***************
*** 247,278 ****
  
  Prefix arg means just kill any existing server communications subprocess."
    (interactive "P")
!   ;; Make sure there is a safe directory in which to place the socket.
!   (server-ensure-safe-dir server-socket-dir)
!   ;; kill it dead!
!   (if server-process
!       (condition-case () (delete-process server-process) (error nil)))
!   ;; Delete the socket files made by previous server invocations.
!   (condition-case ()
!       (delete-file (expand-file-name server-name server-socket-dir))
!     (error nil))
    ;; If this Emacs already had a server, clear out associated status.
    (while server-clients
      (let ((buffer (nth 1 (car server-clients))))
        (server-buffer-done buffer)))
    (unless leave-dead
!     (if server-process
! 	(server-log (message "Restarting server")))
      (letf (((default-file-modes) ?\700))
        (setq server-process
  	    (make-network-process
! 	     :name "server" :family 'local :server t :noquery t
! 	     :service (expand-file-name server-name server-socket-dir)
! 	     :sentinel 'server-sentinel :filter 'server-process-filter
  	     ;; We must receive file names without being decoded.
  	     ;; Those are decoded by server-process-filter according
  	     ;; to file-name-coding-system.
! 	     :coding 'raw-text)))))
  
  ;;;###autoload
  (define-minor-mode server-mode
--- 260,301 ----
  
  Prefix arg means just kill any existing server communications subprocess."
    (interactive "P")
!   ;; Kill it dead!
!   (when server-process
!     (condition-case ()
!         (progn
!           (delete-process server-process)
!           (delete-file (expand-file-name server-file))
!           (setq server-auth-string nil))
!       (error nil)))
    ;; If this Emacs already had a server, clear out associated status.
    (while server-clients
      (let ((buffer (nth 1 (car server-clients))))
        (server-buffer-done buffer)))
    (unless leave-dead
!     (when server-process
!       (server-log (message "Restarting server")))
      (letf (((default-file-modes) ?\700))
        (setq server-process
  	    (make-network-process
!              :name server-name :noquery t :server t
!              :service t :host (or server-host 'local)
!              :filter 'server-process-filter :sentinel 'server-sentinel
!              :plist '(:authenticated nil)
  	     ;; We must receive file names without being decoded.
  	     ;; Those are decoded by server-process-filter according
  	     ;; to file-name-coding-system.
! 	     :coding 'raw-text))
!       (unless server-process
!         (error "Could not start server process"))
!       ;; We must create the server info file, or no one will be able to contact us
!       (with-temp-file (expand-file-name server-file)
!         (set-buffer-multibyte nil)
!         (setq buffer-file-coding-system 'no-conversion)
!         (insert (format-network-address (cadr (memq :local
!                                                     (process-contact server-process
!                                                                      t))))
!                 "\n" (server-auth-string))))))
  
  ;;;###autoload
  (define-minor-mode server-mode
***************
*** 287,300 ****
    ;; nothing if there is one (for multiple Emacs sessions)?
    (server-start (not server-mode)))
  \f
! (defun server-process-filter (proc string)
    "Process a request from the server to edit some files.
  PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
    (server-log string proc)
!   (let ((prev (process-get proc 'previous-string)))
      (when prev
        (setq string (concat prev string))
!       (process-put proc 'previous-string nil)))
    ;; If the input is multiple lines,
    ;; process each line individually.
    (while (string-match "\n" string)
--- 310,334 ----
    ;; nothing if there is one (for multiple Emacs sessions)?
    (server-start (not server-mode)))
  \f
! (defun* server-process-filter (proc string)
    "Process a request from the server to edit some files.
  PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
+   ;; First things first: let's check the authentication
+   (unless (process-get proc :authenticated)
+     (if (and (string-match "-auth \\(.*?\\)\n" string)
+              (string= (match-string 1 string) server-auth-string))
+         (progn
+           (setq string (substring string (match-end 0)))
+           (process-put proc :authenticated t)
+           (server-log "Authentication successful" proc))
+       (server-log "Authentication failed" proc)
+       (delete-process proc)
+       (return-from server-process-filter)))
    (server-log string proc)
!   (let ((prev (process-get proc :previous-string)))
      (when prev
        (setq string (concat prev string))
!       (process-put proc :previous-string nil)))
    ;; If the input is multiple lines,
    ;; process each line individually.
    (while (string-match "\n" string)
***************
*** 377,383 ****
        (if tmp-frame (delete-frame tmp-frame))))
    ;; Save for later any partial line that remains.
    (when (> (length string) 0)
!     (process-put proc 'previous-string string)))
  
  (defun server-goto-line-column (file-line-col)
    (goto-line (nth 1 file-line-col))
--- 411,417 ----
        (if tmp-frame (delete-frame tmp-frame))))
    ;; Save for later any partial line that remains.
    (when (> (length string) 0)
!     (process-put proc :previous-string string)))
  
  (defun server-goto-line-column (file-line-col)
    (goto-line (nth 1 file-line-col))

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: w32 does not have emacsclient/server
  2005-08-05  7:59               ` Juanma Barranquero
@ 2005-08-05  9:02                 ` Eli Zaretskii
  2005-08-05  9:09                   ` Juanma Barranquero
  2005-08-05 11:06                 ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-05  9:02 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Fri, 5 Aug 2005 09:59:15 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: Emacs Devel <emacs-devel@gnu.org>
> 
> I hate the things Gmail does to patches.

May I suggest to use Emacs?

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

* Re: w32 does not have emacsclient/server
  2005-08-05  9:02                 ` Eli Zaretskii
@ 2005-08-05  9:09                   ` Juanma Barranquero
  2005-08-05 18:50                     ` Eli Zaretskii
  2005-08-05 20:38                     ` Richard M. Stallman
  0 siblings, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-05  9:09 UTC (permalink / raw)
  Cc: emacs-devel

On 8/5/05, Eli Zaretskii <eliz@gnu.org> wrote:

> May I suggest to use Emacs?

Well, I can read Gmail at places where I don't have Emacs. And Gmail
is generally so nice that I've started using it as my main e-mail
interface, which says something, as I've always hated web-based e-mail
and used run-of-the-mill POP3 clients.

That said, what would you recommend as e-mail interface for a
mostly-Windows Emacs user? Gnus?

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-05  7:59               ` Juanma Barranquero
  2005-08-05  9:02                 ` Eli Zaretskii
@ 2005-08-05 11:06                 ` Juanma Barranquero
  1 sibling, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-05 11:06 UTC (permalink / raw)
  Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

The same patch, with a fix (there was a buffer overflow on
emacsclient; not a security problem, but still...). send_to_emacs() is
now much more rational.


-- 
                    /L/e/k/t/u

[-- Attachment #2: server.patch --]
[-- Type: application/octet-stream, Size: 36036 bytes --]

Index: lisp/server.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/server.el,v
retrieving revision 1.104
diff -c -r1.104 server.el
*** lisp/server.el	16 Jul 2005 11:58:10 -0000	1.104
--- lisp/server.el	5 Aug 2005 07:59:08 -0000
***************
*** 82,87 ****
--- 82,103 ----
    "Emacs running as a server process."
    :group 'external)
  
+ (defcustom server-host nil
+   "The name or IP address to use as host address of the server process.
+ If set, the server accepts remote connections; otherwise it is local."
+   :group 'server
+   :type '(choice
+           (string :tag "Name or IP address")
+           (const :tag "Local" nil))
+   :version "22.1")
+ 
+ (defcustom server-file "~/.emacs.server"
+   "The server authentication file.
+ Its value will be passed through `expand-file-name'."
+   :group 'server
+   :type 'file
+   :version "22.1")
+ 
  (defcustom server-visit-hook nil
    "*Hook run when visiting a file for the Emacs server."
    :group 'server
***************
*** 100,105 ****
--- 116,124 ----
  (defvar server-process nil
    "The current server process.")
  
+ (defvar server-auth-string nil
+   "The current server authentication string.")
+ 
  (defvar server-clients nil
    "List of current server clients.
  Each element is (CLIENTID BUFFERS...) where CLIENTID is a string
***************
*** 161,194 ****
  
  (defvar server-name "server")
  
- (defvar server-socket-dir
-   (format "/tmp/emacs%d" (user-uid)))
- 
  (defun server-log (string &optional client)
    "If a *server* buffer exists, write STRING to it for logging purposes."
!   (if (get-buffer "*server*")
!       (with-current-buffer "*server*"
! 	(goto-char (point-max))
! 	(insert (current-time-string)
! 		(if client (format " %s:" client) " ")
! 		string)
! 	(or (bolp) (newline)))))
  
  (defun server-sentinel (proc msg)
!   (let ((client (assq proc server-clients)))
!     ;; Remove PROC from the list of clients.
!     (when client
!       (setq server-clients (delq client server-clients))
!       (dolist (buf (cdr client))
! 	(with-current-buffer buf
! 	  ;; Remove PROC from the clients of each buffer.
! 	  (setq server-buffer-clients (delq proc server-buffer-clients))
! 	  ;; Kill the buffer if necessary.
! 	  (when (and (null server-buffer-clients)
! 		     (or (and server-kill-new-buffers
! 			      (not server-existing-buffer))
! 			 (server-temp-file-p)))
! 	    (kill-buffer (current-buffer)))))))
    (server-log (format "Status changed to %s" (process-status proc)) proc))
  
  (defun server-select-display (display)
--- 180,213 ----
  
  (defvar server-name "server")
  
  (defun server-log (string &optional client)
    "If a *server* buffer exists, write STRING to it for logging purposes."
!   (when (get-buffer "*server*")
!     (with-current-buffer "*server*"
!       (goto-char (point-max))
!       (insert (current-time-string)
!               (if client (format " %s:" client) " ")
!               string)
!       (or (bolp) (newline)))))
  
  (defun server-sentinel (proc msg)
!   (if (eq proc server-process)
!       (ignore-errors
!         (delete-file (expand-file-name server-file)))
!     (let ((client (assq proc server-clients)))
!       ;; Remove PROC from the list of clients.
!       (when client
!         (setq server-clients (delq client server-clients))
!         (dolist (buf (cdr client))
!           (with-current-buffer buf
!             ;; Remove PROC from the clients of each buffer.
!             (setq server-buffer-clients (delq proc server-buffer-clients))
!             ;; Kill the buffer if necessary.
!             (when (and (null server-buffer-clients)
!                        (or (and server-kill-new-buffers
!                                 (not server-existing-buffer))
!                            (server-temp-file-p)))
!               (kill-buffer (current-buffer))))))))
    (server-log (format "Status changed to %s" (process-status proc)) proc))
  
  (defun server-select-display (display)
***************
*** 221,241 ****
  	    (t " ")))
     arg t t))
  
! (defun server-ensure-safe-dir (dir)
!   "Make sure DIR is a directory with no race-condition issues.
! Creates the directory if necessary and makes sure:
! - there's no symlink involved
! - it's owned by us
! - it's not readable/writable by anybody else."
!   (setq dir (directory-file-name dir))
!   (let ((attrs (file-attributes dir)))
!     (unless attrs
!       (letf (((default-file-modes) ?\700)) (make-directory dir))
!       (setq attrs (file-attributes dir)))
!     ;; Check that it's safe for use.
!     (unless (and (eq t (car attrs)) (eq (nth 2 attrs) (user-uid))
! 		 (zerop (logand ?\077 (file-modes dir))))
!       (error "The directory %s is unsafe" dir))))
  
  ;;;###autoload
  (defun server-start (&optional leave-dead)
--- 240,254 ----
  	    (t " ")))
     arg t t))
  
! (defun server-auth-string ()
!   (or server-auth-string
!       ;; If the authentication string does not exist, create it on the fly:
!       ;; it's a 64-byte string of random chars in the range `!'..`~'.
!       (setq server-auth-string
!             (loop
!                for i below 64
!                collect (+ 33 (random 94)) into auth
!                finally return (concat auth)))))
  
  ;;;###autoload
  (defun server-start (&optional leave-dead)
***************
*** 247,278 ****
  
  Prefix arg means just kill any existing server communications subprocess."
    (interactive "P")
!   ;; Make sure there is a safe directory in which to place the socket.
!   (server-ensure-safe-dir server-socket-dir)
!   ;; kill it dead!
!   (if server-process
!       (condition-case () (delete-process server-process) (error nil)))
!   ;; Delete the socket files made by previous server invocations.
!   (condition-case ()
!       (delete-file (expand-file-name server-name server-socket-dir))
!     (error nil))
    ;; If this Emacs already had a server, clear out associated status.
    (while server-clients
      (let ((buffer (nth 1 (car server-clients))))
        (server-buffer-done buffer)))
    (unless leave-dead
!     (if server-process
! 	(server-log (message "Restarting server")))
      (letf (((default-file-modes) ?\700))
        (setq server-process
  	    (make-network-process
! 	     :name "server" :family 'local :server t :noquery t
! 	     :service (expand-file-name server-name server-socket-dir)
! 	     :sentinel 'server-sentinel :filter 'server-process-filter
  	     ;; We must receive file names without being decoded.
  	     ;; Those are decoded by server-process-filter according
  	     ;; to file-name-coding-system.
! 	     :coding 'raw-text)))))
  
  ;;;###autoload
  (define-minor-mode server-mode
--- 260,301 ----
  
  Prefix arg means just kill any existing server communications subprocess."
    (interactive "P")
!   ;; Kill it dead!
!   (when server-process
!     (condition-case ()
!         (progn
!           (delete-process server-process)
!           (delete-file (expand-file-name server-file))
!           (setq server-auth-string nil))
!       (error nil)))
    ;; If this Emacs already had a server, clear out associated status.
    (while server-clients
      (let ((buffer (nth 1 (car server-clients))))
        (server-buffer-done buffer)))
    (unless leave-dead
!     (when server-process
!       (server-log (message "Restarting server")))
      (letf (((default-file-modes) ?\700))
        (setq server-process
  	    (make-network-process
!              :name server-name :noquery t :server t
!              :service t :host (or server-host 'local)
!              :filter 'server-process-filter :sentinel 'server-sentinel
!              :plist '(:authenticated nil)
  	     ;; We must receive file names without being decoded.
  	     ;; Those are decoded by server-process-filter according
  	     ;; to file-name-coding-system.
! 	     :coding 'raw-text))
!       (unless server-process
!         (error "Could not start server process"))
!       ;; We must create the server info file, or no one will be able to contact us
!       (with-temp-file (expand-file-name server-file)
!         (set-buffer-multibyte nil)
!         (setq buffer-file-coding-system 'no-conversion)
!         (insert (format-network-address (cadr (memq :local
!                                                     (process-contact server-process
!                                                                      t))))
!                 "\n" (server-auth-string))))))
  
  ;;;###autoload
  (define-minor-mode server-mode
***************
*** 287,300 ****
    ;; nothing if there is one (for multiple Emacs sessions)?
    (server-start (not server-mode)))
  \f
! (defun server-process-filter (proc string)
    "Process a request from the server to edit some files.
  PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
    (server-log string proc)
!   (let ((prev (process-get proc 'previous-string)))
      (when prev
        (setq string (concat prev string))
!       (process-put proc 'previous-string nil)))
    ;; If the input is multiple lines,
    ;; process each line individually.
    (while (string-match "\n" string)
--- 310,334 ----
    ;; nothing if there is one (for multiple Emacs sessions)?
    (server-start (not server-mode)))
  \f
! (defun* server-process-filter (proc string)
    "Process a request from the server to edit some files.
  PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
+   ;; First things first: let's check the authentication
+   (unless (process-get proc :authenticated)
+     (if (and (string-match "-auth \\(.*?\\)\n" string)
+              (string= (match-string 1 string) server-auth-string))
+         (progn
+           (setq string (substring string (match-end 0)))
+           (process-put proc :authenticated t)
+           (server-log "Authentication successful" proc))
+       (server-log "Authentication failed" proc)
+       (delete-process proc)
+       (return-from server-process-filter)))
    (server-log string proc)
!   (let ((prev (process-get proc :previous-string)))
      (when prev
        (setq string (concat prev string))
!       (process-put proc :previous-string nil)))
    ;; If the input is multiple lines,
    ;; process each line individually.
    (while (string-match "\n" string)
***************
*** 377,383 ****
        (if tmp-frame (delete-frame tmp-frame))))
    ;; Save for later any partial line that remains.
    (when (> (length string) 0)
!     (process-put proc 'previous-string string)))
  
  (defun server-goto-line-column (file-line-col)
    (goto-line (nth 1 file-line-col))
--- 411,417 ----
        (if tmp-frame (delete-frame tmp-frame))))
    ;; Save for later any partial line that remains.
    (when (> (length string) 0)
!     (process-put proc :previous-string string)))
  
  (defun server-goto-line-column (file-line-col)
    (goto-line (nth 1 file-line-col))
Index: lib-src/emacsclient.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.74
diff -c -r1.74 emacsclient.c
*** lib-src/emacsclient.c	4 Jul 2005 15:24:11 -0000	1.74
--- lib-src/emacsclient.c	5 Aug 2005 10:44:55 -0000
***************
*** 20,25 ****
--- 20,28 ----
  Boston, MA 02110-1301, USA.  */
  
  
+ #define AUTH_STRING_LENGTH   64
+ #define SEND_BUFFER_SIZE   4096
+ 
  #define NO_SHORTNAMES
  
  #ifdef HAVE_CONFIG_H
***************
*** 30,45 ****
  
  #include <ctype.h>
  #include <stdio.h>
! #include <getopt.h>
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
  
  #ifdef VMS
! # include "vms-pwd.h"
  #else
! # include <pwd.h>
  #endif /* not VMS */
  
  char *getenv (), *getwd ();
  char *(getcwd) ();
--- 33,53 ----
  
  #include <ctype.h>
  #include <stdio.h>
! #include "getopt.h"
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
  
+ #ifdef WINDOWSNT
+ #include <winsock2.h>
+ #else /* not WINDOWSNT */
+ #include <sys/socket.h>
  #ifdef VMS
! #include "vms-pwd.h"
  #else
! #include <pwd.h>
  #endif /* not VMS */
+ #endif /* not WINDOWSNT */
  
  char *getenv (), *getwd ();
  char *(getcwd) ();
***************
*** 47,52 ****
--- 55,72 ----
  #ifndef VERSION
  #define VERSION "unspecified"
  #endif
+ 
+ #define SEND_STRING(data) (send_to_emacs (s, (data)))
+ #define SEND_QUOTED(data) (quote_file_name (s, (data)))
+ 
+ #ifndef EXIT_SUCCESS
+ #define EXIT_SUCCESS 0
+ #endif
+ 
+ #ifndef EXIT_FAILURE
+ #define EXIT_FAILURE 1
+ #endif
+ 
  \f
  /* Name used to invoke this program.  */
  char *progname;
***************
*** 61,71 ****
  char *display = NULL;
  
  /* If non-NULL, the name of an editor to fallback to if the server
!    is not running.  --alternate-editor.   */
! const char * alternate_editor = NULL;
  
! /* If non-NULL, the filename of the UNIX socket.  */
! char *socket_name = NULL;
  
  void print_help_and_exit ();
  
--- 81,96 ----
  char *display = NULL;
  
  /* If non-NULL, the name of an editor to fallback to if the server
!    is not running.  --alternate-editor.  */
! const char *alternate_editor = NULL;
  
! /* If non-NULL, the filename to use as configuration and
!    authentication file.  --server-file.  */
! const char *server_file = NULL;
! 
! /* Buffer to accumulate data to send.  */
! char send_buffer[SEND_BUFFER_SIZE+1];
! int sblen = 0;
  
  void print_help_and_exit ();
  
***************
*** 76,82 ****
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
!   { "socket-name",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
--- 101,107 ----
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
!   { "server-file",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
***************
*** 90,95 ****
--- 115,121 ----
       char **argv;
  {
    alternate_editor = getenv ("ALTERNATE_EDITOR");
+   server_file = getenv("EMACS_SERVER_FILE");
  
    while (1)
      {
***************
*** 111,117 ****
  	  break;
  
  	case 's':
! 	  socket_name = optarg;
  	  break;
  
  	case 'd':
--- 137,143 ----
  	  break;
  
  	case 's':
! 	  server_file = optarg;
  	  break;
  
  	case 'd':
***************
*** 157,164 ****
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
! -s, --socket-name=FILENAME\n\
!                         Set the filename of the UNIX socket for communication\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  \n\
--- 183,190 ----
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
! -s, --server-file=FILENAME\n\
!                         Server configuration and authentication file\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  \n\
***************
*** 166,179 ****
    exit (EXIT_SUCCESS);
  }
  
  /* In NAME, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.  */
  
  void
! quote_file_name (name, stream)
       char *name;
-      FILE *stream;
  {
    char *copy = (char *) malloc (strlen (name) * 2 + 1);
    char *p, *q;
--- 192,244 ----
    exit (EXIT_SUCCESS);
  }
  
+ \f
+ /* Let's send the data to Emacs when either
+    - the data ends in "\n", or
+    - the buffer is full (but this shouldn't happen)
+    Otherwise, we just accumulate it.  */
+ 
+ void send_to_emacs (s, data)
+      SOCKET s;
+      char *data;
+ {
+   while (data) {
+     int dlen = strlen (data);
+     if (dlen + sblen >= SEND_BUFFER_SIZE)
+       {
+         int part = SEND_BUFFER_SIZE - sblen;
+         strncpy (&send_buffer[sblen], data, part);
+         data += part;
+         sblen = SEND_BUFFER_SIZE;
+       }
+     else if (dlen)
+       {
+         strcpy (&send_buffer[sblen], data);
+         data = NULL;
+         sblen += dlen;
+       }
+     else
+       break;
+ 
+     if (sblen == SEND_BUFFER_SIZE
+         || (sblen > 0 && send_buffer[sblen-1] == '\n'))
+       {
+         int sent = send (s, send_buffer, sblen, 0);
+         if (sent != sblen)
+           strcpy (send_buffer, &send_buffer[sent]);
+         sblen -= sent;
+       }
+   }
+ }
+ 
  /* In NAME, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.  */
  
  void
! quote_file_name (s, name)
!      SOCKET s;
       char *name;
  {
    char *copy = (char *) malloc (strlen (name) * 2 + 1);
    char *p, *q;
***************
*** 203,227 ****
      }
    *q++ = 0;
  
!   fprintf (stream, "%s", copy);
  
    free (copy);
  }
  
- /* Like malloc but get fatal error if memory is exhausted.  */
- 
- long *
- xmalloc (size)
-      unsigned int size;
- {
-   long *result = (long *) malloc (size);
-   if (result == NULL)
-   {
-     perror ("malloc");
-     exit (EXIT_FAILURE);
-   }
-   return result;
- }
  \f
  /*
    Try to run a different command, or --if no alternate editor is
--- 268,278 ----
      }
    *q++ = 0;
  
!   SEND_STRING (copy);
  
    free (copy);
  }
  
  \f
  /*
    Try to run a different command, or --if no alternate editor is
***************
*** 244,458 ****
      }
  }
  
- 
  \f
- #if !defined (HAVE_SOCKETS) || defined (NO_SOCKETS_IN_FILE_SYSTEM)
  
! int
! main (argc, argv)
       int argc;
!      char **argv;
  {
!   fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
! 	   argv[0]);
!   fprintf (stderr, "on systems with Berkeley sockets.\n");
  
!   fail (argc, argv);
! }
  
! #else /* HAVE_SOCKETS */
  
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/un.h>
! #include <sys/stat.h>
! #include <errno.h>
  
! extern char *strerror ();
! extern int errno;
  
! /* Three possibilities:
!    2 - can't be `stat'ed		(sets errno)
!    1 - isn't owned by us
!    0 - success: none of the above */
  
! static int
! socket_status (socket_name)
!      char *socket_name;
  {
!   struct stat statbfr;
  
!   if (stat (socket_name, &statbfr) == -1)
!     return 2;
  
!   if (statbfr.st_uid != geteuid ())
!     return 1;
  
!   return 0;
  }
  
! int
! main (argc, argv)
!      int argc;
!      char **argv;
  {
!   int s, i, needlf = 0;
!   FILE *out, *in;
!   struct sockaddr_un server;
!   char *cwd, *str;
!   char string[BUFSIZ];
  
!   progname = argv[0];
  
!   /* Process options.  */
!   decode_options (argc, argv);
  
!   if ((argc - optind < 1) && !eval)
      {
!       fprintf (stderr, "%s: file name or argument required\n", progname);
!       fprintf (stderr, "Try `%s --help' for more information\n", progname);
        exit (EXIT_FAILURE);
      }
  
    /*
!    * Open up an AF_UNIX socket in this person's home directory
     */
! 
!   if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
      {
!       fprintf (stderr, "%s: ", argv[0]);
        perror ("socket");
!       fail (argc, argv);
      }
  
!   server.sun_family = AF_UNIX;
  
!   {
!     int sock_status = 0;
!     int default_sock = !socket_name;
!     int saved_errno;
!     char *server_name = "server";
! 
!     if (socket_name && !index (socket_name, '/') && !index (socket_name, '\\'))
!       { /* socket_name is a file name component.  */
! 	server_name = socket_name;
! 	socket_name = NULL;
! 	default_sock = 1;	/* Try both UIDs.  */
!       }
  
!     if (default_sock)
!       {
! 	socket_name = alloca (100 + strlen (server_name));
! 	sprintf (socket_name, "/tmp/emacs%d/%s",
! 		 (int) geteuid (), server_name);
!       }
  
!     if (strlen (socket_name) < sizeof (server.sun_path))
!       strcpy (server.sun_path, socket_name);
!     else
!       {
! 	fprintf (stderr, "%s: socket-name %s too long",
! 		 argv[0], socket_name);
! 	exit (EXIT_FAILURE);
!       }
  
!     /* See if the socket exists, and if it's owned by us. */
!     sock_status = socket_status (server.sun_path);
!     saved_errno = errno;
!     if (sock_status && default_sock)
!       {
! 	/* Failing that, see if LOGNAME or USER exist and differ from
! 	   our euid.  If so, look for a socket based on the UID
! 	   associated with the name.  This is reminiscent of the logic
! 	   that init_editfns uses to set the global Vuser_full_name.  */
! 
! 	char *user_name = (char *) getenv ("LOGNAME");
! 
! 	if (!user_name)
! 	  user_name = (char *) getenv ("USER");
! 
! 	if (user_name)
! 	  {
! 	    struct passwd *pw = getpwnam (user_name);
! 
! 	    if (pw && (pw->pw_uid != geteuid ()))
! 	      {
! 		/* We're running under su, apparently. */
! 		socket_name = alloca (100 + strlen (server_name));
! 		sprintf (socket_name, "/tmp/emacs%d/%s",
! 			 (int) pw->pw_uid, server_name);
! 
! 		if (strlen (socket_name) < sizeof (server.sun_path))
! 		  strcpy (server.sun_path, socket_name);
! 		else
! 		  {
! 		    fprintf (stderr, "%s: socket-name %s too long",
! 			     argv[0], socket_name);
! 		    exit (EXIT_FAILURE);
! 		  }
! 
! 		sock_status = socket_status (server.sun_path);
! 		saved_errno = errno;
! 	      }
! 	    else
! 	      errno = saved_errno;
! 	  }
!       }
  
!      switch (sock_status)
!        {
!        case 1:
! 	 /* There's a socket, but it isn't owned by us.  This is OK if
! 	    we are root. */
! 	 if (0 != geteuid ())
! 	   {
! 	     fprintf (stderr, "%s: Invalid socket owner\n", argv[0]);
! 	     fail (argc, argv);
! 	   }
! 	 break;
! 
!        case 2:
! 	 /* `stat' failed */
! 	 if (saved_errno == ENOENT)
! 	   fprintf (stderr,
! 		    "%s: can't find socket; have you started the server?\n\
! To start the server in Emacs, type \"M-x server-start\".\n",
! 		    argv[0]);
! 	 else
! 	   fprintf (stderr, "%s: can't stat %s: %s\n",
! 		    argv[0], server.sun_path, strerror (saved_errno));
! 	 fail (argc, argv);
! 	 break;
!        }
!   }
  
!   if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2)
!       < 0)
!     {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("connect");
!       fail (argc, argv);
!     }
  
!   /* We use the stream OUT to send our command to the server.  */
!   if ((out = fdopen (s, "r+")) == NULL)
!     {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("fdopen");
!       fail (argc, argv);
!     }
  
!   /* We use the stream IN to read the response.
!      We used to use just one stream for both output and input
!      on the socket, but reversing direction works nonportably:
!      on some systems, the output appears as the first input;
!      on other systems it does not.  */
!   if ((in = fdopen (s, "r+")) == NULL)
!     {
!       fprintf (stderr, "%s: ", argv[0]);
!       perror ("fdopen");
!       fail (argc, argv);
!     }
  
  #ifdef HAVE_GETCWD
    cwd = getcwd (string, sizeof string);
--- 295,476 ----
      }
  }
  
  \f
  
! /* Process options and check some sane defaults.  */
! void process_options (argc, argv)
       int argc;
!      char *argv[];
  {
!   decode_options (argc, argv);
  
!   if (!server_file)
!     {
!       fprintf (stderr, "%s: server configuration file required\n", progname);
!       goto error;
!     }
  
!   if ((argc - optind < 1) && !eval)
!     {
!       fprintf (stderr, "%s: file name or argument required\n", progname);
!       goto error;
!     }
  
!   return;
  
!  error:
! 
!   fprintf (stderr, "Try `%s --help' for more information\n", progname);
!   exit (EXIT_FAILURE);
! }
  
! #ifdef WINDOWSNT
! /* Wrapper to make WSACleanup a cdecl, as required by atexit().  */
! void close_winsock ()
! {
!   WSACleanup();
! }
! #endif /* WINDOWSNT */
  
! void initialize_sockets ()
  {
! #ifdef WINDOWSNT
  
!   /* Initialize the WinSock2 library.  */
!   WSADATA wsaData;
  
!   if (WSAStartup (MAKEWORD (2, 0), &wsaData))
!     {
!       fprintf (stderr, "%s: error initializing WinSock2", progname);
!       exit (EXIT_FAILURE);
!     }
  
!   atexit (close_winsock);
! #endif
  }
  
! /*
!  * Read the information needed to set up the comm channel with
!  * the Emacs server: host, port and authentication string.
!  */
! void get_server_config (server, authentication)
!      struct sockaddr_in *server;
!      char *authentication;
  {
!   FILE *config;
!   char dotted[32];
!   char *port;
  
!   if (! (config = fopen (server_file, "rb")))
!     {
!       fprintf (stderr, "%s: cannot read configuration file %s",
!                progname, server_file);
!       exit (EXIT_FAILURE);
!     }
  
!   if (fgets (dotted, sizeof dotted, config)
!       && (port = strchr (dotted, ':')))
!     {
!       *port++ = '\0';
!     }
!   else
!     {
!       fprintf (stderr, "%s: invalid configuration info", progname);
!       exit (EXIT_FAILURE);
!     }
  
!   server->sin_family = AF_INET;
!   server->sin_addr.s_addr = inet_addr (dotted);
!   server->sin_port = htons (atoi (port));
! 
!   if (! fread (authentication, AUTH_STRING_LENGTH, 1, config))
      {
!       fprintf (stderr, "%s: cannot read authentication info", progname);
        exit (EXIT_FAILURE);
      }
  
+   fclose (config);
+ }
+ 
+ /*
+  * Perform all required initialization; at the end either the socket
+  * is available and correctly configured, or we've finished with an
+  * error status so the main program can try the alternate editor.
+  */
+ SOCKET
+ set_socket ()
+ {
+   SOCKET s;
+   struct sockaddr_in server;
+   unsigned long c_arg = 0;
+   struct linger l_arg = {1, 1};
+   char auth_string[AUTH_STRING_LENGTH+1];
+ 
+   initialize_sockets();
+ 
+   get_server_config (&server, auth_string);
+ 
    /*
!    * Open up an AF_INET socket
     */
!   if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
      {
!       fprintf (stderr, "%s: ", progname);
        perror ("socket");
!       return INVALID_SOCKET;
      }
  
!   /*
!    * Set up the socket
!    */
!   if (connect (s, (struct sockaddr *) &server, sizeof server) < 0)
!     {
!       fprintf (stderr, "%s: ", progname);
!       perror ("connect");
!       return INVALID_SOCKET;
!     }
  
!   /*
!    * Force socket to be blocking and SO_LINGER
!    */
!   ioctlsocket (s, FIONBIO, &c_arg);
!   setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg);
  
!   /*
!    * Now, let's send the authentication
!    */
!   auth_string[AUTH_STRING_LENGTH] = '\0';
!   SEND_STRING ("-auth ");
!   SEND_STRING (auth_string);
!   SEND_STRING ("\n");
  
!   return s;
! }
  
! \f
! #include <sys/types.h>
  
! #include <sys/stat.h>
! #include <errno.h>
  
! extern char *strerror ();
! extern int errno;
  
! int
! main (argc, argv)
!      int argc;
!      char **argv;
! {
!   SOCKET s;
!   int i, rl, needlf = 0;
!   char *cwd, *str;
!   char string[BUFSIZ+1];
  
!   progname = argv[0];
!   process_options (argc, argv);
! 
!   if ((s = set_socket ()) == INVALID_SOCKET)
!     fail (argc, argv);
  
  #ifdef HAVE_GETCWD
    cwd = getcwd (string, sizeof string);
***************
*** 464,488 ****
        /* getwd puts message in STRING if it fails.  */
  
  #ifdef HAVE_GETCWD
!       fprintf (stderr, "%s: %s (%s)\n", argv[0],
  	       "Cannot get current working directory", strerror (errno));
  #else
!       fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno));
  #endif
        fail (argc, argv);
      }
  
    if (nowait)
!     fprintf (out, "-nowait ");
  
    if (eval)
!     fprintf (out, "-eval ");
  
    if (display)
      {
!       fprintf (out, "-display ");
!       quote_file_name (display, out);
!       fprintf (out, " ");
      }
  
    if ((argc - optind > 0))
--- 482,506 ----
        /* getwd puts message in STRING if it fails.  */
  
  #ifdef HAVE_GETCWD
!       fprintf (stderr, "%s: %s (%s)\n", progname,
  	       "Cannot get current working directory", strerror (errno));
  #else
!       fprintf (stderr, "%s: %s (%s)\n", progname, string, strerror (errno));
  #endif
        fail (argc, argv);
      }
  
    if (nowait)
!     SEND_STRING ("-nowait ");
  
    if (eval)
!     SEND_STRING ("-eval ");
  
    if (display)
      {
!       SEND_STRING ("-display ");
!       SEND_QUOTED (display);
!       SEND_STRING (" ");
      }
  
    if ((argc - optind > 0))
***************
*** 497,556 ****
  	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
  	      if (*p != 0)
  		{
! 		  quote_file_name (cwd, out);
! 		  fprintf (out, "/");
  		}
  	    }
! 	  else if (*argv[i] != '/')
  	    {
! 	      quote_file_name (cwd, out);
! 	      fprintf (out, "/");
  	    }
  
! 	  quote_file_name (argv[i], out);
! 	  fprintf (out, " ");
  	}
      }
    else
      {
        while ((str = fgets (string, BUFSIZ, stdin)))
  	{
! 	  quote_file_name (str, out);
  	}
!       fprintf (out, " ");
      }
  
!   fprintf (out, "\n");
!   fflush (out);
  
!   /* Maybe wait for an answer.   */
!   if (nowait)
!     return EXIT_SUCCESS;
! 
!   if (!eval)
      {
!       printf ("Waiting for Emacs...");
!       needlf = 2;
!     }
!   fflush (stdout);
  
!   /* Now, wait for an answer and print any messages.  */
!   while ((str = fgets (string, BUFSIZ, in)))
!     {
!       if (needlf == 2)
! 	printf ("\n");
!       printf ("%s", str);
!       needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
!     }
  
!   if (needlf)
!     printf ("\n");
!   fflush (stdout);
  
    return EXIT_SUCCESS;
  }
  
- #endif /* HAVE_SOCKETS */
  \f
  #ifndef HAVE_STRERROR
  char *
--- 515,580 ----
  	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
  	      if (*p != 0)
  		{
! 		  SEND_QUOTED (cwd);
! 		  SEND_STRING ("/");
  		}
  	    }
!           /* Absolute paths can also start with backslash or drive letters.  */
!           else if ((*argv[i] != '/')
!                     && (*argv[i] != '\\')
!                     && (!islower (tolower (*argv[i]))
!                         || (argv[i][1] != ':')))
  	    {
! 	      SEND_QUOTED (cwd);
! 	      SEND_STRING ("/");
  	    }
  
! 	  SEND_QUOTED (argv[i]);
! 	  SEND_STRING (" ");
  	}
      }
    else
      {
        while ((str = fgets (string, BUFSIZ, stdin)))
  	{
! 	  SEND_QUOTED (str);
  	}
!       SEND_STRING (" ");
      }
  
!   SEND_STRING ("\n");
  
!   /* Maybe wait for an answer.  */
!   if (!nowait)
      {
!       if (!eval)
!         {
!           printf ("Waiting for Emacs...");
!           needlf = 2;
!         }
!       fflush (stdout);
  
!       /* Now, wait for an answer and print any messages.  */
! 
!       while ((rl = recv (s, string, BUFSIZ, 0)) > 0)
!         {
!           string[rl] = '\0';
!           if (needlf == 2)
!             printf ("\n");
!           printf ("%s", str);
!           needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
!         }
  
!       if (needlf)
!         printf ("\n");
!       fflush (stdout);
!     }
  
+   closesocket (s);
    return EXIT_SUCCESS;
+ 
  }
  
  \f
  #ifndef HAVE_STRERROR
  char *
Index: lib-src/makefile.w32-in
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/makefile.w32-in,v
retrieving revision 2.36
diff -c -r2.36 makefile.w32-in
*** lib-src/makefile.w32-in	28 Jul 2005 07:58:52 -0000	2.36
--- lib-src/makefile.w32-in	5 Aug 2005 07:59:08 -0000
***************
*** 19,25 ****
  #  Boston, MA 02110-1301, USA.
  #
  
! ALL	      = make-docfile hexl ctags etags movemail ebrowse
  
  .PHONY: $(ALL)
  
--- 19,25 ----
  #  Boston, MA 02110-1301, USA.
  #
  
! ALL	      = make-docfile hexl ctags etags movemail ebrowse emacsclient
  
  .PHONY: $(ALL)
  
***************
*** 34,40 ****
  #		$(BLD)/server.exe	\
  #		$(BLD)/emacstool.exe	\
  #		$(BLD)/leditcfns.exe	\
- #		$(BLD)/emacsclient.exe	\
  #		$(BLD)/cvtmail.exe	\
  #		$(BLD)/digest-doc.exe	\
  #		$(BLD)/test-distrib.exe	\
--- 34,39 ----
***************
*** 55,60 ****
--- 54,60 ----
  hexl:		$(BLD) $(BLD)/hexl.exe
  movemail:	$(BLD) $(BLD)/movemail.exe
  fakemail:	$(BLD) $(BLD)/fakemail.exe
+ emacsclient:	$(BLD) $(BLD)/emacsclient.exe
  
  GETOPTOBJS = $(BLD)/getopt.$(O) $(BLD)/getopt1.$(O)
  GETOPTDEPS = $(GETOPTOBJS) getopt.h
***************
*** 67,72 ****
--- 67,85 ----
  # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
  		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(MOVEMAILOBJS) $(WSOCK32) $(LIBS)
  
+ ECLIENT_CFLAGS =	-DWINDOWSNT -DHAVE_GETCWD -DHAVE_STRERROR -c
+ ECLIENTOBJS =	$(BLD)/emacsclient.$(O) \
+ 		$(BLD)/getopt.$(O) \
+ 		$(BLD)/getopt1.$(O) \
+ 		$(BLD)/ntlib.$(O)
+ 
+ $(BLD)/emacsclient.exe:	$(ECLIENTOBJS)
+ # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
+ 		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(LIBS)
+ 
+ $(BLD)/emacsclient.$(O):	emacsclient.c
+ 		$(CC) $(ECLIENT_CFLAGS) $(CC_OUT)$@ emacsclient.c
+ 
  ETAGSOBJ      = $(BLD)/etags.$(O) \
  		$(BLD)/getopt.$(O) \
  		$(BLD)/getopt1.$(O) \
***************
*** 76,82 ****
  $(BLD)/etags.exe: 	$(ETAGSOBJ)
  		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ETAGSOBJ) $(LIBS)
  
- 
  EBROWSEOBJ    = $(BLD)/ebrowse.$(O) \
                  $(BLD)/getopt.$(O) \
                  $(BLD)/getopt1.$(O) \
--- 89,94 ----
***************
*** 120,126 ****
  # $(BLD)/server.exe: 		$(BLD)/server.$(O)
  # $(BLD)/cvtmail.exe: 		$(BLD)/cvtmail.$(O)
  # $(BLD)/digest-doc.exe: 	$(BLD)/digest-doc.$(O)
- # $(BLD)/emacsclient.exe: 	$(BLD)/emacsclient.$(O)
  # $(BLD)/test-distrib.exe: 	$(BLD)/test-distrib.$(O)
  
  #
--- 132,137 ----
***************
*** 130,136 ****
  # as it is required by code in doc.c.
  #
  obj=    sunfns.o dosfns.o msdos.o \
! 	xterm.o xfns.o xmenu.o xselect.o xrdb.o  fringe.o image.o \
  	mac.o macterm.o macfns.o macmenu.o fontset.o \
  	w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
  	w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
--- 141,147 ----
  # as it is required by code in doc.c.
  #
  obj=    sunfns.o dosfns.o msdos.o \
! 	xterm.o xfns.o xmenu.o xselect.o xrdb.o fringe.o image.o \
  	mac.o macterm.o macfns.o macmenu.o fontset.o \
  	w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
  	w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
***************
*** 277,282 ****
--- 288,294 ----
  		$(CP) $(BLD)/ctags.exe $(INSTALL_DIR)/bin
  		$(CP) $(BLD)/hexl.exe $(INSTALL_DIR)/bin
  		$(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin
+ 		$(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin
  		- mkdir "$(INSTALL_DIR)/etc"
  		$(CP) $(DOC) $(INSTALL_DIR)/etc
  

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: w32 does not have emacsclient/server
  2005-08-05  9:09                   ` Juanma Barranquero
@ 2005-08-05 18:50                     ` Eli Zaretskii
  2005-08-05 23:10                       ` Juanma Barranquero
  2005-08-05 20:38                     ` Richard M. Stallman
  1 sibling, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-05 18:50 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Fri, 5 Aug 2005 11:09:45 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: emacs-devel@gnu.org
> 
> That said, what would you recommend as e-mail interface for a
> mostly-Windows Emacs user? Gnus?

I use RMAIL, but Gnus should also work.

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

* Re: w32 does not have emacsclient/server
  2005-08-05  9:09                   ` Juanma Barranquero
  2005-08-05 18:50                     ` Eli Zaretskii
@ 2005-08-05 20:38                     ` Richard M. Stallman
  2005-08-05 21:34                       ` David Kastrup
  2005-08-05 23:12                       ` Juanma Barranquero
  1 sibling, 2 replies; 74+ messages in thread
From: Richard M. Stallman @ 2005-08-05 20:38 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    That said, what would you recommend as e-mail interface for a
    mostly-Windows Emacs user? Gnus?

I recommend that you defenestrate your computer.
Either throw Windows out of the computer, or throw
the computer out the window.

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

* Re: w32 does not have emacsclient/server
  2005-08-05 20:38                     ` Richard M. Stallman
@ 2005-08-05 21:34                       ` David Kastrup
  2005-08-05 23:12                       ` Juanma Barranquero
  1 sibling, 0 replies; 74+ messages in thread
From: David Kastrup @ 2005-08-05 21:34 UTC (permalink / raw)
  Cc: Juanma Barranquero, eliz, emacs-devel

"Richard M. Stallman" <rms@gnu.org> writes:

>     That said, what would you recommend as e-mail interface for a
>     mostly-Windows Emacs user? Gnus?
>
> I recommend that you defenestrate your computer.
> Either throw Windows out of the computer, or throw
> the computer out the window.

The latter is just feasible for local delivery.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-08-05 18:50                     ` Eli Zaretskii
@ 2005-08-05 23:10                       ` Juanma Barranquero
  2005-08-06  6:55                         ` Eli Zaretskii
  0 siblings, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-05 23:10 UTC (permalink / raw)
  Cc: emacs-devel

On 8/5/05, Eli Zaretskii <eliz@gnu.org> wrote:

> I use RMAIL, but Gnus should also work.

Is RMAIL easier to set up than Gnus?

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-05 20:38                     ` Richard M. Stallman
  2005-08-05 21:34                       ` David Kastrup
@ 2005-08-05 23:12                       ` Juanma Barranquero
  2005-08-05 23:48                         ` Lennart Borgman
  2005-08-06 18:35                         ` Richard M. Stallman
  1 sibling, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-05 23:12 UTC (permalink / raw)
  Cc: emacs-devel

On 8/5/05, Richard M. Stallman <rms@gnu.org> wrote:

> I recommend that you defenestrate your computer.
> Either throw Windows out of the computer, or throw
> the computer out the window.

So the options are, losing my computer, or Emacs losing a Windows
maintainer? :-)

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-05 23:12                       ` Juanma Barranquero
@ 2005-08-05 23:48                         ` Lennart Borgman
  2005-08-06  0:02                           ` Juanma Barranquero
  2005-08-06 18:35                         ` Richard M. Stallman
  1 sibling, 1 reply; 74+ messages in thread
From: Lennart Borgman @ 2005-08-05 23:48 UTC (permalink / raw)
  Cc: rms, emacs-devel

Juanma Barranquero wrote:

>On 8/5/05, Richard M. Stallman <rms@gnu.org> wrote:
>
>  
>
>>I recommend that you defenestrate your computer.
>>Either throw Windows out of the computer, or throw
>>the computer out the window.
>>    
>>
>
>So the options are, losing my computer, or Emacs losing a Windows
>maintainer? :-)
>  
>
Yes times are tough
not to lose
we must be rough
follow rules

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

* Re: w32 does not have emacsclient/server
  2005-08-05 23:48                         ` Lennart Borgman
@ 2005-08-06  0:02                           ` Juanma Barranquero
  2005-08-06  6:58                             ` Eli Zaretskii
  2005-08-06  6:59                             ` David Kastrup
  0 siblings, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06  0:02 UTC (permalink / raw)
  Cc: rms, emacs-devel

On 8/6/05, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:

> Yes times are tough
> not to lose
> we must be rough
> follow rules

Very funny.

Still...

Would someone *please* try and comment the changes? Or is there no
interest on an emacs client/server accessible across the network and
Windows-compatible too?

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-05 23:10                       ` Juanma Barranquero
@ 2005-08-06  6:55                         ` Eli Zaretskii
  2005-08-06  7:12                           ` Jason Rumney
  0 siblings, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-06  6:55 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Sat, 6 Aug 2005 01:10:28 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: emacs-devel@gnu.org
> 
> On 8/5/05, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > I use RMAIL, but Gnus should also work.
> 
> Is RMAIL easier to set up than Gnus?

MUCH easier.  In fact, it doesn't need any setup at all just to read
messages and reply to them.  You will only need to customize if you
want to use features like archiving mail in folders separated by
subject etc.

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

* Re: w32 does not have emacsclient/server
  2005-08-06  0:02                           ` Juanma Barranquero
@ 2005-08-06  6:58                             ` Eli Zaretskii
  2005-08-06 11:20                               ` Juanma Barranquero
  2005-08-06  6:59                             ` David Kastrup
  1 sibling, 1 reply; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-06  6:58 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Sat, 6 Aug 2005 02:02:40 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: rms@gnu.org, emacs-devel@gnu.org
> 
> Would someone *please* try and comment the changes? Or is there no
> interest on an emacs client/server accessible across the network and
> Windows-compatible too?

I'd say, if no one posts any practical comments in a week or so, go
ahead and commit the changes.  After all, the Emacs development rules
do not mandate any peer review at all.

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

* Re: w32 does not have emacsclient/server
  2005-08-06  0:02                           ` Juanma Barranquero
  2005-08-06  6:58                             ` Eli Zaretskii
@ 2005-08-06  6:59                             ` David Kastrup
  2005-08-06 13:45                               ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-08-06  6:59 UTC (permalink / raw)
  Cc: Lennart Borgman, rms, emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> On 8/6/05, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
>
>> Yes times are tough
>> not to lose
>> we must be rough
>> follow rules
>
> Very funny.
>
> Still...
>
> Would someone *please* try and comment the changes? Or is there no
> interest on an emacs client/server accessible across the network and
> Windows-compatible too?

Oh, there is.  Actually, one thing I would like as added functionality
in emacsclient is an option "-t" for "tramp" which would fork a shell
and let it act as a tramp connection.  That way, I could use
emacsclient from a su-shell (by pointing EMACS_CLIENT_whatever to the
respective credentials) to edit files without having to reenter a
password.

And of course, I'd like something that will let me use my local Emacs
for editing files in some ssh session.  This would require similar
functionality, and probably some port forwarding.

Lots of potential...

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-08-06  6:55                         ` Eli Zaretskii
@ 2005-08-06  7:12                           ` Jason Rumney
  2005-08-06  8:10                             ` Eli Zaretskii
  0 siblings, 1 reply; 74+ messages in thread
From: Jason Rumney @ 2005-08-06  7:12 UTC (permalink / raw)
  Cc: Juanma Barranquero, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Is RMAIL easier to set up than Gnus?
>
> MUCH easier.  In fact, it doesn't need any setup at all just to read
> messages and reply to them.  You will only need to customize if you
> want to use features like archiving mail in folders separated by
> subject etc.

That's not really true if you do not have the mail spool on your local
machine.

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

* Re: w32 does not have emacsclient/server
  2005-08-06  7:12                           ` Jason Rumney
@ 2005-08-06  8:10                             ` Eli Zaretskii
  2005-08-06  9:30                               ` Lennart Borgman
  2005-08-06 11:21                               ` Juanma Barranquero
  0 siblings, 2 replies; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-06  8:10 UTC (permalink / raw)
  Cc: lekktu, emacs-devel

> Cc: Juanma Barranquero <lekktu@gmail.com>, emacs-devel@gnu.org
> From: Jason Rumney <jasonr@gnu.org>
> Date: Sat, 06 Aug 2005 08:12:50 +0100
> 
> > MUCH easier.  In fact, it doesn't need any setup at all just to read
> > messages and reply to them.  You will only need to customize if you
> > want to use features like archiving mail in folders separated by
> > subject etc.
> 
> That's not really true if you do not have the mail spool on your local
> machine.

??? Perhaps this is a misunderstanding.  I didn't mean to say that
nothing has to be done to configure how mail is fetched from the
mailbox.  But that part is not specific to RMAIL: _any_ mail package
in Emacs will need to set this up, and the setup is (AFAIR) identical
no matter what Emacs mail front end you use.

Am I missing something?

(For the record: my mailbox is not local, I fetch my mail from gnu.org
machines using a Windows SSH client.)

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

* Re: w32 does not have emacsclient/server
  2005-08-06  8:10                             ` Eli Zaretskii
@ 2005-08-06  9:30                               ` Lennart Borgman
  2005-08-06 11:08                                 ` Stephan Stahl
  2005-08-06 14:48                                 ` Eli Zaretskii
  2005-08-06 11:21                               ` Juanma Barranquero
  1 sibling, 2 replies; 74+ messages in thread
From: Lennart Borgman @ 2005-08-06  9:30 UTC (permalink / raw)
  Cc: lekktu, emacs-devel, Jason Rumney

Eli Zaretskii wrote:

>??? Perhaps this is a misunderstanding.  I didn't mean to say that
>nothing has to be done to configure how mail is fetched from the
>mailbox.  But that part is not specific to RMAIL: _any_ mail package
>in Emacs will need to set this up, and the setup is (AFAIR) identical
>no matter what Emacs mail front end you use.
>
>Am I missing something?
>
>(For the record: my mailbox is not local, I fetch my mail from gnu.org
>machines using a Windows SSH client.)
>  
>
Perhaps your missing that some of us just do not know how to do it. 
Could those of you that are using some mail client in Emacs on w32 
perhaps post to the list and tell how this setup is done? Or if you 
think it is not relevant for this list post it to me and I will try to 
condense it to some useful instructions?

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

* Re: w32 does not have emacsclient/server
  2005-08-06  9:30                               ` Lennart Borgman
@ 2005-08-06 11:08                                 ` Stephan Stahl
  2005-08-06 14:48                                 ` Eli Zaretskii
  1 sibling, 0 replies; 74+ messages in thread
From: Stephan Stahl @ 2005-08-06 11:08 UTC (permalink / raw)
  Cc: lekktu, Eli Zaretskii, Jason Rumney, emacs-devel

Hi Lennart.

Lennart Borgman said:

> Perhaps your missing that some of us just do not know how to do it.
> Could those of you that are using some mail client in Emacs on w32
> perhaps post to the list and tell how this setup is done? Or if you
> think it is not relevant for this list post it to me and I will try
> to condense it to some useful instructions?

Well i used gnus togehter with fetchmail (cygwin) on win32. That was a
while ago and now i moved to debian gnu/linux for reading mails but
the gnus setup i have did not change very much. So it should still
work. I can post it here if you could need the info. However i'm no
longer sure which of the settings are required and which go beyond
"basic setup".

Regard,
-- 
Stephan Stahl

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

* Re: w32 does not have emacsclient/server
  2005-08-06  6:58                             ` Eli Zaretskii
@ 2005-08-06 11:20                               ` Juanma Barranquero
  2005-08-06 12:43                                 ` David Kastrup
  2005-08-06 17:45                                 ` Jason Rumney
  0 siblings, 2 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06 11:20 UTC (permalink / raw)
  Cc: emacs-devel

On 8/6/05, Eli Zaretskii <eliz@gnu.org> wrote:

> I'd say, if no one posts any practical comments in a week or so, go
> ahead and commit the changes.  After all, the Emacs development rules
> do not mandate any peer review at all.

You're right.

I would've liked some comments, though, for two reasons:

  - It's an incompatible change, if small: --socket-name does not
exist, and you *must* use either the EMACS_SERVER_FILE environment
variable or the --server-file argument to emacsclient; otherwise
emacsclient will refuse to work.

  - I've been vocal in stressing that I think our freeze is not very
cold at all. So I'd like someone with a more objective POV to decide
whether this (making emacsclient/server work on Windows and from
remote machines) is a bug fix or a new feature. Of course I'd like to
include it now, but I won't complain if the decision goes to shelving
it for the moment being.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-06  8:10                             ` Eli Zaretskii
  2005-08-06  9:30                               ` Lennart Borgman
@ 2005-08-06 11:21                               ` Juanma Barranquero
  2005-08-06 14:52                                 ` Eli Zaretskii
  1 sibling, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06 11:21 UTC (permalink / raw)
  Cc: emacs-devel, Jason Rumney

On 8/6/05, Eli Zaretskii <eliz@gnu.org> wrote:

> ??? Perhaps this is a misunderstanding.  I didn't mean to say that
> nothing has to be done to configure how mail is fetched from the
> mailbox.  But that part is not specific to RMAIL: _any_ mail package
> in Emacs will need to set this up, and the setup is (AFAIR) identical
> no matter what Emacs mail front end you use.
> 
> Am I missing something?

AFAIK, gnus can fetch mail from a POP3 mail server; I don't need to
worry about fetching the mail "by hand" with another program or
anything. I gather is not so with RMAIL?

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-06 11:20                               ` Juanma Barranquero
@ 2005-08-06 12:43                                 ` David Kastrup
  2005-08-06 13:43                                   ` Juanma Barranquero
  2005-08-06 17:45                                 ` Jason Rumney
  1 sibling, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-08-06 12:43 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> On 8/6/05, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> I'd say, if no one posts any practical comments in a week or so, go
>> ahead and commit the changes.  After all, the Emacs development rules
>> do not mandate any peer review at all.
>
> You're right.
>
> I would've liked some comments, though, for two reasons:
>
>   - It's an incompatible change, if small: --socket-name does not
> exist, and you *must* use either the EMACS_SERVER_FILE environment
> variable or the --server-file argument to emacsclient; otherwise
> emacsclient will refuse to work.

Uh what?  Isn't there a default file name?

>   - I've been vocal in stressing that I think our freeze is not very
> cold at all. So I'd like someone with a more objective POV to decide
> whether this (making emacsclient/server work on Windows and from
> remote machines) is a bug fix or a new feature.

It is a new feature fixing a bug.

> Of course I'd like to include it now, but I won't complain if the
> decision goes to shelving it for the moment being.

In my opinion it is one thing worth the hassle of ironing out, though
it is definitely new.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-08-06 12:43                                 ` David Kastrup
@ 2005-08-06 13:43                                   ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06 13:43 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

On 8/6/05, David Kastrup <dak@gnu.org> wrote:

> Uh what?  Isn't there a default file name?

No, there's not. What should it be? $HOME/.emacs.server, I suppose?

> It is a new feature fixing a bug.

Well, thanks for clarifying it ;-)

> In my opinion it is one thing worth the hassle of ironing out, though
> it is definitely new.

Ah, OK :-)

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-06  6:59                             ` David Kastrup
@ 2005-08-06 13:45                               ` Juanma Barranquero
  2005-08-06 14:03                                 ` David Kastrup
  0 siblings, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06 13:45 UTC (permalink / raw)
  Cc: Lennart Borgman, rms, emacs-devel

On 8/6/05, David Kastrup <dak@gnu.org> wrote:

> Oh, there is.  Actually, one thing I would like as added functionality
> in emacsclient is an option "-t" for "tramp" which would fork a shell
> and let it act as a tramp connection.  That way, I could use
> emacsclient from a su-shell (by pointing EMACS_CLIENT_whatever to the
> respective credentials) to edit files without having to reenter a
> password.

I think after the new emacsclient is committed (if ever), I'll leave
the implementation of what you're proposing to someone else with more
knowledge of tramp, SSH and su.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-06 13:45                               ` Juanma Barranquero
@ 2005-08-06 14:03                                 ` David Kastrup
  2005-08-07 17:15                                   ` Richard M. Stallman
  0 siblings, 1 reply; 74+ messages in thread
From: David Kastrup @ 2005-08-06 14:03 UTC (permalink / raw)
  Cc: Lennart Borgman, rms, emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> On 8/6/05, David Kastrup <dak@gnu.org> wrote:
>
>> Oh, there is.  Actually, one thing I would like as added
>> functionality in emacsclient is an option "-t" for "tramp" which
>> would fork a shell and let it act as a tramp connection.  That way,
>> I could use emacsclient from a su-shell (by pointing
>> EMACS_CLIENT_whatever to the respective credentials) to edit files
>> without having to reenter a password.
>
> I think after the new emacsclient is committed (if ever), I'll leave
> the implementation of what you're proposing to someone else with
> more knowledge of tramp, SSH and su.

Yes.  And it might be reasonable to postpone _that_ until after the
release.  Even though it would probably be of the "don't use it, and
it won't break anything" variety.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server
  2005-08-06  9:30                               ` Lennart Borgman
  2005-08-06 11:08                                 ` Stephan Stahl
@ 2005-08-06 14:48                                 ` Eli Zaretskii
  1 sibling, 0 replies; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-06 14:48 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Sat, 06 Aug 2005 11:30:02 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> CC: Jason Rumney <jasonr@gnu.org>,  lekktu@gmail.com, 
>  emacs-devel@gnu.org
> 
> Could those of you that are using some mail client in Emacs on w32 
> perhaps post to the list and tell how this setup is done?

I don't do anything that is not already described in the manual.
There's no need: movemail works on Windows as well as on Posix
platforms, and with exactly the same command-line options.

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

* Re: w32 does not have emacsclient/server
  2005-08-06 11:21                               ` Juanma Barranquero
@ 2005-08-06 14:52                                 ` Eli Zaretskii
  0 siblings, 0 replies; 74+ messages in thread
From: Eli Zaretskii @ 2005-08-06 14:52 UTC (permalink / raw)
  Cc: emacs-devel, jasonr

> Date: Sat, 6 Aug 2005 13:21:41 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: Jason Rumney <jasonr@gnu.org>, emacs-devel@gnu.org
> 
> AFAIK, gnus can fetch mail from a POP3 mail server; I don't need to
> worry about fetching the mail "by hand" with another program or
> anything. I gather is not so with RMAIL?

No, it's _exactly_ the same.

The problem is that gnu.org doesn't allow plain POP3 logins, only
APOP.  So I fetch mail via ssh (by running movemail on the gnu.org
server).  Then I tell RMAIL to get new mail from the file created by
ssh.

If you can use POP3, RMAIL will work with the same setup.

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

* Re: w32 does not have emacsclient/server
  2005-08-06 11:20                               ` Juanma Barranquero
  2005-08-06 12:43                                 ` David Kastrup
@ 2005-08-06 17:45                                 ` Jason Rumney
  2005-08-06 17:54                                   ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: Jason Rumney @ 2005-08-06 17:45 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

>   - It's an incompatible change, if small: --socket-name does not
> exist, and you *must* use either the EMACS_SERVER_FILE environment
> variable or the --server-file argument to emacsclient; otherwise
> emacsclient will refuse to work.

That is bad. The original suggestion was to have a standard file
name for the server file.

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

* Re: w32 does not have emacsclient/server
  2005-08-06 17:45                                 ` Jason Rumney
@ 2005-08-06 17:54                                   ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06 17:54 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

On 8/6/05, Jason Rumney <jasonr@gnu.org> wrote:

> That is bad. The original suggestion was to have a standard file
> name for the server file.

Yes. I'll make it default to ~/.emacs.server (~/ for the user running
Emacs, of course).

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-05 23:12                       ` Juanma Barranquero
  2005-08-05 23:48                         ` Lennart Borgman
@ 2005-08-06 18:35                         ` Richard M. Stallman
  2005-08-06 18:44                           ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: Richard M. Stallman @ 2005-08-06 18:35 UTC (permalink / raw)
  Cc: emacs-devel

    So the options are, losing my computer, or Emacs losing a Windows
    maintainer? :-)

I would rather see you living in freedom and maintaining Emacs
for GNU/Linux.

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

* Re: w32 does not have emacsclient/server
  2005-08-06 18:35                         ` Richard M. Stallman
@ 2005-08-06 18:44                           ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-06 18:44 UTC (permalink / raw)
  Cc: emacs-devel

On 8/6/05, Richard M. Stallman <rms@gnu.org> wrote:

> I would rather see you living in freedom and maintaining Emacs
> for GNU/Linux.

Thanks. I appreciate your feelings.

On that vein, I would much prefer to live in freedom and maintain
Emacs for GNU/Hurd. Unfortunately, I'm not a kernel hacker so I'm not
able to help in that project...

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-06 14:03                                 ` David Kastrup
@ 2005-08-07 17:15                                   ` Richard M. Stallman
  2005-08-07 20:31                                     ` Juanma Barranquero
  0 siblings, 1 reply; 74+ messages in thread
From: Richard M. Stallman @ 2005-08-07 17:15 UTC (permalink / raw)
  Cc: lekktu, emacs-devel, lennart.borgman.073

    Yes.  And it might be reasonable to postpone _that_ until after the
    release.  Even though it would probably be of the "don't use it, and
    it won't break anything" variety.

I would really like it if people would turn their attention
from this to the tasks listed in FOR-RELEASE.  We could get a release
made this year if people start doing those tasks.

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

* Re: w32 does not have emacsclient/server
  2005-08-07 17:15                                   ` Richard M. Stallman
@ 2005-08-07 20:31                                     ` Juanma Barranquero
  2005-08-09  0:26                                       ` Richard M. Stallman
  0 siblings, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-07 20:31 UTC (permalink / raw)
  Cc: emacs-devel

On 8/7/05, Richard M. Stallman <rms@gnu.org> wrote:

> I would really like it if people would turn their attention
> from this to the tasks listed in FOR-RELEASE.  We could get a release
> made this year if people start doing those tasks.

Don't you think that TCP servers on Windows taking 100% CPU is a bug
worth fixing before the release?

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-05  1:43             ` Juanma Barranquero
  2005-08-05  7:59               ` Juanma Barranquero
@ 2005-08-08 23:49               ` Stefan Monnier
  2005-08-09  0:12                 ` Juanma Barranquero
  2005-08-09  0:19                 ` Juanma Barranquero
  1 sibling, 2 replies; 74+ messages in thread
From: Stefan Monnier @ 2005-08-08 23:49 UTC (permalink / raw)
  Cc: Emacs Devel

> server.el now creates an AF_INET socket, at an unspecified port. The
> host address is local (127.0.0.1) unless the user customizes the
> variable `server-host' to the IP or name to use to bind the socket.
> The server generates a 64-byte random string (not random bytes, but
> printable characters in the range `!'..`~'; it's still about 420 bits
> of entropy) and writes in `server-file' (by default "~/.emacs.server")
> the host, port and authentication string. Connections are expected to
> pass as the first thing in a communication exchange the string "-auth
> AUTHENTICATION-STRING" where AUTHENTICATION-STRING is the 64-byte
> secret key; otherwise the connection is closed immediately.

Sounds very good.  To the host, port, and auth, I'd add a "server
name" entry, which would default to "server", to reproduce the
socket-name thingy.

> In emacsclient.c I've got rid of all AF_UNIX stuff.

Doesn't sound so good.  I'd rather make it possible to choose between Unix
and TCP sockets (default to Unix when possible, and TCP otherwise).

> I've also changed the code to use send/recv instead of writing to a file
> handle (was easier than fighting two Windows C compilers' idiosincrasies)
> and added buffering so data is only sent on receiving "\n" or filling the
> buffer.

Fair.

> Argument `socket-name' has been replaced by `server-file', to
> indicate the path to the server config/auth file (alternatively, the
> variable EMACS_SERVER_FILE can be set to point to the file; and BTW,
> a better name for the variable would be very welcome).

I'd rather see "server-name" which could be a path to a unix socket (like
now) or just a relative name of a unix socket (like now) or the name of
a server to be found in ~/.emacs.servers.  I.e. if there is no unix socket
of that name, lookup ~/.emacs.servers for TCP servers.

> The last change has been to make it consider \path and c:path as absolute
> paths (previously it would prepend the current directory to Windows-style
> absolute paths).

Of course this should only be done under w32.

> environments it'd be posible to use emacsclient/server.el with a fixed
> address/port and no .emacs.server file (emacsclient would have to grow
> --server-address and --server-port options, of course).

What would be the benefit?


        Stefan

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

* Re: w32 does not have emacsclient/server
  2005-08-08 23:49               ` Stefan Monnier
@ 2005-08-09  0:12                 ` Juanma Barranquero
  2005-08-10  0:42                   ` Stefan Monnier
  2005-08-09  0:19                 ` Juanma Barranquero
  1 sibling, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-09  0:12 UTC (permalink / raw)
  Cc: Emacs Devel

On 8/9/05, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Sounds very good.  To the host, port, and auth, I'd add a "server
> name" entry, which would default to "server", to reproduce the
> socket-name thingy.

OK.

> > In emacsclient.c I've got rid of all AF_UNIX stuff.

> Doesn't sound so good.  I'd rather make it possible to choose between Unix
> and TCP sockets (default to Unix when possible, and TCP otherwise).

Oh. Well, the AF_UNIX code should be conditionally commented out on
Windows, or do you mean to choose at run-time?

> I'd rather see "server-name" which could be a path to a unix socket (like
> now) or just a relative name of a unix socket (like now) or the name of
> a server to be found in ~/.emacs.servers.  I.e. if there is no unix socket
> of that name, lookup ~/.emacs.servers for TCP servers.

I'm not sure I'm getting what you intend with this. Why would you do
have several servers on the same .emacs.server(s) file?

  - To run several instances of Emacs, each one a server, using the
same .emacs.server? I think that would cause all kinds of race
conditions; it'd be better to simply use different server files.

  - Or, for one single Emacs to have several server instances? I don't
think anything is gained there, in particular if you're going to have
the .emacs.server readable for clients (meaning that if they can read
the file, they can read all authorizations). OTOH, having different
servers *with different server files* could be useful.

> > The last change has been to make it consider \path and c:path as absolute
> > paths (previously it would prepend the current directory to Windows-style
> > absolute paths).
> 
> Of course this should only be done under w32.

Why? As I see it, the name you send is interpreted by the server, so
the client has to be able to send absolute and relative paths for all
environments (in fact, VMS or Mac ones should also be grokked, if
emacsclient works on these environments). I mean, if I'm on a
GNU/Linux, and the server is running on a Windows machine, emacsclient
c:\my\file.txt is likely to be a file on the server...

> > environments it'd be posible to use emacsclient/server.el with a fixed
> > address/port and no .emacs.server file (emacsclient would have to grow
> > --server-address and --server-port options, of course).
> 
> What would be the benefit?

On low-security setups (like the ones I'm gonna find myself 99% of the
time) I could just define an alias toem=`emacsclient --auth=myauth
--host=myhost --port=myport' and not worry about setting reading
permissions on the server's %HOME% dir.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-08 23:49               ` Stefan Monnier
  2005-08-09  0:12                 ` Juanma Barranquero
@ 2005-08-09  0:19                 ` Juanma Barranquero
  2005-08-10  0:49                   ` Stefan Monnier
  1 sibling, 1 reply; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-09  0:19 UTC (permalink / raw)
  Cc: Emacs Devel

On 8/9/05, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> I'd rather see "server-name" which could be a path to a unix socket (like
> now) or just a relative name of a unix socket (like now) or the name of
> a server to be found in ~/.emacs.servers.  I.e. if there is no unix socket
> of that name, lookup ~/.emacs.servers for TCP servers.

Another thing: that would mean having to decide whether you're
creating an AF_UNIX or AF_INET server, and if the former, connection
from some non-Unix emacsclients (like Windows) would be impossible. Is
that a bug or a feature?

I'm really not convinced than keeping both Unix sockets and TCP/IP
sockets is a good idea. I'm open to being convinced otherwise, though.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-07 20:31                                     ` Juanma Barranquero
@ 2005-08-09  0:26                                       ` Richard M. Stallman
  2005-08-09  0:39                                         ` Juanma Barranquero
  0 siblings, 1 reply; 74+ messages in thread
From: Richard M. Stallman @ 2005-08-09  0:26 UTC (permalink / raw)
  Cc: emacs-devel

    Don't you think that TCP servers on Windows taking 100% CPU is a bug
    worth fixing before the release?

It is worth fixing if possible, though not quite as important because
it only affects a non-free non-GNU-like system.

But what has that got to do with this, anyway?
I was responding to the following:

    Yes.  And it might be reasonable to postpone _that_ until after the
    release.  Even though it would probably be of the "don't use it, and
    it won't break anything" variety.

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

* Re: w32 does not have emacsclient/server
  2005-08-09  0:26                                       ` Richard M. Stallman
@ 2005-08-09  0:39                                         ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-09  0:39 UTC (permalink / raw)
  Cc: emacs-devel

On 8/9/05, Richard M. Stallman <rms@gnu.org> wrote:

> But what has that got to do with this, anyway?

You said:

> I would really like it if people would turn their attention
> from this to the tasks listed in FOR-RELEASE.

Which I took to mean, turn the attention from the changes to
server/emacsclient and everything related to it that had sprung
recently. Sorry if I misunderstood you.

-- 
                    /L/e/k/t/u

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

* Re: w32 does not have emacsclient/server
  2005-08-09  0:12                 ` Juanma Barranquero
@ 2005-08-10  0:42                   ` Stefan Monnier
  0 siblings, 0 replies; 74+ messages in thread
From: Stefan Monnier @ 2005-08-10  0:42 UTC (permalink / raw)
  Cc: Emacs Devel

>> > In emacsclient.c I've got rid of all AF_UNIX stuff.
>> Doesn't sound so good.  I'd rather make it possible to choose between Unix
>> and TCP sockets (default to Unix when possible, and TCP otherwise).
> Oh. Well, the AF_UNIX code should be conditionally commented out on
> Windows, or do you mean to choose at run-time?

As much as possible, it should be chosen at runtime, but under w32, the
choice would have to be done at compile time since IIRC AF_UNIX doesn't
exist, so the compilation would otherwise fail.

>> I'd rather see "server-name" which could be a path to a unix socket (like
>> now) or just a relative name of a unix socket (like now) or the name of
>> a server to be found in ~/.emacs.servers.  I.e. if there is no unix socket
>> of that name, lookup ~/.emacs.servers for TCP servers.

> I'm not sure I'm getting what you intend with this. Why would you do
> have several servers on the same .emacs.server(s) file?

>   - To run several instances of Emacs, each one a server, using the
> same .emacs.server? I think that would cause all kinds of race
> conditions; it'd be better to simply use different server files.

Maybe you're right, and .emacs.servers should be a directory.
So if you run emacsclient --server-name foo it would look for
/tmp/emacs<uid>/foo for a unix socket and if that fails it'd look for
~/.emacs.servers/foo for a file holding the host/port/auth info.

>> Sounds very good.  To the host, port, and auth, I'd add a "server
>> name" entry, which would default to "server", to reproduce the
>> socket-name thingy.
> OK.

If the server name is in the file name, it doesn't need to be added inside
the file.

>   - Or, for one single Emacs to have several server instances? I don't

I'm not sure this can currently work.  I wouldn't worry about this case.

>> > The last change has been to make it consider \path and c:path as absolute
>> > paths (previously it would prepend the current directory to Windows-style
>> > absolute paths).
>> 
>> Of course this should only be done under w32.

> Why? As I see it, the name you send is interpreted by the server, so
> the client has to be able to send absolute and relative paths for all
> environments (in fact, VMS or Mac ones should also be grokked, if
> emacsclient works on these environments). I mean, if I'm on a
> GNU/Linux, and the server is running on a Windows machine, emacsclient
> c:\my\file.txt is likely to be a file on the server...

I'd basically assume that cross-host uses would only work right if both
machines share the same file-system (and layout).  In other cases, it's not
really clear which behavior is right in which case.  I.e. in your example
where the command issued on the client refers to a path on the server, it
may be preferable to use --eval (find-file "c:\\my\\file.txt") to make it
clear what is the intention.  After all, * and other meta chars will be
handled by the shell under the assumption that the argument to emacsclient
is a local file name.


        Stefan

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

* Re: w32 does not have emacsclient/server
  2005-08-09  0:19                 ` Juanma Barranquero
@ 2005-08-10  0:49                   ` Stefan Monnier
  2005-08-10  0:58                     ` Juanma Barranquero
  0 siblings, 1 reply; 74+ messages in thread
From: Stefan Monnier @ 2005-08-10  0:49 UTC (permalink / raw)
  Cc: Emacs Devel

>> I'd rather see "server-name" which could be a path to a unix socket (like
>> now) or just a relative name of a unix socket (like now) or the name of
>> a server to be found in ~/.emacs.servers.  I.e. if there is no unix socket
>> of that name, lookup ~/.emacs.servers for TCP servers.

> Another thing: that would mean having to decide whether you're
> creating an AF_UNIX or AF_INET server,

My text above refers to the emacsclient case.  For the server, of course you
want the choice between Unix and TCP to be done explicitly via a configuration.

> and if the former, connection from some non-Unix emacsclients (like
> Windows) would be impossible. Is that a bug or a feature?

If the socket is a Unix socket, connection is not possible remotely, so
every client will necessarily be a (or rather THE) unix client.

> I'm really not convinced than keeping both Unix sockets and TCP/IP
> sockets is a good idea. I'm open to being convinced otherwise, though.

The new TCP code is unlikely to be as problem free, so for the sake of
ensuring that what used to work still works, I'd recommend you write your
patch such that when the old code worked, it will work just as smoothly as
before (i.e. use Unix sockets by default when available) and only when the
old code didn't work use TCP sockets (which then won't be much worse than
before unless you introduced a security hole).


        Stefan

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

* Re: w32 does not have emacsclient/server
  2005-08-10  0:49                   ` Stefan Monnier
@ 2005-08-10  0:58                     ` Juanma Barranquero
  0 siblings, 0 replies; 74+ messages in thread
From: Juanma Barranquero @ 2005-08-10  0:58 UTC (permalink / raw)
  Cc: Emacs Devel

On 8/10/05, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> The new TCP code is unlikely to be as problem free, so for the sake of
> ensuring that what used to work still works, I'd recommend you write your
> patch such that when the old code worked, it will work just as smoothly as
> before

OK, I'll get back to work with all your suggestions.

"Don't call us, we will call you" ;-)

-- 
                    /L/e/k/t/u

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

end of thread, other threads:[~2005-08-10  0:58 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-15 15:36 w32 does not have emacsclient/server klaus.berndl
2005-07-16 13:28 ` Juanma Barranquero
  -- strict thread matches above, loose matches on Subject: below --
2005-07-15  7:01 Lennart Borgman
2005-07-15  8:29 ` Jason Rumney
2005-07-15 12:40   ` Lennart Borgman
2005-07-15 15:07     ` David Kastrup
2005-07-15 16:52       ` Lennart Borgman
2005-07-15 18:21     ` Eli Zaretskii
2005-07-16 20:45       ` Richard M. Stallman
2005-07-17  3:33         ` Eli Zaretskii
2005-07-17 17:36           ` Richard M. Stallman
2005-07-17 18:09             ` Eli Zaretskii
2005-07-18 16:33               ` Richard M. Stallman
2005-07-15  8:31 ` David Kastrup
2005-07-15 12:21   ` Lennart Borgman
2005-07-15 12:37     ` David Kastrup
2005-07-15 12:50       ` Lennart Borgman
2005-07-15 15:12         ` David Kastrup
2005-07-15 14:33     ` Jason Rumney
2005-07-15 14:52       ` Lennart Borgman
2005-07-15 15:15         ` David Kastrup
2005-07-15 20:28           ` Stefan Monnier
2005-07-27 14:34             ` Juanma Barranquero
2005-07-27 15:45               ` Jason Rumney
2005-07-27 16:16                 ` Juanma Barranquero
2005-07-27 16:31                   ` Jason Rumney
2005-07-28 17:20                   ` Stefan Monnier
2005-08-05  1:43             ` Juanma Barranquero
2005-08-05  7:59               ` Juanma Barranquero
2005-08-05  9:02                 ` Eli Zaretskii
2005-08-05  9:09                   ` Juanma Barranquero
2005-08-05 18:50                     ` Eli Zaretskii
2005-08-05 23:10                       ` Juanma Barranquero
2005-08-06  6:55                         ` Eli Zaretskii
2005-08-06  7:12                           ` Jason Rumney
2005-08-06  8:10                             ` Eli Zaretskii
2005-08-06  9:30                               ` Lennart Borgman
2005-08-06 11:08                                 ` Stephan Stahl
2005-08-06 14:48                                 ` Eli Zaretskii
2005-08-06 11:21                               ` Juanma Barranquero
2005-08-06 14:52                                 ` Eli Zaretskii
2005-08-05 20:38                     ` Richard M. Stallman
2005-08-05 21:34                       ` David Kastrup
2005-08-05 23:12                       ` Juanma Barranquero
2005-08-05 23:48                         ` Lennart Borgman
2005-08-06  0:02                           ` Juanma Barranquero
2005-08-06  6:58                             ` Eli Zaretskii
2005-08-06 11:20                               ` Juanma Barranquero
2005-08-06 12:43                                 ` David Kastrup
2005-08-06 13:43                                   ` Juanma Barranquero
2005-08-06 17:45                                 ` Jason Rumney
2005-08-06 17:54                                   ` Juanma Barranquero
2005-08-06  6:59                             ` David Kastrup
2005-08-06 13:45                               ` Juanma Barranquero
2005-08-06 14:03                                 ` David Kastrup
2005-08-07 17:15                                   ` Richard M. Stallman
2005-08-07 20:31                                     ` Juanma Barranquero
2005-08-09  0:26                                       ` Richard M. Stallman
2005-08-09  0:39                                         ` Juanma Barranquero
2005-08-06 18:35                         ` Richard M. Stallman
2005-08-06 18:44                           ` Juanma Barranquero
2005-08-05 11:06                 ` Juanma Barranquero
2005-08-08 23:49               ` Stefan Monnier
2005-08-09  0:12                 ` Juanma Barranquero
2005-08-10  0:42                   ` Stefan Monnier
2005-08-09  0:19                 ` Juanma Barranquero
2005-08-10  0:49                   ` Stefan Monnier
2005-08-10  0:58                     ` Juanma Barranquero
2005-07-15 15:13       ` Juanma Barranquero
2005-07-15 15:48         ` David Kastrup
2005-07-18  6:22           ` Juanma Barranquero
2005-07-15 17:15         ` Lennart Borgman
2005-07-15 23:24           ` Robert J. Chassell
2005-07-15 17:53   ` Guy Gascoigne - Piggford

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.