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,17 +1780,29 @@ 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
|
|
||||||
(server-stop-automatically--handle-delete-frame (selected-frame))
|
|
||||||
(let ((proc (frame-parameter nil 'client)))
|
(let ((proc (frame-parameter nil 'client)))
|
||||||
(cond ((eq proc 'nowait)
|
(cond ((eq proc 'nowait)
|
||||||
;; Nowait frames have no client buffer list.
|
;; Nowait frames have no client buffer list.
|
||||||
(if (cdr (frame-list))
|
(if (length> (frame-list) (if server-stop-automatically 2 1))
|
||||||
|
;; If there are any other frames, only delete this one.
|
||||||
|
;; When `server-stop-automatically' is set, don't count
|
||||||
|
;; the daemon frame.
|
||||||
(progn (save-some-buffers arg)
|
(progn (save-some-buffers arg)
|
||||||
(delete-frame))
|
(delete-frame))
|
||||||
;; If we're the last frame standing, kill Emacs.
|
;; If we're the last frame standing, kill Emacs.
|
||||||
(save-buffers-kill-emacs arg)))
|
(save-buffers-kill-emacs arg)))
|
||||||
((processp proc)
|
((processp proc)
|
||||||
|
(if (or (not server-stop-automatically)
|
||||||
|
(length> server-clients 1)
|
||||||
|
(seq-some
|
||||||
|
(lambda (frame)
|
||||||
|
(when-let ((p (frame-parameter frame 'client)))
|
||||||
|
(not (eq proc p))))
|
||||||
|
(frame-list)))
|
||||||
|
;; If `server-stop-automatically' is not enabled, there
|
||||||
|
;; are any other clients, or there are frames not owned
|
||||||
|
;; by the current client (e.g. `nowait' frames), then
|
||||||
|
;; we just want to delete this client.
|
||||||
(let ((buffers (process-get proc 'buffers)))
|
(let ((buffers (process-get proc 'buffers)))
|
||||||
(save-some-buffers
|
(save-some-buffers
|
||||||
arg (if buffers
|
arg (if buffers
|
||||||
|
@ -1801,8 +1813,10 @@ only these files will be asked to be saved."
|
||||||
;; ARG is non-nil), since we're not killing
|
;; ARG is non-nil), since we're not killing
|
||||||
;; Emacs (unlike `save-buffers-kill-emacs').
|
;; Emacs (unlike `save-buffers-kill-emacs').
|
||||||
(and arg t)))
|
(and arg t)))
|
||||||
(server-delete-client proc)))
|
(server-delete-client proc))
|
||||||
(t (error "Invalid client frame"))))))
|
;; 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