0

I want to know about why they are used? , what are they?

what is daemon in emacs,

Why Should/shouldnot i use "emacs" instead of "emacsclient --create-frame" ?

what is client and server in emacs?

please if you know explain me briefly from like childhood to adulthood?

1
  • 1
    One simple question per question, please.
    – Drew
    Commented Oct 29, 2021 at 18:25

2 Answers 2

2

First, I think these things are quite well explained in Chapter 39 of the Emacs manual. So, I would recommend you to read that chapter (again) after reading the 'childhood' info below...

Although Emacs is commonly described as an editor, a better description would be to call it 'an Emacs lisp interpreter including', or 'a virtual lisp machine containing', an editor.

Now to answer this question it is probably most insightful to view Emacs as a virtual lisp machine, and then provide an analogy with a real PC/workstation.

Using the command emacs will boot an entire lisp machine, which in this analogy is like starting up a PC/workstation and login in as a user into your desktop environment.

If you are using the browser on a PC and you download some text file, you would probably not startup another PC just to read your text file there, because it is much simpler to read the file right in the current desktop session by opening the file in some editor, or for the analogy, by connecting to the desktop session and create a file in the new frame (provided by the editor). Generally, when the editor is already open, you do not even require a new instance of the editor (i.e. no new frame), but you can just open another file by 'connecting to the editor' and open it there. This is what emacsclient is for (more below).

By starting a daemon (which more or less means starting the Emacs server, without doing anything else, i.e. without starting a graphical user interface), it is like you are preparing your PC to be in 'sleep' mode, so your desktop user session is already loaded, although the computer seems to be turned off. But now you can directly get into your user session by a simple trigger (like pressing a key, or by 'unfolding' your laptop). Commonly, a server is something you connect to, like when you connect to some website, the website was already 'running' on the remote server (it does not have to boot up first).

emacsclient is the utility that helps you connect to the Emacs server (it provides a graphical user interface). It is somewhat analogous to providing you a monitor, keyboard and mouse to help you connect to your PC (for waking up the sleeping pc and let you interact with it).

Finally, the TCP server is just a particular kind of server that lets you 'connect' to Emacs (your 'virtual machine') in a particular way (e.g. from a remote station). Usually you do not need the TCP server because you can simply connect to your Emacs server via some mechanism provided by your OS (like for waking your PC locally, you can just press a key on the keyboard). However, if you want to connect to the Emacs server from far (like booting your PC from another room), then you need some way to connect to it from far for which you can use the TCP(rotocol), like you would probably do for waking your remotely sleeping computer in the other room/house/universe.

I would advise starting the Emacs server by adding (server-start) to your init file (because then you will also restart the server when restarting Emacs). Then open Emacs once after you have started your PC, and then try to never close it; connect to it using the emacsclient (without the --create-frame option). Once in a while, you need to restart Emacs, e.g. after updating some packages or after 'polluting the virtual machine(/interpreter) environment'.

The above is certainly a very cumbersome and crude 'childhood' explanation, and could probably get much improved (edits are very welcome), but I hope it will help somewhat to understand what is written in Chapter 39 of the Emacs manual, which again, I would strongly recommend you to read (again).

Then just start using the server, and you will gradually discover what will be the best workflow for you.

1

To understand emacs daemon and client it is important to understand the effect of configuration required by both

This only hinted to at last paragraph in 44 Saving Emacs Sessions of the emacs manual

When Emacs starts in daemon mode, it cannot ask you any questions, so if it finds the desktop file locked, it will not load it, unless desktop-load-locked-desktop is t.

Note that restoring the desktop in daemon mode is somewhat problematic for other reasons: e.g., the daemon cannot use GUI features, so parameters such as frame position, size, and decorations cannot be restored. For that reason, you may wish to delay restoring the desktop in daemon mode until the first client connects, by calling desktop-read in a hook function that you add to server-after-make-frame-hook (see Creating Frames in The Emacs Lisp Reference Manual).

Some links on the session problem.

Emacs Daemon with Version 28.0.5.GTK+ on linux:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.