diff options
| author | Stefan Monnier | 2010-11-09 15:07:10 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2010-11-09 15:07:10 -0500 |
| commit | d607b96bc2824116a8fe0e5840ce49da7ce4514f (patch) | |
| tree | 229a11bba88b67e8961db4d10aa8b3725f3a4873 /lisp/server.el | |
| parent | 27410d0ac3406a341cc90ada064047a7f1ea5209 (diff) | |
| parent | c00980655bc15ca019fd6c559c69601be18f2407 (diff) | |
| download | emacs-d607b96bc2824116a8fe0e5840ce49da7ce4514f.tar.gz emacs-d607b96bc2824116a8fe0e5840ce49da7ce4514f.zip | |
Merge from emacs-23
Diffstat (limited to 'lisp/server.el')
| -rw-r--r-- | lisp/server.el | 28 |
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. |
| 503 | This starts a server communications subprocess through which | 503 | This starts a server communications subprocess through which |
| 504 | client \"editors\" can send your editing commands to this Emacs | 504 | client \"editors\" can send your editing commands to this Emacs |
| @@ -508,7 +508,10 @@ Emacs distribution as your standard \"editor\". | |||
| 508 | Optional argument LEAVE-DEAD (interactively, a prefix arg) means just | 508 | Optional argument LEAVE-DEAD (interactively, a prefix arg) means just |
| 509 | kill any existing server communications subprocess. | 509 | kill any existing server communications subprocess. |
| 510 | 510 | ||
| 511 | If a server is already running, the server is not started. | 511 | If a server is already running, restart it. If clients are |
| 512 | running, ask the user for confirmation first, unless optional | ||
| 513 | argument INHIBIT-PROMPT is non-nil. | ||
| 514 | |||
| 512 | To force-start a server, do \\[server-force-delete] and then | 515 | To 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. | ||
| 611 | This 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. |