Where is the code for the Emacs server in the core?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Where is the code for the Emacs server in the core?

George Plymale II
Hi,

I am trying to find the code in the Emacs core which implements the
Emacs server / daemon. The reason I am looking is that I am curious
about implementing multi-tty support in the Emacs Mac Port by Yamamoto
Mitsuharu. Unfortunately, I believe that I must first see the code that
governs the Emacs server. I am not sure if that is the right place to
look, but I am unsure where else the problem could be. The Emacs server
purposefully rejects requests to have a terminal and GUI client. I
assume it also governs which process will be in charge of all the Emacs
clients. So I thought the server code would be the best place to look.

I did a directory diff on the source trees of the Emacs Mac Port and
plain GNU Emacs. But I could not find anything which indicated a
difference in either server. Moreover, I could not find anything related
to the Emacs server.

Could anyone help shed some light on this situation? I've not looked at
much of the Emacs core in the past, except the Lisp interpreter, so I'm
not very familiar with its landscape.

Thanks

Reply | Threaded
Open this post in threaded view
|

Re: Where is the code for the Emacs server in the core?

Eli Zaretskii
> From: George Plymale II <[hidden email]>
> Date: Fri, 12 Jan 2018 02:58:42 -0500
>
> I am trying to find the code in the Emacs core which implements the
> Emacs server / daemon. The reason I am looking is that I am curious
> about implementing multi-tty support in the Emacs Mac Port by Yamamoto
> Mitsuharu. Unfortunately, I believe that I must first see the code that
> governs the Emacs server. I am not sure if that is the right place to
> look, but I am unsure where else the problem could be. The Emacs server
> purposefully rejects requests to have a terminal and GUI client. I
> assume it also governs which process will be in charge of all the Emacs
> clients. So I thought the server code would be the best place to look.

Multi-tty support depends on two features:

  . the ability to have more than one display_info object, so that
    some could be used for TTY frames and others for GUI frames
  . the ability to open a TTY frame on a named tty device, see
    make-terminal-frame

emacsclient and server.el use these two abilities to request creation
of a new frame either on a different TTY device or on a different X
display.  The files where this functionality is implemented are
emacsclient.c, server.el, frame.el and frame.c.

Reply | Threaded
Open this post in threaded view
|

Re: Where is the code for the Emacs server in the core?

George Plymale II-2
Thanks a lot for the information. Your advice has been quite helpful and
I think that I've found some of the regions of code that I was looking
for. At least it's a start so hopefully I can figure the rest out.

One more thing I'd like to have a second opinion on:

> The Mac port doesn't support multi-tty with GUI.  The developer has no
> idea how to detach Emacs as a GUI application from Window Server or
> Dock without separating a GUI process (not thread) from the main Emacs
> (Lisp evaluator) process.  TTY-only multi-tty is supposed to work.

That is Yamamoto Mitsuharu's statement on why multi-tty is not supported
on the Emacs Mac Port. Does plain GNU Emacs have this problem? If so,
how does it get around or solve it? I have to assume that plain GNU
Emacs is also attached to the Window Server or Dock as well so I'm
wondering if there's something I'm missing.

Reply | Threaded
Open this post in threaded view
|

Re: Where is the code for the Emacs server in the core?

Eli Zaretskii
> From: George Plymale II <[hidden email]>
> Cc: [hidden email]
> Date: Sat, 13 Jan 2018 10:51:55 -0500
>
> > The Mac port doesn't support multi-tty with GUI.  The developer has no
> > idea how to detach Emacs as a GUI application from Window Server or
> > Dock without separating a GUI process (not thread) from the main Emacs
> > (Lisp evaluator) process.  TTY-only multi-tty is supposed to work.
>
> That is Yamamoto Mitsuharu's statement on why multi-tty is not supported
> on the Emacs Mac Port. Does plain GNU Emacs have this problem? If so,
> how does it get around or solve it? I have to assume that plain GNU
> Emacs is also attached to the Window Server or Dock as well so I'm
> wondering if there's something I'm missing.

I know nothing about how macOS works wrt GUI applications, so I don't
understand what is meant by "attached to the Window Server or Dock",
nor how to compare that with what Emacs does on X, sorry.  Perhaps
someone else could chime in.

Reply | Threaded
Open this post in threaded view
|

Re: Where is the code for the Emacs server in the core?

Alan Third
In reply to this post by George Plymale II-2
On Sat, Jan 13, 2018 at 10:51:55AM -0500, George Plymale II wrote:

> > The Mac port doesn't support multi-tty with GUI.  The developer has no
> > idea how to detach Emacs as a GUI application from Window Server or
> > Dock without separating a GUI process (not thread) from the main Emacs
> > (Lisp evaluator) process.  TTY-only multi-tty is supposed to work.
>
> That is Yamamoto Mitsuharu's statement on why multi-tty is not supported
> on the Emacs Mac Port. Does plain GNU Emacs have this problem? If so,
> how does it get around or solve it? I have to assume that plain GNU
> Emacs is also attached to the Window Server or Dock as well so I'm
> wondering if there's something I'm missing.

I’m not sure this is relevant, but if you do this on the NS port:

     Open GUI instance
     start server
     run ‘emacsclient -t’ in the terminal
     close GUI frame

You can’t open a new GUI frame, even though the GUI instance with the
server is still running. You can see it in the dock, and access the
menus, but I can’t find any way to create a new frame.

So while it works, it’s not perfect.

I don’t know what we do differently from the Mac port.
--
Alan Third

Reply | Threaded
Open this post in threaded view
|

Re: Where is the code for the Emacs server in the core?

George Plymale II-2
Yes, thank you for reminding me of that behavior. I had quite forgotten
about that weirdness since I use this package:
https://github.com/DarwinAwardWinner/osx-pseudo-daemon

So I guess maybe things aren't very different between the NS port and
the Mac Port... certainly some more investigation is needed.

Thanks

Reply | Threaded
Open this post in threaded view
|

Re: Where is the code for the Emacs server in the core?

George Plymale II-2
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> From: George Plymale II <[hidden email]>
>> Cc: [hidden email]
>> Date: Sat, 13 Jan 2018 10:51:55 -0500
>>
>> > The Mac port doesn't support multi-tty with GUI.  The developer has no
>> > idea how to detach Emacs as a GUI application from Window Server or
>> > Dock without separating a GUI process (not thread) from the main Emacs
>> > (Lisp evaluator) process.  TTY-only multi-tty is supposed to work.
>>
>> That is Yamamoto Mitsuharu's statement on why multi-tty is not supported
>> on the Emacs Mac Port. Does plain GNU Emacs have this problem? If so,
>> how does it get around or solve it? I have to assume that plain GNU
>> Emacs is also attached to the Window Server or Dock as well so I'm
>> wondering if there's something I'm missing.
>
> I know nothing about how macOS works wrt GUI applications, so I don't
> understand what is meant by "attached to the Window Server or Dock",
> nor how to compare that with what Emacs does on X, sorry.  Perhaps
> someone else could chime in.

No problem, Alan has given some useful input on my conjectures.