diff options
| author | Dave Love | 2003-01-15 17:49:32 +0000 |
|---|---|---|
| committer | Dave Love | 2003-01-15 17:49:32 +0000 |
| commit | 33186f32d8061fec2d61797bbcb1f44aa028e3bd (patch) | |
| tree | dd094c3fd01074164afe319ba15c4ab13b95f957 | |
| parent | 7d7b15b874629760af1ed61f8ddf846d04d44559 (diff) | |
| download | emacs-33186f32d8061fec2d61797bbcb1f44aa028e3bd.tar.gz emacs-33186f32d8061fec2d61797bbcb1f44aa028e3bd.zip | |
(server-window): Customize.
(server-mode): New.
(server-unload-hook): Call server-start.
| -rw-r--r-- | lisp/server.el | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/lisp/server.el b/lisp/server.el index 456dcb61ae8..321a61ed8bd 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; server.el --- Lisp code for GNU Emacs running as server process | 1 | ;;; server.el --- Lisp code for GNU Emacs running as server process |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1986, 87, 92, 94, 95, 96, 97, 98, 99, 2000, 2001 | 3 | ;; Copyright (C) 1986, 87, 92, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002 |
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; Free Software Foundation, Inc. |
| 5 | 5 | ||
| 6 | ;; Author: William Sommerfeld <wesommer@athena.mit.edu> | 6 | ;; Author: William Sommerfeld <wesommer@athena.mit.edu> |
| @@ -114,17 +114,29 @@ When a buffer is marked as \"done\", it is removed from this list.") | |||
| 114 | ;; Changing major modes should not erase this local. | 114 | ;; Changing major modes should not erase this local. |
| 115 | (put 'server-buffer-clients 'permanent-local t) | 115 | (put 'server-buffer-clients 'permanent-local t) |
| 116 | 116 | ||
| 117 | (defvar server-window nil | 117 | (defcustom server-window nil |
| 118 | "*The window to use for selecting Emacs server buffers. | 118 | "*Specification of the window to use for selecting Emacs server buffers. |
| 119 | If nil, use the selected window. | 119 | If nil, use the selected window. |
| 120 | If it is a frame, use the frame's selected window. | ||
| 121 | If it is a function, it should take one argument (a buffer) and | 120 | If it is a function, it should take one argument (a buffer) and |
| 122 | display and select it. A common value is `pop-to-buffer'.") | 121 | display and select it. A common value is `pop-to-buffer'. |
| 122 | If it is a window, use that. | ||
| 123 | If it is a frame, use the frame's selected window. | ||
| 124 | |||
| 125 | It is not meaningful to set this to a specific frame or window with Custom. | ||
| 126 | Only programs can do so." | ||
| 127 | :group 'server | ||
| 128 | :version "21.4" | ||
| 129 | :type '(choice (const :tag "Use selected window" | ||
| 130 | :match (lambda (widget value) | ||
| 131 | (not (functionp value))) | ||
| 132 | nil) | ||
| 133 | (function-item :tag "Use pop-to-buffer" pop-to-buffer) | ||
| 134 | (function :tag "Other function"))) | ||
| 123 | 135 | ||
| 124 | (defcustom server-temp-file-regexp "^/tmp/Re\\|/draft$" | 136 | (defcustom server-temp-file-regexp "^/tmp/Re\\|/draft$" |
| 125 | "*Regexp which should match filenames of temporary files | 137 | "*Regexp matching names of temporary files. |
| 126 | which are deleted and reused after each edit | 138 | These are deleted and reused after each edit by the programs that |
| 127 | by the programs that invoke the Emacs server." | 139 | invoke the Emacs server." |
| 128 | :group 'server | 140 | :group 'server |
| 129 | :type 'regexp) | 141 | :type 'regexp) |
| 130 | 142 | ||
| @@ -149,13 +161,15 @@ This means that the server should not kill the buffer when you say you | |||
| 149 | are done with it in the server.") | 161 | are done with it in the server.") |
| 150 | (make-variable-buffer-local 'server-existing-buffer) | 162 | (make-variable-buffer-local 'server-existing-buffer) |
| 151 | 163 | ||
| 164 | ;; Fixme: This doesn't look secure. If it really is, it deserves a | ||
| 165 | ;; comment, but I'd expect it to be created in a protected subdir as | ||
| 166 | ;; normal. -- fx | ||
| 152 | (defvar server-socket-name | 167 | (defvar server-socket-name |
| 153 | (format "/tmp/esrv%d-%s" (user-uid) | 168 | (format "/tmp/esrv%d-%s" (user-uid) |
| 154 | (substring (system-name) 0 (string-match "\\." (system-name))))) | 169 | (substring (system-name) 0 (string-match "\\." (system-name))))) |
| 155 | 170 | ||
| 156 | ;; If a *server* buffer exists, | ||
| 157 | ;; write STRING to it for logging purposes. | ||
| 158 | (defun server-log (string &optional client) | 171 | (defun server-log (string &optional client) |
| 172 | "If a *server* buffer exists, write STRING to it for logging purposes." | ||
| 159 | (if (get-buffer "*server*") | 173 | (if (get-buffer "*server*") |
| 160 | (with-current-buffer "*server*" | 174 | (with-current-buffer "*server*" |
| 161 | (goto-char (point-max)) | 175 | (goto-char (point-max)) |
| @@ -249,10 +263,24 @@ Prefix arg means just kill any existing server communications subprocess." | |||
| 249 | ;; to file-name-coding-system. | 263 | ;; to file-name-coding-system. |
| 250 | :coding 'raw-text))) | 264 | :coding 'raw-text))) |
| 251 | (set-default-file-modes umask))))) | 265 | (set-default-file-modes umask))))) |
| 266 | |||
| 267 | ;;;###autoload | ||
| 268 | (define-minor-mode server-mode | ||
| 269 | "Toggle Server mode. | ||
| 270 | With ARG, turn Server mode on if ARG is positive, off otherwise. | ||
| 271 | Server mode runs a process that accepts commands from the | ||
| 272 | `emacsclient' program. See `server-start' and Info node `Emacs server'." | ||
| 273 | :global t | ||
| 274 | :group 'server | ||
| 275 | :version "21.4" | ||
| 276 | ;; Fixme: Should this check for an existing server socket and do | ||
| 277 | ;; nothing if there is one (for multiple Emacs sessions)? | ||
| 278 | (server-start (not server-mode))) | ||
| 279 | (custom-add-version 'server-mode "21.4") | ||
| 252 | 280 | ||
| 253 | ;Process a request from the server to edit some files. | ||
| 254 | ;Format of STRING is "PATH PATH PATH... \n" | ||
| 255 | (defun server-process-filter (proc string) | 281 | (defun server-process-filter (proc string) |
| 282 | "Process a request from the server to edit some files. | ||
| 283 | PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." | ||
| 256 | (server-log string proc) | 284 | (server-log string proc) |
| 257 | (let ((ps (assq proc server-previous-strings))) | 285 | (let ((ps (assq proc server-previous-strings))) |
| 258 | (when (cdr ps) | 286 | (when (cdr ps) |
| @@ -587,6 +615,7 @@ Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it." | |||
| 587 | (global-set-key "\C-x#" 'server-edit) | 615 | (global-set-key "\C-x#" 'server-edit) |
| 588 | 616 | ||
| 589 | (defun server-unload-hook () | 617 | (defun server-unload-hook () |
| 618 | (server-start t) | ||
| 590 | (remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) | 619 | (remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) |
| 591 | (remove-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) | 620 | (remove-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) |
| 592 | (remove-hook 'kill-buffer-hook 'server-kill-buffer)) | 621 | (remove-hook 'kill-buffer-hook 'server-kill-buffer)) |