Make killing a non-last client work the same no matter the auto-stop setting
Previously, if 'server-stop-automatically' was configured for 'kill-terminal' or 'delete-frame', killing a client via 'save-buffers-kill-terminal' wouldn't prompt about the saving files in the client's buffer list (as it does when not using those settings). This change ensures that those settings only apply when killing the last client, as described in the manual (bug#51993). * lisp/server.el (server-save-buffers-kill-terminal): Handle 'server-stop-automatically' behavior in this function, rather than calling 'server-stop-automatically--handle-delete-frame'.
This commit is contained in:
parent
a27f61f6f4
commit
4bcdb1cc65
1 changed files with 37 additions and 23 deletions
|
@ -1780,29 +1780,43 @@ With ARG non-nil, silently save all file-visiting buffers, then kill.
|
||||||
|
|
||||||
If emacsclient was started with a list of filenames to edit, then
|
If emacsclient was started with a list of filenames to edit, then
|
||||||
only these files will be asked to be saved."
|
only these files will be asked to be saved."
|
||||||
(if server-stop-automatically
|
(let ((proc (frame-parameter nil 'client)))
|
||||||
(server-stop-automatically--handle-delete-frame (selected-frame))
|
(cond ((eq proc 'nowait)
|
||||||
(let ((proc (frame-parameter nil 'client)))
|
;; Nowait frames have no client buffer list.
|
||||||
(cond ((eq proc 'nowait)
|
(if (length> (frame-list) (if server-stop-automatically 2 1))
|
||||||
;; Nowait frames have no client buffer list.
|
;; If there are any other frames, only delete this one.
|
||||||
(if (cdr (frame-list))
|
;; When `server-stop-automatically' is set, don't count
|
||||||
(progn (save-some-buffers arg)
|
;; the daemon frame.
|
||||||
(delete-frame))
|
(progn (save-some-buffers arg)
|
||||||
;; If we're the last frame standing, kill Emacs.
|
(delete-frame))
|
||||||
(save-buffers-kill-emacs arg)))
|
;; If we're the last frame standing, kill Emacs.
|
||||||
((processp proc)
|
(save-buffers-kill-emacs arg)))
|
||||||
(let ((buffers (process-get proc 'buffers)))
|
((processp proc)
|
||||||
(save-some-buffers
|
(if (or (not server-stop-automatically)
|
||||||
arg (if buffers
|
(length> server-clients 1)
|
||||||
;; Only files from emacsclient file list.
|
(seq-some
|
||||||
(lambda () (memq (current-buffer) buffers))
|
(lambda (frame)
|
||||||
;; No emacsclient file list: don't override
|
(when-let ((p (frame-parameter frame 'client)))
|
||||||
;; `save-some-buffers-default-predicate' (unless
|
(not (eq proc p))))
|
||||||
;; ARG is non-nil), since we're not killing
|
(frame-list)))
|
||||||
;; Emacs (unlike `save-buffers-kill-emacs').
|
;; If `server-stop-automatically' is not enabled, there
|
||||||
(and arg t)))
|
;; are any other clients, or there are frames not owned
|
||||||
(server-delete-client proc)))
|
;; by the current client (e.g. `nowait' frames), then
|
||||||
(t (error "Invalid client frame"))))))
|
;; we just want to delete this client.
|
||||||
|
(let ((buffers (process-get proc 'buffers)))
|
||||||
|
(save-some-buffers
|
||||||
|
arg (if buffers
|
||||||
|
;; Only files from emacsclient file list.
|
||||||
|
(lambda () (memq (current-buffer) buffers))
|
||||||
|
;; No emacsclient file list: don't override
|
||||||
|
;; `save-some-buffers-default-predicate' (unless
|
||||||
|
;; ARG is non-nil), since we're not killing
|
||||||
|
;; Emacs (unlike `save-buffers-kill-emacs').
|
||||||
|
(and arg t)))
|
||||||
|
(server-delete-client proc))
|
||||||
|
;; Otherwise, we want to kill Emacs.
|
||||||
|
(save-buffers-kill-emacs arg)))
|
||||||
|
(t (error "Invalid client frame")))))
|
||||||
|
|
||||||
(defun server-stop-automatically--handle-delete-frame (frame)
|
(defun server-stop-automatically--handle-delete-frame (frame)
|
||||||
"Handle deletion of FRAME when `server-stop-automatically' is used."
|
"Handle deletion of FRAME when `server-stop-automatically' is used."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue