aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Porter2022-12-02 12:14:50 -0800
committerJim Porter2022-12-04 14:14:09 -0800
commit4bcdb1cc65bf779b6479f99a7aa767ab83b3bae1 (patch)
tree14d92fbf9ddcf081b007ad73b80bb6ef311a7c4d
parenta27f61f6f48762b43810558b38cf6a6ab1ea7673 (diff)
downloademacs-4bcdb1cc65bf779b6479f99a7aa767ab83b3bae1.tar.gz
emacs-4bcdb1cc65bf779b6479f99a7aa767ab83b3bae1.zip
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'.
-rw-r--r--lisp/server.el60
1 files changed, 37 insertions, 23 deletions
diff --git a/lisp/server.el b/lisp/server.el
index 1b027f88ce6..7e713eaecde 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1780,29 +1780,43 @@ With ARG non-nil, silently save all file-visiting buffers, then kill.
1780 1780
1781If emacsclient was started with a list of filenames to edit, then 1781If emacsclient was started with a list of filenames to edit, then
1782only these files will be asked to be saved." 1782only these files will be asked to be saved."
1783 (if server-stop-automatically 1783 (let ((proc (frame-parameter nil 'client)))
1784 (server-stop-automatically--handle-delete-frame (selected-frame)) 1784 (cond ((eq proc 'nowait)
1785 (let ((proc (frame-parameter nil 'client))) 1785 ;; Nowait frames have no client buffer list.
1786 (cond ((eq proc 'nowait) 1786 (if (length> (frame-list) (if server-stop-automatically 2 1))
1787 ;; Nowait frames have no client buffer list. 1787 ;; If there are any other frames, only delete this one.
1788 (if (cdr (frame-list)) 1788 ;; When `server-stop-automatically' is set, don't count
1789 (progn (save-some-buffers arg) 1789 ;; the daemon frame.
1790 (delete-frame)) 1790 (progn (save-some-buffers arg)
1791 ;; If we're the last frame standing, kill Emacs. 1791 (delete-frame))
1792 (save-buffers-kill-emacs arg))) 1792 ;; If we're the last frame standing, kill Emacs.
1793 ((processp proc) 1793 (save-buffers-kill-emacs arg)))
1794 (let ((buffers (process-get proc 'buffers))) 1794 ((processp proc)
1795 (save-some-buffers 1795 (if (or (not server-stop-automatically)
1796 arg (if buffers 1796 (length> server-clients 1)
1797 ;; Only files from emacsclient file list. 1797 (seq-some
1798 (lambda () (memq (current-buffer) buffers)) 1798 (lambda (frame)
1799 ;; No emacsclient file list: don't override 1799 (when-let ((p (frame-parameter frame 'client)))
1800 ;; `save-some-buffers-default-predicate' (unless 1800 (not (eq proc p))))
1801 ;; ARG is non-nil), since we're not killing 1801 (frame-list)))
1802 ;; Emacs (unlike `save-buffers-kill-emacs'). 1802 ;; If `server-stop-automatically' is not enabled, there
1803 (and arg t))) 1803 ;; are any other clients, or there are frames not owned
1804 (server-delete-client proc))) 1804 ;; by the current client (e.g. `nowait' frames), then
1805 (t (error "Invalid client frame")))))) 1805 ;; we just want to delete this client.
1806 (let ((buffers (process-get proc 'buffers)))
1807 (save-some-buffers
1808 arg (if buffers
1809 ;; Only files from emacsclient file list.
1810 (lambda () (memq (current-buffer) buffers))
1811 ;; No emacsclient file list: don't override
1812 ;; `save-some-buffers-default-predicate' (unless
1813 ;; ARG is non-nil), since we're not killing
1814 ;; Emacs (unlike `save-buffers-kill-emacs').
1815 (and arg t)))
1816 (server-delete-client proc))
1817 ;; Otherwise, we want to kill Emacs.
1818 (save-buffers-kill-emacs arg)))
1819 (t (error "Invalid client frame")))))
1806 1820
1807(defun server-stop-automatically--handle-delete-frame (frame) 1821(defun server-stop-automatically--handle-delete-frame (frame)
1808 "Handle deletion of FRAME when `server-stop-automatically' is used." 1822 "Handle deletion of FRAME when `server-stop-automatically' is used."