How to remove the prompt for killing emacsclient buffers?

后端 未结 4 747
借酒劲吻你
借酒劲吻你 2021-02-01 17:53

After I open something with emacsclient, when I kill that buffer (C-x k) I get a confirmation dialog:

Buffer `blah\' still has clients; kill it? (yes or no)
         


        
4条回答
  •  独厮守ぢ
    2021-02-01 18:30

    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.
    

提交回复
热议问题