3

According to the documentation of the command server-edit:

Switch to next server editing buffer; say "Done" for current buffer. If a server buffer is current, it is marked "done" and optionally saved. The buffer is also killed if it did not exist before the clients asked for it. When all of a client's buffers are marked as "done", the client is notified.

I have seen many sources which mention this command. For example https://emacs.stackexchange.com/a/29461 says emacsclient waits for emacs server. When you do server-edit, the server notifies emacsclient to terminate.

My question is when do I actually need to call this command? I have the following in my init file.

(require 'server)
(unless (server-running-p) (server-start))

I open the files with emacsclient -n. Do I ever need server-edit command?

Added: Occasionally (for the reasons that I don't know) emacsclient fails to connect to the server and emacsclient -n opens a new instance of emacs and even when I completely exit from emacs and restart emacs, this inconvenient phenomenon continues. I don't know why this happens despite the fact that I always call emacsclient by -n option. Later, I discovered that by running server-edit this issue can be resolved. Despite the fact that the post linked by YoungFrog claims that I don't need to call server-edit in this situation, it seems that server-edit performs a magic even in this situation. Thus I decided to ask this question to know more about the command server-edit beyond the existing documentation and few posts on this subject in this site, because I felt that I don't completely understand this command.

  • 2
    See also the -n flag to emacsclient (if you use it, server-edit is... less useful) – YoungFrog Jan 11 '17 at 21:42
  • @YoungFrog could you please elaborate more and if possible to post your comment as a a complete answer. – Name Jan 12 '17 at 7:12
  • 4
    Possible duplicate of What is the use for server-edit (C-x #) – YoungFrog Jan 12 '17 at 14:40
  • I believe the above link (duplicate) has it all, but feel free to ask for more information if needed. – YoungFrog Jan 12 '17 at 15:37
4

Some programs run your editor and ask you to edit some text. (For instance: writing a commit message in git when you didn't specify one in your command.) They expect you to turn off your editor when you're done with editing, but turning off your entire Emacs server would be pointless. server-edit exists so you can use Emacs with programs that work like that easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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