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)))
(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))
If invoked with a prefix argument, or if there is no server process running,
starts server process and that is all. Invoked by \\[server-edit]."
(interactive "P")
- (if (or arg
- (not server-process)
- (memq (process-status server-process) '(signal exit)))
- (server-start nil)
- (apply 'server-switch-buffer (server-done))))
+ (cond
+ ((or arg
+ (not server-process)
+ (memq (process-status server-process) '(signal exit)))
+ (server-mode 1))
+ (server-clients (apply 'server-switch-buffer (server-done)))
+ (t (message "No server editing buffers exist"))))
(defun server-switch-buffer (&optional next-buffer killed-one)
"Switch to another buffer, preferably one that has a client.
(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)
\f
(provide 'server)
-;;; arch-tag: 1f7ecb42-f00a-49f8-906d-61995d84c8d6
+;; arch-tag: 1f7ecb42-f00a-49f8-906d-61995d84c8d6
;;; server.el ends here