You may set the keyboard command C-x k so that it marks client buffers as done and kills normal buffers.
I shamelessly stole this code snippet from the Emacs Client entry in the Emacs Wiki:
(add-hook 'server-switch-hook
(lambda ()
(when (current-local-map)
(use-local-map (copy-keymap (current-local-map))))
(when server-buffer-clients
(local-set-key (kbd "C-x k") 'server-edit))))
While this does not help with other ways of killing buffers (such as M-x list-buffers
), it should be on the safe side by respecting the Emacs client behavior that some shell scripts expect.
Here is an excerpt from the file server.el in your Emacs distribution that might shed a little light on what I mean:
;; When you finish editing a Server buffer, again call server-edit
;; to mark that buffer as done for the client and switch to the next
;; Server buffer. When all the buffers for a client have been edited
;; and exited with server-edit, the client "editor" will return
;; to the program that invoked it.
Later on, there is an explicit warning that a buffer shouldn't be killed, but released (at least this is how I interpret it):
;; Ask before killing a server buffer.
;; It was suggested to release its client instead,
;; but I think that is dangerous--the client would proceed
;; using whatever is on disk in that file. -- rms.
C-x #
to tell the server when you've finished with the file. If you do that (rather thanC-x k
), you won't be asked the question. – Mccluskey