I'm considering using emacs as a server (using (server-start)) but I do not want to use C-x # to kill buffers. I've heard of the -n option for emacsclient, but I'm concerned that it may cause unwanted behavior when other programs use emacsclient. I've thought about using this:

(add-hook kill-buffer-hook server-edit)

Would this work?

  • You'd need to quote things: (add-hook 'kill-buffer-hook #'server-edit) - but it's worth trying. If it doesn't work, you can remove the function from the hook using remove-hook and get back to where you where. – NickD Sep 24 '20 at 4:17
  • I don't see any benefit to adding server-edit to kill-buffer-hook. It would do some potentially unwanted buffer switching whenever you kill a buffer, but otherwise wouldn't change what happens when you kill a buffer. You can kill a buffer normally even if it's serving a client. You get a confirmation prompt; if you want to get rid of the prompt, doing something after that prompt won't help. Please clarify your question: what is your current workflow, which part bothers you, and how do you want Emacs to react differently? – Gilles 'SO- stop being evil' Sep 24 '20 at 11:44
  • 1
    Please clarify what is the problem you have with C-x # exactly as well as which uses of emacsclient you're concerned with. – Stefan Sep 24 '20 at 14:31
  • I guess I could get used to C-x #, but it is inconvenient, and I am likely to accidentally close buffers in other ways very frequently before I get used to it. For example, I have already built up muscle memory for z x (I use evil-mode). I may be wrong, but I would guess that programs such as git, emacs anywhere, etc. would see emacsclient close and assume I am done editing before I have even begun if I used the -n flag, recording the wrong information. – Aronurr64 Sep 24 '20 at 15:49

Your Answer

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

Browse other questions tagged or ask your own question.