unofficial mirror of emacs-devel@gnu.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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server
  2005-07-15  7:01 w32 does not have emacsclient/server 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server
  2005-07-15  7:01 w32 does not have emacsclient/server 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; 120+ 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] 120+ 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     ` w32 does not have emacsclient/server Jason Rumney
  2005-07-15 17:53   ` Guy Gascoigne - Piggford
  1 sibling, 2 replies; 120+ 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] 120+ 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     ` w32 does not have emacsclient/server Jason Rumney
  1 sibling, 1 reply; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server
  2005-07-15 14:33     ` w32 does not have emacsclient/server 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; 120+ 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] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server
  2005-07-15 12:50       ` Lennart Borgman
@ 2005-07-15 15:12         ` David Kastrup
  2005-07-15 16:59           ` w32 does not have emacsclient/server - getting paper size Lennart Borgman
  0 siblings, 1 reply; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server
  2005-07-15 14:33     ` w32 does not have emacsclient/server 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 15:12         ` David Kastrup
@ 2005-07-15 16:59           ` Lennart Borgman
  2005-07-15 17:13             ` David Kastrup
  0 siblings, 1 reply; 120+ messages in thread
From: Lennart Borgman @ 2005-07-15 16:59 UTC (permalink / raw)
  Cc: Emacs Devel

David Kastrup wrote:

>>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.
>  
>
Are you suggesting that this can be done on w32? Can you then give me 
some pointers?

Are you also saying that if it can not be done this way on w32 then we 
should not do it at all?

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 16:59           ` w32 does not have emacsclient/server - getting paper size Lennart Borgman
@ 2005-07-15 17:13             ` David Kastrup
  2005-07-15 17:55               ` Lennart Borgman
  0 siblings, 1 reply; 120+ messages in thread
From: David Kastrup @ 2005-07-15 17:13 UTC (permalink / raw)
  Cc: Emacs Devel

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

> David Kastrup wrote:
>
>>>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.
>>  
>>
> Are you suggesting that this can be done on w32? Can you then give me
> some pointers?

I am not suggesting any such thing.  I know nothing whatsoever about
w32 and I consider life too short to change anything about that.

What is your complaint?  That some feature is not present at all, that
it is present only on platforms other than w32, or that you would want
it to be available only on w32?

> Are you also saying that if it can not be done this way on w32 then
> we should not do it at all?

I am saying that _if_ it is done, it should not be done only on w32.
As long as the feature is made available on the free platforms, it is
no problem if the details of the implementation on w32 differ.  But it
is not a good idea to just implement stuff Windows-only.  Emacs does
not have as a goal to _force_ people to use proprietary systems if
they hope to achieve something.

If Microsoft offered a hundred programmers to work on improving Emacs,
that would be an offer not lightly turned down.  But they would not be
permitted to improve Emacs just for the sake of Windows.

I have no idea what you are complaining about actually with regard to
the paper size.  It appears that you are currently in a bad mood and
can't be bothered describing _any_ problem concretely enough so that
it would even make sense talking about it.  It is unclear what
functionality is not implemented on what platforms and for what
reasons, and why you think that somebody is sabotaging the
implementation or whatever.

Please, stop this pointless unfocused bickering.  It is taking time
and attention from work that needs to be done, at the same time being
so unspecific that it is completely unclear what this is even supposed
to be about.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 17:13             ` David Kastrup
@ 2005-07-15 17:55               ` Lennart Borgman
  2005-07-15 21:20                 ` Jason Rumney
  2005-07-16  9:54                 ` Eli Zaretskii
  0 siblings, 2 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-15 17:55 UTC (permalink / raw)
  Cc: Emacs Devel

David Kastrup wrote:

>I am not suggesting any such thing.  I know nothing whatsoever about
>w32 and I consider life too short to change anything about that.
>  
>
Sorry, I thought you did.

>I have no idea what you are complaining about actually with regard to
>the paper size.  It appears that you are currently in a bad mood and
>can't be bothered describing _any_ problem concretely enough so that
>it would even make sense talking about it.  It is unclear what
>functionality is not implemented on what platforms and for what
>reasons, and why you think that somebody is sabotaging the
>implementation or whatever.
>
It seems to have been a bad time mention this. The problem here is the 
different architectures between unix like OS:s and w32. If you are not 
interested in w32 then that is ok, but please do not assume that I write 
about intentions (like sabotage).

I can for sure be more specific. Paper size on w32 must be fetched from 
the windows Registry because it is stored there. All major applications 
on w32 I know of does this. An implementation for accessing Registry on 
w32 was offered some years ago, but was not accepted. It is of course a 
w32 only solution, since the same things are accessed differently on 
unix like OS:es. But it actually in my opinion makes Emacs a bit less 
powerful on w32 that it can not access the registry.

I do not expect you do comment on the details of this. I would however 
hope that you like to see the big picture.

^ permalink raw reply	[flat|nested] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 17:55               ` Lennart Borgman
@ 2005-07-15 21:20                 ` Jason Rumney
  2005-07-15 21:39                   ` Lennart Borgman
  2005-07-16  9:54                 ` Eli Zaretskii
  1 sibling, 1 reply; 120+ messages in thread
From: Jason Rumney @ 2005-07-15 21:20 UTC (permalink / raw)
  Cc: Emacs Devel

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

> An implementation for accessing Registry on w32 was offered some
> years ago, but was not accepted.

I don't recall this. If it was anything like most such offers, someone
submitted some code, the Emacs developers suggested some improvements,
and we never heard from the author on that topic again.

But anyway, reading specific settings from the registry does not
require general registry editing functionality.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 21:20                 ` Jason Rumney
@ 2005-07-15 21:39                   ` Lennart Borgman
  2005-07-15 22:00                     ` David Kastrup
  2005-07-16 10:00                     ` Eli Zaretskii
  0 siblings, 2 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-15 21:39 UTC (permalink / raw)
  Cc: Emacs Devel

Jason Rumney wrote:

>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>
>  
>
>>An implementation for accessing Registry on w32 was offered some
>>years ago, but was not accepted.
>>    
>>
>
>I don't recall this. If it was anything like most such offers, someone
>submitted some code, the Emacs developers suggested some improvements,
>and we never heard from the author on that topic again.
>  
>
I was not here then, it is history for me, so I am not sure about all 
details. I believe Steve Kemp implemented this. I think I have seen 
several versions though. I just checked the net and could not find the 
version I was thinking of.

This included capabilities to right to the Registry (if I remember 
correctly), but I consider those potentially harmful. Writing should be 
done under very good control (since it could make a disaster) and I do 
not consider even an editor as Emacs as giving that tight control.

>But anyway, reading specific settings from the registry does not
>require general registry editing functionality.
>  
>
I see no reason why Emacs should be able to edit the w32 Registry, but 
reading it would be very convenient. It should not be seen as giving 
Emacs extra features on w32. Rather it is another way to accomplish the 
same thing that are already easily accomplished on unix like systems. 
(At least I believe that this is the state.)

Paper size is one I remember right now. Another is the location of 
Ghostscript. If Emacs could read the registry then such things would be 
easy to get by just writing some elisp code for it. Am I not right 
assuming that these things are already easy to get on unix like systems?

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 21:39                   ` Lennart Borgman
@ 2005-07-15 22:00                     ` David Kastrup
  2005-07-15 22:13                       ` Lennart Borgman
  2005-07-16 10:00                     ` Eli Zaretskii
  1 sibling, 1 reply; 120+ messages in thread
From: David Kastrup @ 2005-07-15 22:00 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

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

> I see no reason why Emacs should be able to edit the w32 Registry,
> but reading it would be very convenient. It should not be seen as
> giving Emacs extra features on w32. Rather it is another way to
> accomplish the same thing that are already easily accomplished on
> unix like systems. (At least I believe that this is the state.)
>
> Paper size is one I remember right now. Another is the location of
> Ghostscript. If Emacs could read the registry then such things would
> be easy to get by just writing some elisp code for it. Am I not
> right assuming that these things are already easy to get on unix
> like systems?

I don't see that Emacs has an interface into the locale in general
which would be required for reading the papersize setting.  And the
usual way for GhostScript is just to look for "gs" in the exec path.
Since the process shell does that already, "gs" is usually used as the
default command.  There is no separate database to search for such
information.  That's what PATH is for.

So if one built a general interface into stuff like the paper size,
and then filled it with life also on the free systems, doing the same
on w32 would not violate any policies.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 22:00                     ` David Kastrup
@ 2005-07-15 22:13                       ` Lennart Borgman
  2005-07-15 22:33                         ` David Kastrup
  2005-07-15 23:09                         ` Jason Rumney
  0 siblings, 2 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-15 22:13 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

David Kastrup wrote:

>I don't see that Emacs has an interface into the locale in general
>which would be required for reading the papersize setting.  And the
>usual way for GhostScript is just to look for "gs" in the exec path.
>Since the process shell does that already, "gs" is usually used as the
>default command.  There is no separate database to search for such
>information.  That's what PATH is for.
>  
>
Ghostscript is not installed that way on w32. It is not supposed to be 
find in the PATH. That is because the w32 "architecture" is different. 
You can only find Ghostscript through the registry (or searching the 
whole disk ;-)

>So if one built a general interface into stuff like the paper size,
>and then filled it with life also on the free systems, doing the same
>on w32 would not violate any policies.
>
That would be very nice. The problem is however that until this is done 
Emacs is kind of a second class citizen that do not have access to 
things all other w32 programs has. And that makes for a bad impression. 
Am I right in assuming that the lack of this capability on for example 
GNU/Linux does not give such an impression?

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 22:13                       ` Lennart Borgman
@ 2005-07-15 22:33                         ` David Kastrup
  2005-07-15 23:07                           ` Lennart Borgman
  2005-07-16  9:48                           ` Eli Zaretskii
  2005-07-15 23:09                         ` Jason Rumney
  1 sibling, 2 replies; 120+ messages in thread
From: David Kastrup @ 2005-07-15 22:33 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

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

> David Kastrup wrote:
>
>>I don't see that Emacs has an interface into the locale in general
>>which would be required for reading the papersize setting.  And the
>>usual way for GhostScript is just to look for "gs" in the exec path.
>>Since the process shell does that already, "gs" is usually used as
>>the default command.  There is no separate database to search for
>>such information.  That's what PATH is for.
>>  
>>
> Ghostscript is not installed that way on w32. It is not supposed to
> be find in the PATH. That is because the w32 "architecture" is
> different. You can only find Ghostscript through the registry (or
> searching the whole disk ;-)

Does not sound too intelligent.

>>So if one built a general interface into stuff like the paper size,
>>and then filled it with life also on the free systems, doing the
>>same on w32 would not violate any policies.
>>
> That would be very nice. The problem is however that until this is
> done Emacs is kind of a second class citizen that do not have access
> to things all other w32 programs has.  And that makes for a bad
> impression.

Not half as bad as Emacs catering for w32 better than for free
systems.  We don't want people to get started on Emacs on w32 to find
themselves in the situation that they don't want to switch operating
systems because then Emacs will fail to work.

So unless the registry access is required for implementing some
cross-platform functionality, there is no motivation to add it into
Emacs because that would only encourage unportable applications.

If you find that you are missing something like paper size, then this
shortcoming is not a w32-specific one, and "solving" this by providing
registry access is a w32-only solution.  No thanks.

The right way to go about this is first to create an API that is
useful across operating systems.  Then this API can be filled with
life.  It would appear that on Posix system, this would entail a
read-only interface into setlocale(3), and maybe on w32 reading
registry keys.  Whether those interfaces should be exposed to Lisp, is
a different question.  It would make sense to define this stuff with
the Posix semantics, and then let w32-specific code translate this
into the respective registry reading calls.

That way, the functionality is accessible, and people don't get hooked
on Windows _because_ of Emacs.

> Am I right in assuming that the lack of this capability on for
> example GNU/Linux does not give such an impression?

What capability?  Reading the registry?  Don't be silly.  Querying the
paper size?  Well, I don't see why that omission should be less of a
problem on a Unix-like operating system.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 22:33                         ` David Kastrup
@ 2005-07-15 23:07                           ` Lennart Borgman
  2005-07-16  6:14                             ` David Kastrup
  2005-07-16  9:48                           ` Eli Zaretskii
  1 sibling, 1 reply; 120+ messages in thread
From: Lennart Borgman @ 2005-07-15 23:07 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

David Kastrup wrote:

>>Ghostscript is not installed that way on w32. It is not supposed to
>>be find in the PATH. That is because the w32 "architecture" is
>>different. You can only find Ghostscript through the registry (or
>>searching the whole disk ;-)
>>    
>>
>
>Does not sound too intelligent.
>  
>
I believe that this was my first thought long ago too, but I am actually 
not sure it is not an intelligent solution. You have to have more of the 
picture to decide that I believe.

>>That would be very nice. The problem is however that until this is
>>done Emacs is kind of a second class citizen that do not have access
>>to things all other w32 programs has.  And that makes for a bad
>>impression.
>>    
>>
>
>So unless the registry access is required for implementing some
>cross-platform functionality, there is no motivation to add it into
>Emacs because that would only encourage unportable applications.
>
>The right way to go about this is first to create an API that is
>useful across operating systems.  Then this API can be filled with
>life.  It would appear that on Posix system, this would entail a
>read-only interface into setlocale(3), and maybe on w32 reading
>registry keys.  Whether those interfaces should be exposed to Lisp, is
>a different question.  It would make sense to define this stuff with
>the Posix semantics, and then let w32-specific code translate this
>into the respective registry reading calls.
>  
>
Yes, I agree.  On w32 I think at least new users would expect this to 
work. If we want them to switch to GNU/Linux then I believe we should 
anticipate that they will expect this on GNU/Linux too. If you think 
this is the right way to go then I would be glad if you (or someone 
else) did this for Posix systems. Then I (or someone else) will 
implement this on w32 because at least I feel it is the right way to go.

>What capability?  Reading the registry?  Don't be silly.  Querying the
>paper size?  Well, I don't see why that omission should be less of a
>problem on a Unix-like operating system.
>
Fine, then we could perhaps have a common goal in this small but not 
unimportant detail. It is not unimportant since it is part of a bigger 
picture concerning the integration with the OS that new users probably 
do expect.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 22:13                       ` Lennart Borgman
  2005-07-15 22:33                         ` David Kastrup
@ 2005-07-15 23:09                         ` Jason Rumney
  2005-07-15 23:22                           ` Lennart Borgman
  1 sibling, 1 reply; 120+ messages in thread
From: Jason Rumney @ 2005-07-15 23:09 UTC (permalink / raw)
  Cc: Emacs Devel

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

> Ghostscript is not installed that way on w32. It is not supposed to be
> find in the PATH.

Why? It seems very inconvenient to require programs to find other
programs by searching for them manually in a "registry", rather than
using the PATH features that are built into the OS.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 23:09                         ` Jason Rumney
@ 2005-07-15 23:22                           ` Lennart Borgman
  2005-07-15 23:40                             ` Jason Rumney
  2005-07-16  6:02                             ` David Kastrup
  0 siblings, 2 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-15 23:22 UTC (permalink / raw)
  Cc: Emacs Devel

Jason Rumney wrote:

>>Ghostscript is not installed that way on w32. It is not supposed to be
>>find in the PATH.
>>    
>>
>
>Why? It seems very inconvenient to require programs to find other
>programs by searching for them manually in a "registry", rather than
>using the PATH features that are built into the OS.
>  
>
There are several reasons I think. One reason is that installing new 
programs should not change system overall behaviour.

A more important reason is that programs on w32 communicate differently 
than on GNU/Linux. The w32 way, COM (or what the current name for it is, 
it changes now and then), is rather similar to Corba on a conceptual 
level. Programs can call other programs through COM and get a result 
back. The Registry keeps track of the available COM components.

COM is designed as interfaces with version control so it gives a rather 
flexibel environment.

Whatever we think of that this is the w32 way and to integrate in the 
w32 environment as first class citizens this must be accepted.

^ permalink raw reply	[flat|nested] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 23:22                           ` Lennart Borgman
@ 2005-07-15 23:40                             ` Jason Rumney
  2005-07-17  0:58                               ` Richard M. Stallman
  2005-07-16  6:02                             ` David Kastrup
  1 sibling, 1 reply; 120+ messages in thread
From: Jason Rumney @ 2005-07-15 23:40 UTC (permalink / raw)
  Cc: Emacs Devel

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

> A more important reason is that programs on w32 communicate
> differently than on GNU/Linux.

Ghostscript is a port of a Unix program, it communicates the
traditional way through stdio, like any other command-line program.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 23:22                           ` Lennart Borgman
  2005-07-15 23:40                             ` Jason Rumney
@ 2005-07-16  6:02                             ` David Kastrup
  2005-07-16  8:31                               ` Lennart Borgman
  2005-07-16  9:42                               ` Eli Zaretskii
  1 sibling, 2 replies; 120+ messages in thread
From: David Kastrup @ 2005-07-16  6:02 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

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

> Jason Rumney wrote:
>
>>>Ghostscript is not installed that way on w32. It is not supposed to be
>>>find in the PATH.
>>>    
>>>
>>
>>Why? It seems very inconvenient to require programs to find other
>>programs by searching for them manually in a "registry", rather than
>>using the PATH features that are built into the OS.
>>  
>>
> There are several reasons I think. One reason is that installing new
> programs should not change system overall behaviour.

Then why install them in the first place?

> A more important reason is that programs on w32 communicate
> differently than on GNU/Linux. The w32 way, COM (or what the current
> name for it is, it changes now and then), is rather similar to Corba
> on a conceptual level. Programs can call other programs through COM
> and get a result back. The Registry keeps track of the available COM
> components.

Well, PATH keeps track of the available programs.

> COM is designed as interfaces with version control so it gives a
> rather flexibel environment.

What use is there in "interfaces with version control" in a system
that does not even support different versions of DLLs to be installed
at the same time?

> Whatever we think of that this is the w32 way and to integrate in
> the w32 environment as first class citizens this must be accepted.

It is not a goal for Emacs to be a first class w32 citizen.  The goal
for Emacs on Windows is to be as good an Emacs as elsewhere.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 23:07                           ` Lennart Borgman
@ 2005-07-16  6:14                             ` David Kastrup
  2005-07-16  9:46                               ` Eli Zaretskii
  0 siblings, 1 reply; 120+ messages in thread
From: David Kastrup @ 2005-07-16  6:14 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

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

> David Kastrup wrote:
>
>>So unless the registry access is required for implementing some
>>cross-platform functionality, there is no motivation to add it into
>>Emacs because that would only encourage unportable applications.
>>
>>The right way to go about this is first to create an API that is
>>useful across operating systems.  Then this API can be filled with
>>life.  It would appear that on Posix system, this would entail a
>>read-only interface into setlocale(3), and maybe on w32 reading
>>registry keys.  Whether those interfaces should be exposed to Lisp,
>>is a different question.  It would make sense to define this stuff
>>with the Posix semantics, and then let w32-specific code translate
>>this into the respective registry reading calls.
>
> Yes, I agree.  On w32 I think at least new users would expect this
> to work.

Posix queries?  Unlikely.  Really, you should for a change try
spelling out what you mean.

> If we want them to switch to GNU/Linux then I believe we should
> anticipate that they will expect this on GNU/Linux too. If you think
> this is the right way to go then I would be glad if you (or someone
> else) did this for Posix systems. Then I (or someone else) will
> implement this on w32 because at least I feel it is the right way to
> go.

Look, it is getting annoying.  You have not _once_ in this whole
thread clearly spelled out _what_ your problem is and what you want
done.  You only ever talk about "this" being desirable and so on
without ever bothering specifying what "this" is supposed to be and
why it would be interested.

In all of your 20-something post long tirade about the poor persecuted
w32 users, I am still missing a problem description.  Something along
the lines of:

    For this-and-that application, it would be important for Emacs to
    be able to query the operating system's idea of the system paper
    size.  I propose a function getting the following arguments and
    returning the following values.  This should be a part of this and
    that module.  To implement it on w32 would require this and that
    functionality.  I don't know how this would be done on Posix.

>>What capability?  Reading the registry?  Don't be silly.  Querying
>>the paper size?  Well, I don't see why that omission should be less
>>of a problem on a Unix-like operating system.
>>
> Fine, then we could perhaps have a common goal in this small but not
> unimportant detail. It is not unimportant since it is part of a
> bigger picture concerning the integration with the OS that new users
> probably do expect.

The paper size is part of a bigger picture concerning the integration
with the OS?

Could you stop throwing around buzzwords and simply come up with a few
actual examples of what you are talking about in the first place?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  6:02                             ` David Kastrup
@ 2005-07-16  8:31                               ` Lennart Borgman
  2005-07-16  9:03                                 ` David Kastrup
  2005-07-16  9:42                               ` Eli Zaretskii
  1 sibling, 1 reply; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16  8:31 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

David Kastrup wrote:

>>There are several reasons I think. One reason is that installing new
>>programs should not change system overall behaviour.
>>    
>>
>
>Then why install them in the first place?
>  
>
I am sorry but this does not make sense.

>  
>
>>A more important reason is that programs on w32 communicate
>>differently than on GNU/Linux. The w32 way, COM (or what the current
>>name for it is, it changes now and then), is rather similar to Corba
>>on a conceptual level. Programs can call other programs through COM
>>and get a result back. The Registry keeps track of the available COM
>>components.
>>    
>>
>
>Well, PATH keeps track of the available programs.
>  
>
I am sorry again, you are simply oversimplifying.

>What use is there in "interfaces with version control" in a system
>that does not even support different versions of DLLs to be installed
>at the same time?
>  
>
Sorry, but obviously some users care about what version they are using 
and sometimes want to have different versions installed simultaneaously.

>>Whatever we think of that this is the w32 way and to integrate in
>>the w32 environment as first class citizens this must be accepted.
>>    
>>
>
>It is not a goal for Emacs to be a first class w32 citizen.  The goal
>for Emacs on Windows is to be as good an Emacs as elsewhere.
>
I found this comment worth noting. The meaning of what you are writing 
here is not self evident. It must be further developed to be useful.

One thing to think about is for example "what do users on different 
system require of the programs they are using?". Even if users are not 
explicitly mentioned in your statement they are of course implicitly.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  8:31                               ` Lennart Borgman
@ 2005-07-16  9:03                                 ` David Kastrup
  2005-07-16  9:39                                   ` Eli Zaretskii
  0 siblings, 1 reply; 120+ messages in thread
From: David Kastrup @ 2005-07-16  9:03 UTC (permalink / raw)
  Cc: Emacs Devel, Jason Rumney

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

> David Kastrup wrote:
>
>>>There are several reasons I think. One reason is that installing new
>>>programs should not change system overall behaviour.
>>>    
>>>
>>
>>Then why install them in the first place?
>>  
>>
> I am sorry but this does not make sense.

Why bother to install software if it is not intended to make any
difference?

>>>Whatever we think of that this is the w32 way and to integrate in
>>>the w32 environment as first class citizens this must be accepted.
>>
>>It is not a goal for Emacs to be a first class w32 citizen.  The
>>goal for Emacs on Windows is to be as good an Emacs as elsewhere.
>
> I found this comment worth noting. The meaning of what you are
> writing here is not self evident. It must be further developed to be
> useful.
>
> One thing to think about is for example "what do users on different
> system require of the programs they are using?". Even if users are
> not explicitly mentioned in your statement they are of course
> implicitly.

We are not bothered about Windows users.  We are bothered about Emacs
users.  Making Emacs a first class w32 application is not a project
goal.  Making w32 a first class Emacs platform might be one.  It may
not have the same priority as other operating systems, but as long as
somebody is willing to do the work, there is no principal problem as
far as I can see.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  9:03                                 ` David Kastrup
@ 2005-07-16  9:39                                   ` Eli Zaretskii
  0 siblings, 0 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16  9:39 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> From: David Kastrup <dak@gnu.org>
> Date: Sat, 16 Jul 2005 11:03:37 +0200
> Cc: Emacs Devel <emacs-devel@gnu.org>, Jason Rumney <jasonr@gnu.org>
> 
> Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
> 
> > David Kastrup wrote:
> >
> >>>There are several reasons I think. One reason is that installing new
> >>>programs should not change system overall behaviour.
> >>>    
> >>>
> >>
> >>Then why install them in the first place?
> >>  
> >>
> > I am sorry but this does not make sense.
> 
> Why bother to install software if it is not intended to make any
> difference?

David, please stop this attitude.  This thread is complicated even
without nitpicking, and the fact that neither you nor Lennart are
native English speakers doesn't help.  Did you consider the
possibility that you simply misunderstand each other?  If you keenly
don't understand something, may I suggest that next time you ask a
question instead of posting ridicule?

What Lennart was saying (AFAIU) is that installing a program should
not affect the behavior of the parts of the system which have nothing
to do with the program being installed.  For example, installing
Ghostscript should not affect an FTP client such as NcFTP in any way.
If you modify PATH (or any other global environment variable), the
potential for the unwanted effect is there.

Now, I'm not saying that I could sign my name under this principle,
but it certainly isn't ridiculous.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  6:02                             ` David Kastrup
  2005-07-16  8:31                               ` Lennart Borgman
@ 2005-07-16  9:42                               ` Eli Zaretskii
  1 sibling, 0 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16  9:42 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> From: David Kastrup <dak@gnu.org>
> Date: Sat, 16 Jul 2005 08:02:16 +0200
> Cc: Emacs Devel <emacs-devel@gnu.org>, Jason Rumney <jasonr@gnu.org>
> 
> What use is there in "interfaces with version control" in a system
> that does not even support different versions of DLLs to be installed
> at the same time?

Actually, it does.  Perhaps you don't know enough about this issue to
post such definitive opinions.

> The goal for Emacs on Windows is to be as good an Emacs as
> elsewhere.

Yes.  And reaching that goal sometimes requires Windows-only
solutions, as much as reaching the same goal on GNU/Linux sometimes
requires solutions that don't work on any other OS, even on Unix.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  6:14                             ` David Kastrup
@ 2005-07-16  9:46                               ` Eli Zaretskii
  2005-07-16 11:56                                 ` David Kastrup
  2005-07-17  0:59                                 ` Richard M. Stallman
  0 siblings, 2 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16  9:46 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> From: David Kastrup <dak@gnu.org>
> Date: Sat, 16 Jul 2005 08:14:10 +0200
> Cc: Emacs Devel <emacs-devel@gnu.org>, Jason Rumney <jasonr@gnu.org>
> 
> Look, it is getting annoying.  You have not _once_ in this whole
> thread clearly spelled out _what_ your problem is and what you want
> done.

Actually, he did.  Perhaps you weren't listening.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 22:33                         ` David Kastrup
  2005-07-15 23:07                           ` Lennart Borgman
@ 2005-07-16  9:48                           ` Eli Zaretskii
  1 sibling, 0 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16  9:48 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> From: David Kastrup <dak@gnu.org>
> Date: Sat, 16 Jul 2005 00:33:52 +0200
> Cc: Emacs Devel <emacs-devel@gnu.org>, Jason Rumney <jasonr@gnu.org>
> 
> > Ghostscript is not installed that way on w32. It is not supposed to
> > be find in the PATH. That is because the w32 "architecture" is
> > different. You can only find Ghostscript through the registry (or
> > searching the whole disk ;-)
> 
> Does not sound too intelligent.

The fact that it's different from the Posix paradigm does not mean
it's not intelligent.  Modifying global environment variables has its
drawbacks.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 17:55               ` Lennart Borgman
  2005-07-15 21:20                 ` Jason Rumney
@ 2005-07-16  9:54                 ` Eli Zaretskii
  2005-07-16 10:10                   ` Lennart Borgman
  1 sibling, 1 reply; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16  9:54 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Fri, 15 Jul 2005 19:55:13 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> Cc: Emacs Devel <emacs-devel@gnu.org>
> 
> I can for sure be more specific. Paper size on w32 must be fetched from 
> the windows Registry because it is stored there. All major applications 
> on w32 I know of does this.

Here's one plan to attack and solve this problem:

Step 1: Design a Lisp-level API for using the paper size.  This API
should be useful on all supported platforms.  If necessary, discuss
the design here and implement any corrections/suggestions.

Step 2: Implement the API support for the w32 port.  If that needs to
read the Registry, do that in w32-specific files.  (Jason already
said, and I agree, that this doesn't require a general-purpose
facility to read the Registry.  In fact, Emacs already does read the
Registry in several places without having such a GP facility.)

Step 3: Ask experts for other platforms to implement the same
functionality for their configurations.  Better yet, if you have
enough knowledge and/or help from those experts, implement it
yourself, as part of adding this new API.

If the functionality is useful, I don't see why this plan would fail
or be met with resistance.  Do you?

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 21:39                   ` Lennart Borgman
  2005-07-15 22:00                     ` David Kastrup
@ 2005-07-16 10:00                     ` Eli Zaretskii
  2005-07-16 10:28                       ` Lennart Borgman
                                         ` (2 more replies)
  1 sibling, 3 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16 10:00 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Fri, 15 Jul 2005 23:39:44 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> Cc: Emacs Devel <emacs-devel@gnu.org>
> 
> Paper size is one I remember right now. Another is the location of 
> Ghostscript.

How about adding some code to `openp' so that, on w32 platforms, it
would look for the program/file in the Registry, in addition to the
list of directories it gets as its argument?

In other words, searching for a file or a program is already a
functionality for which we have an established API in Emacs.
Extending that API to handle Ghostscript and similar cases is
something that IMHO will be met with less resistance than inventing a
Windows-only API.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  9:54                 ` Eli Zaretskii
@ 2005-07-16 10:10                   ` Lennart Borgman
  0 siblings, 0 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 10:10 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii wrote:

>Here's one plan to attack and solve this problem:
>
>Step 1: Design a Lisp-level API for using the paper size.  This API
>should be useful on all supported platforms.  If necessary, discuss
>the design here and implement any corrections/suggestions.
>
>Step 2: Implement the API support for the w32 port.  If that needs to
>read the Registry, do that in w32-specific files.  (Jason already
>said, and I agree, that this doesn't require a general-purpose
>facility to read the Registry.  In fact, Emacs already does read the
>Registry in several places without having such a GP facility.)
>
>Step 3: Ask experts for other platforms to implement the same
>functionality for their configurations.  Better yet, if you have
>enough knowledge and/or help from those experts, implement it
>yourself, as part of adding this new API.
>
>If the functionality is useful, I don't see why this plan would fail
>or be met with resistance.  Do you?
>
This is very good and I have hoped for this type of suggestions ever 
since I joined here.

I might disagree to whether there should be a general facility to 
reading the Registry, but that is a minor point right now. Just as I 
guess you and Jason think there is a possibility that such a facility is 
misused and w32 only solutions are developed. I believe however that 
they can easily be converted to cross platform solutions and that they 
might help in fact help GNU/Linux by pushing the needs for common access 
of certain things. (But I do not know GNU/Linux sufficiently well. This 
is just a guess and I would welcome corrections.)

Unfortunately I do not know how to do this on other platform. I will 
come back with a suggestion for an interface, if no one does suggest a 
posix style solution before me (which would be very nice!).

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 10:00                     ` Eli Zaretskii
@ 2005-07-16 10:28                       ` Lennart Borgman
  2005-07-16 11:42                         ` Jason Rumney
  2005-07-16 12:13                         ` Eli Zaretskii
  2005-07-16 10:58                       ` Jason Rumney
  2005-07-16 12:00                       ` David Kastrup
  2 siblings, 2 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 10:28 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii wrote:

>>Date: Fri, 15 Jul 2005 23:39:44 +0200
>>From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>>Cc: Emacs Devel <emacs-devel@gnu.org>
>>
>>Paper size is one I remember right now. Another is the location of 
>>Ghostscript.
>>    
>>
>
>How about adding some code to `openp' so that, on w32 platforms, it
>would look for the program/file in the Registry, in addition to the
>list of directories it gets as its argument?
>
>In other words, searching for a file or a program is already a
>functionality for which we have an established API in Emacs.
>Extending that API to handle Ghostscript and similar cases is
>something that IMHO will be met with less resistance than inventing a
>Windows-only API.
>  
>
A note for non w32 users: On w32 application paths are (if the 
installation process is welbehaved) stored in a Registry key under "App 
Paths" (with a path prepended, the registry has an hierarchical view 
looking like a tree structured file system).

For those applications that uses this possibility I think this could be 
used. I found it however a bit hard to think of a seamless way to 
integrate this in openp. Could you elaborate a little bit more?

My primary thoughts are that this could be restricted to the case when 
you search for an .exe file on w32 and this is not found in the path. In 
openp there is needed a piece of w32 specific code at the end that calls 
the w32 procedure. Not too disturbing perhaps. And it should work "out 
of the box" in most places in Emacs. Quite nice.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 10:00                     ` Eli Zaretskii
  2005-07-16 10:28                       ` Lennart Borgman
@ 2005-07-16 10:58                       ` Jason Rumney
  2005-07-16 11:07                         ` Lennart Borgman
  2005-07-16 12:00                       ` David Kastrup
  2 siblings, 1 reply; 120+ messages in thread
From: Jason Rumney @ 2005-07-16 10:58 UTC (permalink / raw)
  Cc: Lennart Borgman, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Fri, 15 Jul 2005 23:39:44 +0200
>> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>> Cc: Emacs Devel <emacs-devel@gnu.org>
>> 
>> Paper size is one I remember right now. Another is the location of 
>> Ghostscript.
>
> How about adding some code to `openp' so that, on w32 platforms, it
> would look for the program/file in the Registry, in addition to the
> list of directories it gets as its argument?

Where do you look? This is the first time I have ever heard of looking
for a path in the registry. You'd need to have a mapping of known
programs to where they store their registry key telling you where their
path is. There is no standard for doing this!

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 10:58                       ` Jason Rumney
@ 2005-07-16 11:07                         ` Lennart Borgman
  2005-07-16 11:50                           ` Jason Rumney
  0 siblings, 1 reply; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 11:07 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

Jason Rumney wrote:

>Eli Zaretskii <eliz@gnu.org> writes:
>
>  
>
>>>Date: Fri, 15 Jul 2005 23:39:44 +0200
>>>From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>>>Cc: Emacs Devel <emacs-devel@gnu.org>
>>>
>>>Paper size is one I remember right now. Another is the location of 
>>>Ghostscript.
>>>      
>>>
>>How about adding some code to `openp' so that, on w32 platforms, it
>>would look for the program/file in the Registry, in addition to the
>>list of directories it gets as its argument?
>>    
>>
>
>Where do you look? This is the first time I have ever heard of looking
>for a path in the registry. You'd need to have a mapping of known
>programs to where they store their registry key telling you where their
>path is. There is no standard for doing this!
>  
>
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\.

There you will find for example a key named firefox.exe under which you 
find the actual path to firefox.exe. But you are right, not all programs 
use this, unfortunately. So in many cases you need a more specific mean 
to get the path, but it is still often in the Registry.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 10:28                       ` Lennart Borgman
@ 2005-07-16 11:42                         ` Jason Rumney
  2005-07-16 12:13                         ` Eli Zaretskii
  1 sibling, 0 replies; 120+ messages in thread
From: Jason Rumney @ 2005-07-16 11:42 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

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

> A note for non w32 users: On w32 application paths are (if the
> installation process is welbehaved) stored in a Registry key under
> "App Paths" (with a path prepended, the registry has an hierarchical
> view looking like a tree structured file system).

This is misleading. The "App Paths" registry key is used for finding
DLLs loaded by that application. Nothing more. To find this registry
key requires knowing where the executable file it, since the path
to this key within the registry is stored in the executable itself.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 11:07                         ` Lennart Borgman
@ 2005-07-16 11:50                           ` Jason Rumney
  2005-07-16 12:26                             ` Eli Zaretskii
  2005-07-16 12:40                             ` Lennart Borgman
  0 siblings, 2 replies; 120+ messages in thread
From: Jason Rumney @ 2005-07-16 11:50 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

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

> HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\.

I see. The path is not as unpredictable as I thought. However, gs.exe
or gswin32.exe is not listed in my registry, even though I have it
installed, so this is not useful for finding ghostscript.

Also, these keys are documented as being extra paths for that
application to find its DLLs. Since the directory where the executable
resides is automatically searched, it is not necessary to include that
path in this key, so it is not a reliable way to find the executable.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  9:46                               ` Eli Zaretskii
@ 2005-07-16 11:56                                 ` David Kastrup
  2005-07-17  3:30                                   ` Eli Zaretskii
  2005-07-17  0:59                                 ` Richard M. Stallman
  1 sibling, 1 reply; 120+ messages in thread
From: David Kastrup @ 2005-07-16 11:56 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: David Kastrup <dak@gnu.org>
>> Date: Sat, 16 Jul 2005 08:14:10 +0200
>> Cc: Emacs Devel <emacs-devel@gnu.org>, Jason Rumney <jasonr@gnu.org>
>> 
>> Look, it is getting annoying.  You have not _once_ in this whole
>> thread clearly spelled out _what_ your problem is and what you want
>> done.
>
> Actually, he did.  Perhaps you weren't listening.

Perhaps.  So what is the particular application for which he needs the
system paper size, and who has vetoed that anything be implemented
that would make it accessible?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 10:00                     ` Eli Zaretskii
  2005-07-16 10:28                       ` Lennart Borgman
  2005-07-16 10:58                       ` Jason Rumney
@ 2005-07-16 12:00                       ` David Kastrup
  2005-07-17  3:32                         ` Eli Zaretskii
  2 siblings, 1 reply; 120+ messages in thread
From: David Kastrup @ 2005-07-16 12:00 UTC (permalink / raw)
  Cc: Lennart Borgman, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Fri, 15 Jul 2005 23:39:44 +0200
>> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>> Cc: Emacs Devel <emacs-devel@gnu.org>
>> 
>> Paper size is one I remember right now. Another is the location of
>> Ghostscript.
>
> How about adding some code to `openp' so that, on w32 platforms, it
> would look for the program/file in the Registry, in addition to the
> list of directories it gets as its argument?

I remember just being told that the main advantage of the registry was
that it was able to refer to several different installed versions of
the same software.

I don't see how this would be able to disambiguate between those
installed versions.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 10:28                       ` Lennart Borgman
  2005-07-16 11:42                         ` Jason Rumney
@ 2005-07-16 12:13                         ` Eli Zaretskii
  2005-07-16 12:44                           ` Lennart Borgman
  2005-07-16 21:57                           ` Jason Rumney
  1 sibling, 2 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16 12:13 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Sat, 16 Jul 2005 12:28:20 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> CC: emacs-devel@gnu.org
> 
> I found it however a bit hard to think of a seamless way to 
> integrate this in openp. Could you elaborate a little bit more?

Something like a call to a w32-specific function (whose code should be
in some w32*.c file) near the beginning of openp sounds like the right
thing to do.

(I'm suggesting to look in the Registry _before_ you look along PATH
because this is simpler and faster.  But if there are good reasons to
look along PATH first, let's hear them.)

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 11:50                           ` Jason Rumney
@ 2005-07-16 12:26                             ` Eli Zaretskii
  2005-07-16 12:53                               ` Lennart Borgman
  2005-07-16 12:40                             ` Lennart Borgman
  1 sibling, 1 reply; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16 12:26 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> From: Jason Rumney <jasonr@gnu.org>
> Date: Sat, 16 Jul 2005 12:50:14 +0100
> 
> Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
> 
> > HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\.
> 
> I see. The path is not as unpredictable as I thought. However, gs.exe
> or gswin32.exe is not listed in my registry, even though I have it
> installed, so this is not useful for finding ghostscript.

We have a specific situation where looking in the Registry was
suggested: finding Ghostscript.  Lennart, can you tell how the
Registry is used to find Ghostscript, and what applications do that?
Then we could reason about possible utility of whatever those
applications do to our case.

Without the specifics, this argument sounds a bit academic.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 11:50                           ` Jason Rumney
  2005-07-16 12:26                             ` Eli Zaretskii
@ 2005-07-16 12:40                             ` Lennart Borgman
  2005-07-16 13:29                               ` Eli Zaretskii
  1 sibling, 1 reply; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 12:40 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

Jason Rumney wrote:

>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>
>  
>
>>HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\.
>>    
>>
>
>I see. The path is not as unpredictable as I thought. However, gs.exe
>or gswin32.exe is not listed in my registry, even though I have it
>installed, so this is not useful for finding ghostscript.
>  
>
Yes, at the moment not, but I think this is something the authors of 
this packages should be noted of.

>Also, these keys are documented as being extra paths for that
>application to find its DLLs. Since the directory where the executable
>resides is automatically searched, it is not necessary to include that
>path in this key, so it is not a reliable way to find the executable.
>
I do not think it is only for DLLs. I can not say that MS is very clear 
in their documentation, some info is hard to find. But look here, this 
page says that ShellExecute looks in App Paths:

   
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/fileassociations/fa_perceived_types.asp

If you have firefox installed (and you do not have it in your path) you 
can try this:

   Open "Start Menu - Run" and enter firefox.exe.

It will start Firefox. However just typing "firefox.exe" in a cmd.exe 
window does not work. This could be by intent (backward compatibility, 
trying to behave as other shells) or just a bug.

In any case I believe that looking in App Paths for an entry could be 
useful -- and this behaviour would be in accordance with what 
ShellExecute does. Unfortunately it is for many applications more 
difficult to find the path. This is actually one of the reasons I think 
there should be a way to read the Registry from elisp.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 12:13                         ` Eli Zaretskii
@ 2005-07-16 12:44                           ` Lennart Borgman
  2005-07-16 21:57                           ` Jason Rumney
  1 sibling, 0 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 12:44 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii wrote:

>>Date: Sat, 16 Jul 2005 12:28:20 +0200
>>From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>>CC: emacs-devel@gnu.org
>>
>>I found it however a bit hard to think of a seamless way to 
>>integrate this in openp. Could you elaborate a little bit more?
>>    
>>
>
>Something like a call to a w32-specific function (whose code should be
>in some w32*.c file) near the beginning of openp sounds like the right
>thing to do.
>
>(I'm suggesting to look in the Registry _before_ you look along PATH
>because this is simpler and faster.  But if there are good reasons to
>look along PATH first, let's hear them.)
>
I think the page I sent a link to in reply to Jason suggests that 
looking in the Registry is done after searching the pach for 
ShellExecute. Testing the behaviour from Start Menu - Run also suggests 
so. So I think it should be at the end.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 12:26                             ` Eli Zaretskii
@ 2005-07-16 12:53                               ` Lennart Borgman
  2005-07-16 13:22                                 ` Eli Zaretskii
  0 siblings, 1 reply; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 12:53 UTC (permalink / raw)
  Cc: emacs-devel, Jason Rumney

Eli Zaretskii wrote:

>>Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
>>From: Jason Rumney <jasonr@gnu.org>
>>Date: Sat, 16 Jul 2005 12:50:14 +0100
>>
>>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>>
>>    
>>
>>>HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\.
>>>      
>>>
>>I see. The path is not as unpredictable as I thought. However, gs.exe
>>or gswin32.exe is not listed in my registry, even though I have it
>>installed, so this is not useful for finding ghostscript.
>>    
>>
>
>We have a specific situation where looking in the Registry was
>suggested: finding Ghostscript.  Lennart, can you tell how the
>Registry is used to find Ghostscript, and what applications do that?
>Then we could reason about possible utility of whatever those
>applications do to our case.
>
>Without the specifics, this argument sounds a bit academic.
>  
>
In the case of Ghostscript it is actually quite complicated. I have code 
for finding Ghostscript in the file w32-regdat.el which is part of 
EmacsW32. This uses an external program to read the Registry. The actual 
Registry interface is in w32-reg-iface.el (also in EmacsW32).

It is quite much code to put here on the list. If this is interesting 
for the arguments here then maybe you could look in the zip file found here:

   http://ourcomments.org/Emacs/DL/EmacsW32/

Finding GSview is in contrast very simple since it is in App Paths.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 12:53                               ` Lennart Borgman
@ 2005-07-16 13:22                                 ` Eli Zaretskii
  2005-07-16 13:36                                   ` Lennart Borgman
  0 siblings, 1 reply; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16 13:22 UTC (permalink / raw)
  Cc: emacs-devel, jasonr

> Date: Sat, 16 Jul 2005 14:53:04 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> CC: Jason Rumney <jasonr@gnu.org>,  emacs-devel@gnu.org
> 
> In the case of Ghostscript it is actually quite complicated. I have code 
> for finding Ghostscript in the file w32-regdat.el which is part of 
> EmacsW32. This uses an external program to read the Registry. The actual 
> Registry interface is in w32-reg-iface.el (also in EmacsW32).

Are you saying that w32-regdat.el's method of finding Ghostscript is
how other programs, like GSView, find it?  This is so ridiculously
complicated that it's simpler to tell the users "add the GS directory
to your PATH".

Note that the node "MS-DOS Printing" (which deals with Windows as well
as DOS problems) already advises to use a full absolute file name of
the Ghostscript executable in setting up ps-lpr-command.  Is this the
only place where a user would need to know the Ghostscript
installation directory?

> Finding GSview is in contrast very simple since it is in App Paths.

But we shouldn't need to launch GSview, should we?

^ permalink raw reply	[flat|nested] 120+ 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, 0 replies; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 12:40                             ` Lennart Borgman
@ 2005-07-16 13:29                               ` Eli Zaretskii
  2005-07-16 13:39                                 ` Lennart Borgman
  2005-07-16 21:55                                 ` Jason Rumney
  0 siblings, 2 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-16 13:29 UTC (permalink / raw)
  Cc: emacs-devel, jasonr

> Date: Sat, 16 Jul 2005 14:40:00 +0200
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> CC: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
> 
> I do not think it is only for DLLs. I can not say that MS is very clear 
> in their documentation, some info is hard to find. But look here, this 
> page says that ShellExecute looks in App Paths:
> 
>    
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/fileassociations/fa_perceived_types.asp

According to that article, there are a few more directories where
openp should look for executables: the Windows directory and the
Windows/System32 (Windows/system on Windows 9X) directory.  Perhaps
w32.c:init_environment should prepend these two directories to the
value of PATH it sets up.  Then they will be automatically searched.

> If you have firefox installed (and you do not have it in your path) you 
> can try this:
> 
>    Open "Start Menu - Run" and enter firefox.exe.
> 
> It will start Firefox. However just typing "firefox.exe" in a cmd.exe 
> window does not work. This could be by intent (backward compatibility, 
> trying to behave as other shells) or just a bug.

So it sounds like adding to openp the search in "App Paths" would be
useful at least in some cases.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 13:22                                 ` Eli Zaretskii
@ 2005-07-16 13:36                                   ` Lennart Borgman
  0 siblings, 0 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 13:36 UTC (permalink / raw)
  Cc: emacs-devel, jasonr

Eli Zaretskii wrote:

>>In the case of Ghostscript it is actually quite complicated. I have code 
>>for finding Ghostscript in the file w32-regdat.el which is part of 
>>EmacsW32. This uses an external program to read the Registry. The actual 
>>Registry interface is in w32-reg-iface.el (also in EmacsW32).
>>    
>>
>
>Are you saying that w32-regdat.el's method of finding Ghostscript is
>how other programs, like GSView, find it?  This is so ridiculously
>complicated that it's simpler to tell the users "add the GS directory
>to your PATH".
>  
>
Yes, this is how GSView does it. I believe there might be a point in 
doing it the same way as GSView does it.

>Note that the node "MS-DOS Printing" (which deals with Windows as well
>as DOS problems) already advises to use a full absolute file name of
>the Ghostscript executable in setting up ps-lpr-command.  Is this the
>only place where a user would need to know the Ghostscript
>installation directory?
>  
>
I believe so, is not printing.el using this too? The only thing I do is 
setting up this automatically for the user (since Ghostscript/GSview are 
not in the path).

>>Finding GSview is in contrast very simple since it is in App Paths.
>>    
>>
>
>But we shouldn't need to launch GSview, should we?
>  
>
I think I added this because printing.el uses it.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 13:29                               ` Eli Zaretskii
@ 2005-07-16 13:39                                 ` Lennart Borgman
  2005-07-16 21:55                                 ` Jason Rumney
  1 sibling, 0 replies; 120+ messages in thread
From: Lennart Borgman @ 2005-07-16 13:39 UTC (permalink / raw)
  Cc: emacs-devel, jasonr

Eli Zaretskii wrote:

>According to that article, there are a few more directories where
>openp should look for executables: the Windows directory and the
>Windows/System32 (Windows/system on Windows 9X) directory.  Perhaps
>w32.c:init_environment should prepend these two directories to the
>value of PATH it sets up.  Then they will be automatically searched.
>  
>
Maybe. Are they not in the path all the time? Also prepending them might 
cause problems. I have had problems with w32 find.exe and GNU find.exe. 
Appending might then be better?

^ permalink raw reply	[flat|nested] 120+ 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; 120+ 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] 120+ messages in thread

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 13:29                               ` Eli Zaretskii
  2005-07-16 13:39                                 ` Lennart Borgman
@ 2005-07-16 21:55                                 ` Jason Rumney
  1 sibling, 0 replies; 120+ messages in thread
From: Jason Rumney @ 2005-07-16 21:55 UTC (permalink / raw)
  Cc: Lennart Borgman, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> According to that article, there are a few more directories where
> openp should look for executables: the Windows directory and the
> Windows/System32 (Windows/system on Windows 9X) directory.  Perhaps
> w32.c:init_environment should prepend these two directories to the
> value of PATH it sets up.  Then they will be automatically searched.

Those directories are normally in the PATH already (at the start by
default). If we want to make sure they are, I suggest appending, not
prepending, as advanced users may prepend other directories
deliberately, for example to get a Unix style find command instead of
the Windows find.exe.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 12:13                         ` Eli Zaretskii
  2005-07-16 12:44                           ` Lennart Borgman
@ 2005-07-16 21:57                           ` Jason Rumney
  2005-07-16 22:30                             ` David Kastrup
  1 sibling, 1 reply; 120+ messages in thread
From: Jason Rumney @ 2005-07-16 21:57 UTC (permalink / raw)
  Cc: Lennart Borgman, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> (I'm suggesting to look in the Registry _before_ you look along PATH
> because this is simpler and faster.  But if there are good reasons to
> look along PATH first, let's hear them.)

Few users will know about this registry "App Path" (it was news to
me), so they might find it surprising that their changes to PATH do
not take effect.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 21:57                           ` Jason Rumney
@ 2005-07-16 22:30                             ` David Kastrup
  0 siblings, 0 replies; 120+ messages in thread
From: David Kastrup @ 2005-07-16 22:30 UTC (permalink / raw)
  Cc: Lennart Borgman, Eli Zaretskii, emacs-devel

Jason Rumney <jasonr@gnu.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> (I'm suggesting to look in the Registry _before_ you look along
>> PATH because this is simpler and faster.  But if there are good
>> reasons to look along PATH first, let's hear them.)
>
> Few users will know about this registry "App Path" (it was news to
> me), so they might find it surprising that their changes to PATH do
> not take effect.

In particular, Emacs is a haven for people that are forced for some
reason to use Windows.  Those people will know how to manipulate PATH,
and will be pretty much floored if it does not work.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-15 23:40                             ` Jason Rumney
@ 2005-07-17  0:58                               ` Richard M. Stallman
  0 siblings, 0 replies; 120+ messages in thread
From: Richard M. Stallman @ 2005-07-17  0:58 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    Ghostscript is a port of a Unix program,

It's not a "Unix program"--it was developed for the GNU system,
and GNU's Not Unix ;-).

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16  9:46                               ` Eli Zaretskii
  2005-07-16 11:56                                 ` David Kastrup
@ 2005-07-17  0:59                                 ` Richard M. Stallman
  1 sibling, 0 replies; 120+ messages in thread
From: Richard M. Stallman @ 2005-07-17  0:59 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    > Look, it is getting annoying.  You have not _once_ in this whole
    > thread clearly spelled out _what_ your problem is and what you want
    > done.

    Actually, he did.  Perhaps you weren't listening.

With so much mail in this thread, I don't see how he could
even read all of it.  I can't even start.

If someone wants to contribute code to make these features
(which already exist on GNU-like systems) work on Windows also,
then assuming it is clean and we get the papers for it, we can
install it.

Perhaps that settles the issue.  (I couldn't read all the mail,
so I can't be sure what the issue is.)

Would people please terminate this argument?  It is getting
in the way of work on Emacs.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 11:56                                 ` David Kastrup
@ 2005-07-17  3:30                                   ` Eli Zaretskii
  0 siblings, 0 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-17  3:30 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> Cc: lennart.borgman.073@student.lu.se,  emacs-devel@gnu.org
> From: David Kastrup <dak@gnu.org>
> Date: Sat, 16 Jul 2005 13:56:43 +0200
> 
> >> Look, it is getting annoying.  You have not _once_ in this whole
> >> thread clearly spelled out _what_ your problem is and what you want
> >> done.
> >
> > Actually, he did.  Perhaps you weren't listening.
> 
> Perhaps.  So what is the particular application for which he needs the
> system paper size, and who has vetoed that anything be implemented
> that would make it accessible?

Please read the rest of the thread, it's all there.

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

* Re: w32 does not have emacsclient/server - getting paper size
  2005-07-16 12:00                       ` David Kastrup
@ 2005-07-17  3:32                         ` Eli Zaretskii
  0 siblings, 0 replies; 120+ messages in thread
From: Eli Zaretskii @ 2005-07-17  3:32 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> Cc: Lennart Borgman <lennart.borgman.073@student.lu.se>,  emacs-devel@gnu.org
> From: David Kastrup <dak@gnu.org>
> Date: Sat, 16 Jul 2005 14:00:57 +0200
> 
> > How about adding some code to `openp' so that, on w32 platforms, it
> > would look for the program/file in the Registry, in addition to the
> > list of directories it gets as its argument?
> 
> I remember just being told that the main advantage of the registry was
> that it was able to refer to several different installed versions of
> the same software.

If something can be found through the Registry, `openp' can be taught
to do that.

^ permalink raw reply	[flat|nested] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ 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; 120+ 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] 120+ messages in thread

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

Thread overview: 120+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-15  7:01 w32 does not have emacsclient/server 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 16:59           ` w32 does not have emacsclient/server - getting paper size Lennart Borgman
2005-07-15 17:13             ` David Kastrup
2005-07-15 17:55               ` Lennart Borgman
2005-07-15 21:20                 ` Jason Rumney
2005-07-15 21:39                   ` Lennart Borgman
2005-07-15 22:00                     ` David Kastrup
2005-07-15 22:13                       ` Lennart Borgman
2005-07-15 22:33                         ` David Kastrup
2005-07-15 23:07                           ` Lennart Borgman
2005-07-16  6:14                             ` David Kastrup
2005-07-16  9:46                               ` Eli Zaretskii
2005-07-16 11:56                                 ` David Kastrup
2005-07-17  3:30                                   ` Eli Zaretskii
2005-07-17  0:59                                 ` Richard M. Stallman
2005-07-16  9:48                           ` Eli Zaretskii
2005-07-15 23:09                         ` Jason Rumney
2005-07-15 23:22                           ` Lennart Borgman
2005-07-15 23:40                             ` Jason Rumney
2005-07-17  0:58                               ` Richard M. Stallman
2005-07-16  6:02                             ` David Kastrup
2005-07-16  8:31                               ` Lennart Borgman
2005-07-16  9:03                                 ` David Kastrup
2005-07-16  9:39                                   ` Eli Zaretskii
2005-07-16  9:42                               ` Eli Zaretskii
2005-07-16 10:00                     ` Eli Zaretskii
2005-07-16 10:28                       ` Lennart Borgman
2005-07-16 11:42                         ` Jason Rumney
2005-07-16 12:13                         ` Eli Zaretskii
2005-07-16 12:44                           ` Lennart Borgman
2005-07-16 21:57                           ` Jason Rumney
2005-07-16 22:30                             ` David Kastrup
2005-07-16 10:58                       ` Jason Rumney
2005-07-16 11:07                         ` Lennart Borgman
2005-07-16 11:50                           ` Jason Rumney
2005-07-16 12:26                             ` Eli Zaretskii
2005-07-16 12:53                               ` Lennart Borgman
2005-07-16 13:22                                 ` Eli Zaretskii
2005-07-16 13:36                                   ` Lennart Borgman
2005-07-16 12:40                             ` Lennart Borgman
2005-07-16 13:29                               ` Eli Zaretskii
2005-07-16 13:39                                 ` Lennart Borgman
2005-07-16 21:55                                 ` Jason Rumney
2005-07-16 12:00                       ` David Kastrup
2005-07-17  3:32                         ` Eli Zaretskii
2005-07-16  9:54                 ` Eli Zaretskii
2005-07-16 10:10                   ` Lennart Borgman
2005-07-15 14:33     ` w32 does not have emacsclient/server 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
  -- strict thread matches above, loose matches on Subject: below --
2005-07-15 15:36 klaus.berndl
2005-07-16 13:28 ` Juanma Barranquero

Code repositories for project(s) associated with this public inbox

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

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