]> git.eshelyaron.com Git - emacs.git/commitdiff
(server-start): Allow server to shut down when no frames are available
authorChong Yidong <cyd@stupidchicken.com>
Wed, 21 Jan 2009 20:33:17 +0000 (20:33 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Wed, 21 Jan 2009 20:33:17 +0000 (20:33 +0000)
in daemon-mode.

lisp/server.el

index 910c0047dce5012b593ec3ca24add61407ed6b56..20b9ff57ffe423d986c2b146aa024667b029e1da 100644 (file)
@@ -465,10 +465,16 @@ If a server is already running, the server is not started.
 To force-start a server, do \\[server-force-delete] and then
 \\[server-start]."
   (interactive "P")
-  (when (or
-        (not server-clients)
-        (yes-or-no-p
-         "The current server still has clients; delete them? "))
+  (when (or (not server-clients)
+           ;; Ask the user before deleting existing clients---except
+           ;; when we can't get user input, which may happen when
+           ;; doing emacsclient --eval "(kill-emacs)" in daemon mode.
+           (if (and (daemonp)
+                    (null (cdr (frame-list)))
+                    (eq (selected-frame) terminal-frame))
+               leave-dead
+             (yes-or-no-p
+              "The current server still has clients; delete them? ")))
     (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))
           (server-file (expand-file-name server-name server-dir)))
       (when server-process
@@ -979,7 +985,7 @@ The following commands are accepted by the client:
                             ;; We can't use the Emacs daemon's
                             ;; terminal frame.
                             (not (and (daemonp)
-                                      (= (length (frame-list)) 1)
+                                      (null (cdr (frame-list)))
                                       (eq (selected-frame)
                                           terminal-frame)))))
                    (setq tty-name nil tty-type nil)