diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/server.el | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/lisp/server.el b/lisp/server.el index d91a51e425a..d2406e21bdf 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -251,8 +251,16 @@ This means that the server should not kill the buffer when you say you | |||
| 251 | are done with it in the server.") | 251 | are done with it in the server.") |
| 252 | (make-variable-buffer-local 'server-existing-buffer) | 252 | (make-variable-buffer-local 'server-existing-buffer) |
| 253 | 253 | ||
| 254 | ;;;###autoload | 254 | (defvar server-external-socket-initialised nil |
| 255 | (defcustom server-name "server" | 255 | "When an external socket is passed into Emacs, we need to call |
| 256 | `server-start' in order to initialise the connection. This flag | ||
| 257 | prevents multiple initialisations when an external socket has | ||
| 258 | been consumed.") | ||
| 259 | |||
| 260 | (defcustom server-name | ||
| 261 | (if (get-external-sockname) | ||
| 262 | (file-name-nondirectory (get-external-sockname)) | ||
| 263 | "server") | ||
| 256 | "The name of the Emacs server, if this Emacs process creates one. | 264 | "The name of the Emacs server, if this Emacs process creates one. |
| 257 | The command `server-start' makes use of this. It should not be | 265 | The command `server-start' makes use of this. It should not be |
| 258 | changed while a server is running." | 266 | changed while a server is running." |
| @@ -263,8 +271,10 @@ changed while a server is running." | |||
| 263 | ;; We do not use `temporary-file-directory' here, because emacsclient | 271 | ;; We do not use `temporary-file-directory' here, because emacsclient |
| 264 | ;; does not read the init file. | 272 | ;; does not read the init file. |
| 265 | (defvar server-socket-dir | 273 | (defvar server-socket-dir |
| 266 | (and (featurep 'make-network-process '(:family local)) | 274 | (if (get-external-sockname) |
| 267 | (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))) | 275 | (file-name-directory (get-external-sockname)) |
| 276 | (and (featurep 'make-network-process '(:family local)) | ||
| 277 | (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))) | ||
| 268 | "The directory in which to place the server socket. | 278 | "The directory in which to place the server socket. |
| 269 | If local sockets are not supported, this is nil.") | 279 | If local sockets are not supported, this is nil.") |
| 270 | 280 | ||
| @@ -618,23 +628,29 @@ To force-start a server, do \\[server-force-delete] and then | |||
| 618 | (when server-process | 628 | (when server-process |
| 619 | ;; kill it dead! | 629 | ;; kill it dead! |
| 620 | (ignore-errors (delete-process server-process))) | 630 | (ignore-errors (delete-process server-process))) |
| 621 | ;; Delete the socket files made by previous server invocations. | 631 | ;; Check to see if an uninitialised external socket has been |
| 622 | (if (not (eq t (server-running-p server-name))) | 632 | ;; passed in, if that is the case, skip checking |
| 623 | ;; Remove any leftover socket or authentication file | 633 | ;; `server-running-p' as this will return the wrong result. |
| 624 | (ignore-errors | 634 | (if (and (get-external-sockname) |
| 625 | (let (delete-by-moving-to-trash) | 635 | (not server-external-socket-initialised)) |
| 626 | (delete-file server-file))) | 636 | (setq server-external-socket-initialised t) |
| 627 | (setq server-mode nil) ;; already set by the minor mode code | 637 | ;; Delete the socket files made by previous server invocations. |
| 628 | (display-warning | 638 | (if (not (eq t (server-running-p server-name))) |
| 629 | 'server | 639 | ;; Remove any leftover socket or authentication file |
| 630 | (concat "Unable to start the Emacs server.\n" | 640 | (ignore-errors |
| 631 | (format "There is an existing Emacs server, named %S.\n" | 641 | (let (delete-by-moving-to-trash) |
| 632 | server-name) | 642 | (delete-file server-file))) |
| 633 | (substitute-command-keys | 643 | (setq server-mode nil) ;; already set by the minor mode code |
| 634 | "To start the server in this Emacs process, stop the existing | 644 | (display-warning |
| 645 | 'server | ||
| 646 | (concat "Unable to start the Emacs server.\n" | ||
| 647 | (format "There is an existing Emacs server, named %S.\n" | ||
| 648 | server-name) | ||
| 649 | (substitute-command-keys | ||
| 650 | "To start the server in this Emacs process, stop the existing | ||
| 635 | server or call `\\[server-force-delete]' to forcibly disconnect it.")) | 651 | server or call `\\[server-force-delete]' to forcibly disconnect it.")) |
| 636 | :warning) | 652 | :warning) |
| 637 | (setq leave-dead t)) | 653 | (setq leave-dead t))) |
| 638 | ;; If this Emacs already had a server, clear out associated status. | 654 | ;; If this Emacs already had a server, clear out associated status. |
| 639 | (while server-clients | 655 | (while server-clients |
| 640 | (server-delete-client (car server-clients))) | 656 | (server-delete-client (car server-clients))) |