changeset 70672:06de67179ba1

(server-start): Only create a directory if needed. (server-edit, server-unload-hook): server-start => server-mode. (kill-emacs-hook): Cleanup upon exit.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 16 May 2006 06:53:01 +0000
parents 2dba1b0f2902
children 798fa39b6207
files lisp/ChangeLog lisp/server.el
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue May 16 03:35:46 2006 +0000
+++ b/lisp/ChangeLog	Tue May 16 06:53:01 2006 +0000
@@ -1,3 +1,9 @@
+2006-05-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* server.el (server-start): Only create a directory if needed.
+	(server-edit, server-unload-hook): server-start => server-mode.
+	(kill-emacs-hook): Cleanup upon exit.
+
 2006-05-15  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* hexl.el (hexlify-buffer): Encode process arguments manually.
--- a/lisp/server.el	Tue May 16 03:35:46 2006 +0000
+++ b/lisp/server.el	Tue May 16 06:53:01 2006 +0000
@@ -252,8 +252,6 @@
 
 Prefix arg means just kill any existing server communications subprocess."
   (interactive "P")
-  ;; Make sure there is a safe directory in which to place the socket.
-  (server-ensure-safe-dir server-socket-dir)
   ;; kill it dead!
   (if server-process
       (condition-case () (delete-process server-process) (error nil)))
@@ -265,7 +263,10 @@
   (while server-clients
     (let ((buffer (nth 1 (car server-clients))))
       (server-buffer-done buffer)))
+  ;; Now any previous server is properly stopped.
   (unless leave-dead
+    ;; Make sure there is a safe directory in which to place the socket.
+    (server-ensure-safe-dir server-socket-dir)
     (if server-process
 	(server-log (message "Restarting server")))
     (letf (((default-file-modes) ?\700))
@@ -578,7 +579,7 @@
   (if (or arg
 	  (not server-process)
 	  (memq (process-status server-process) '(signal exit)))
-      (server-start nil)
+      (server-mode 1)
     (apply 'server-switch-buffer (server-done))))
 
 (defun server-switch-buffer (&optional next-buffer killed-one)
@@ -637,14 +638,15 @@
 (define-key ctl-x-map "#" 'server-edit)
 
 (defun server-unload-hook ()
-  (server-start t)
+  (server-mode -1)
   (remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
   (remove-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function)
   (remove-hook 'kill-buffer-hook 'server-kill-buffer))
 
+(add-hook 'kill-emacs-hook (lambda () (server-mode -1))) ;Cleanup upon exit.
 (add-hook 'server-unload-hook 'server-unload-hook)
 
 (provide 'server)
 
-;;; arch-tag: 1f7ecb42-f00a-49f8-906d-61995d84c8d6
+;; arch-tag: 1f7ecb42-f00a-49f8-906d-61995d84c8d6
 ;;; server.el ends here