aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/server.el
diff options
context:
space:
mode:
authorStefan Monnier2010-11-09 15:07:10 -0500
committerStefan Monnier2010-11-09 15:07:10 -0500
commitd607b96bc2824116a8fe0e5840ce49da7ce4514f (patch)
tree229a11bba88b67e8961db4d10aa8b3725f3a4873 /lisp/server.el
parent27410d0ac3406a341cc90ada064047a7f1ea5209 (diff)
parentc00980655bc15ca019fd6c559c69601be18f2407 (diff)
downloademacs-d607b96bc2824116a8fe0e5840ce49da7ce4514f.tar.gz
emacs-d607b96bc2824116a8fe0e5840ce49da7ce4514f.zip
Merge from emacs-23
Diffstat (limited to 'lisp/server.el')
-rw-r--r--lisp/server.el28
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/server.el b/lisp/server.el
index 6fbef70768d..ecc9b16cce7 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -498,7 +498,7 @@ See variable `server-auth-dir' for details."
498 (error "The directory `%s' is unsafe" dir))))) 498 (error "The directory `%s' is unsafe" dir)))))
499 499
500;;;###autoload 500;;;###autoload
501(defun server-start (&optional leave-dead) 501(defun server-start (&optional leave-dead inhibit-prompt)
502 "Allow this Emacs process to be a server for client processes. 502 "Allow this Emacs process to be a server for client processes.
503This starts a server communications subprocess through which 503This starts a server communications subprocess through which
504client \"editors\" can send your editing commands to this Emacs 504client \"editors\" can send your editing commands to this Emacs
@@ -508,7 +508,10 @@ Emacs distribution as your standard \"editor\".
508Optional argument LEAVE-DEAD (interactively, a prefix arg) means just 508Optional argument LEAVE-DEAD (interactively, a prefix arg) means just
509kill any existing server communications subprocess. 509kill any existing server communications subprocess.
510 510
511If a server is already running, the server is not started. 511If a server is already running, restart it. If clients are
512running, ask the user for confirmation first, unless optional
513argument INHIBIT-PROMPT is non-nil.
514
512To force-start a server, do \\[server-force-delete] and then 515To force-start a server, do \\[server-force-delete] and then
513\\[server-start]." 516\\[server-start]."
514 (interactive "P") 517 (interactive "P")
@@ -516,12 +519,14 @@ To force-start a server, do \\[server-force-delete] and then
516 ;; Ask the user before deleting existing clients---except 519 ;; Ask the user before deleting existing clients---except
517 ;; when we can't get user input, which may happen when 520 ;; when we can't get user input, which may happen when
518 ;; doing emacsclient --eval "(kill-emacs)" in daemon mode. 521 ;; doing emacsclient --eval "(kill-emacs)" in daemon mode.
519 (if (and (daemonp) 522 (cond
520 (null (cdr (frame-list))) 523 ((and (daemonp)
521 (eq (selected-frame) terminal-frame)) 524 (null (cdr (frame-list)))
522 leave-dead 525 (eq (selected-frame) terminal-frame))
523 (yes-or-no-p 526 leave-dead)
524 "The current server still has clients; delete them? "))) 527 (inhibit-prompt t)
528 (t (yes-or-no-p
529 "The current server still has clients; delete them? "))))
525 (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir)) 530 (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))
526 (server-file (expand-file-name server-name server-dir))) 531 (server-file (expand-file-name server-name server-dir)))
527 (when server-process 532 (when server-process
@@ -560,7 +565,7 @@ server or call `M-x server-force-delete' to forcibly disconnect it.")
560 (add-hook 'delete-frame-functions 'server-handle-delete-frame) 565 (add-hook 'delete-frame-functions 'server-handle-delete-frame)
561 (add-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) 566 (add-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
562 (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) 567 (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function)
563 (add-hook 'kill-emacs-hook (lambda () (server-mode -1))) ;Cleanup upon exit. 568 (add-hook 'kill-emacs-hook 'server-force-stop) ;Cleanup upon exit.
564 (setq server-process 569 (setq server-process
565 (apply #'make-network-process 570 (apply #'make-network-process
566 :name server-name 571 :name server-name
@@ -601,6 +606,11 @@ server or call `M-x server-force-delete' to forcibly disconnect it.")
601 " " (number-to-string (emacs-pid)) ; Kept for compatibility 606 " " (number-to-string (emacs-pid)) ; Kept for compatibility
602 "\n" auth-key))))))))) 607 "\n" auth-key)))))))))
603 608
609(defun server-force-stop ()
610 "Kill all connections to the current server.
611This function is meant to be called from `kill-emacs-hook'."
612 (server-start nil t))
613
604;;;###autoload 614;;;###autoload
605(defun server-force-delete (&optional name) 615(defun server-force-delete (&optional name)
606 "Unconditionally delete connection file for server NAME. 616 "Unconditionally delete connection file for server NAME.