aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-10-31 23:35:06 -0400
committerChong Yidong2010-10-31 23:35:06 -0400
commit381d186f82544c7c34478badef209f52feacd80f (patch)
treef42f58a5fdedb529a0aa650c9c455346a1f5abe3
parent98cfec0d6935f25a54852caaa33112ea1ca4634b (diff)
downloademacs-381d186f82544c7c34478badef209f52feacd80f.tar.gz
emacs-381d186f82544c7c34478badef209f52feacd80f.zip
Prevent server-mode from issuing a prompt in kill-emacs-hook.
* server.el (server-start): New arg INHIBIT-PROMPT prevents asking user for confirmation. (server-force-stop): Use it. (server-start): Use server-force-stop for kill-emacs-hook, to avoid user interaction while killing Emacs.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/server.el28
2 files changed, 27 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d2a1713ed27..bc43863e6b4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12010-11-01 Chong Yidong <cyd@stupidchicken.com>
2
3 * server.el (server-start): New arg INHIBIT-PROMPT prevents asking
4 user for confirmation.
5 (server-force-stop): Use it.
6 (server-start): Use server-force-stop for kill-emacs-hook, to
7 avoid user interaction while killing Emacs.
8
12010-10-31 Stefan Monnier <monnier@iro.umontreal.ca> 92010-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * vc/log-edit.el (log-edit-rewrite-fixes): New var. 11 * vc/log-edit.el (log-edit-rewrite-fixes): New var.
diff --git a/lisp/server.el b/lisp/server.el
index 265b422e957..17d6743a0f7 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -485,7 +485,7 @@ See variable `server-auth-dir' for details."
485 (error "The directory `%s' is unsafe" dir))))) 485 (error "The directory `%s' is unsafe" dir)))))
486 486
487;;;###autoload 487;;;###autoload
488(defun server-start (&optional leave-dead) 488(defun server-start (&optional leave-dead inhibit-prompt)
489 "Allow this Emacs process to be a server for client processes. 489 "Allow this Emacs process to be a server for client processes.
490This starts a server communications subprocess through which 490This starts a server communications subprocess through which
491client \"editors\" can send your editing commands to this Emacs 491client \"editors\" can send your editing commands to this Emacs
@@ -495,7 +495,10 @@ Emacs distribution as your standard \"editor\".
495Optional argument LEAVE-DEAD (interactively, a prefix arg) means just 495Optional argument LEAVE-DEAD (interactively, a prefix arg) means just
496kill any existing server communications subprocess. 496kill any existing server communications subprocess.
497 497
498If a server is already running, the server is not started. 498If a server is already running, restart it. If clients are
499running, ask the user for confirmation first, unless optional
500argument INHIBIT-PROMPT is non-nil.
501
499To force-start a server, do \\[server-force-delete] and then 502To force-start a server, do \\[server-force-delete] and then
500\\[server-start]." 503\\[server-start]."
501 (interactive "P") 504 (interactive "P")
@@ -503,12 +506,14 @@ To force-start a server, do \\[server-force-delete] and then
503 ;; Ask the user before deleting existing clients---except 506 ;; Ask the user before deleting existing clients---except
504 ;; when we can't get user input, which may happen when 507 ;; when we can't get user input, which may happen when
505 ;; doing emacsclient --eval "(kill-emacs)" in daemon mode. 508 ;; doing emacsclient --eval "(kill-emacs)" in daemon mode.
506 (if (and (daemonp) 509 (cond
507 (null (cdr (frame-list))) 510 ((and (daemonp)
508 (eq (selected-frame) terminal-frame)) 511 (null (cdr (frame-list)))
509 leave-dead 512 (eq (selected-frame) terminal-frame))
510 (yes-or-no-p 513 leave-dead)
511 "The current server still has clients; delete them? "))) 514 (inhibit-prompt t)
515 (t (yes-or-no-p
516 "The current server still has clients; delete them? "))))
512 (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir)) 517 (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))
513 (server-file (expand-file-name server-name server-dir))) 518 (server-file (expand-file-name server-name server-dir)))
514 (when server-process 519 (when server-process
@@ -545,7 +550,7 @@ server or call `M-x server-force-delete' to forcibly disconnect it.")
545 (add-hook 'delete-frame-functions 'server-handle-delete-frame) 550 (add-hook 'delete-frame-functions 'server-handle-delete-frame)
546 (add-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) 551 (add-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
547 (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) 552 (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function)
548 (add-hook 'kill-emacs-hook (lambda () (server-mode -1))) ;Cleanup upon exit. 553 (add-hook 'kill-emacs-hook 'server-force-stop) ;Cleanup upon exit.
549 (setq server-process 554 (setq server-process
550 (apply #'make-network-process 555 (apply #'make-network-process
551 :name server-name 556 :name server-name
@@ -586,6 +591,11 @@ server or call `M-x server-force-delete' to forcibly disconnect it.")
586 " " (int-to-string (emacs-pid)) 591 " " (int-to-string (emacs-pid))
587 "\n" auth-key))))))))) 592 "\n" auth-key)))))))))
588 593
594(defun server-force-stop ()
595 "Kill all connections to the current server.
596This function is meant to be called from `kill-emacs-hook'."
597 (server-start nil t))
598
589;;;###autoload 599;;;###autoload
590(defun server-force-delete (&optional name) 600(defun server-force-delete (&optional name)
591 "Unconditionally delete connection file for server NAME. 601 "Unconditionally delete connection file for server NAME.