diff options
| author | Karoly Lorentey | 2004-10-10 16:41:15 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-10-10 16:41:15 +0000 |
| commit | 6d3a46f77949e0b230b32f4b3d7f2681b934985e (patch) | |
| tree | 0ea7de4449fe6ecbbcea2303db30d739588ac3fc | |
| parent | a284b538354c95a7fcf8d2d1f6a88ff7c8374fc1 (diff) | |
| download | emacs-6d3a46f77949e0b230b32f4b3d7f2681b934985e.tar.gz emacs-6d3a46f77949e0b230b32f4b3d7f2681b934985e.zip | |
Small tweaks in server.el.
* lisp/server.el: Doc updates.
(server-select-display): Remove (unused).
(server-handle-suspend-tty): Kill the client in case of errors from
process-send-string.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-255
| -rw-r--r-- | lisp/server.el | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/lisp/server.el b/lisp/server.el index c53d239196d..bfedacbac3a 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -42,7 +42,7 @@ | |||
| 42 | ;; This program transmits the file names to Emacs through | 42 | ;; This program transmits the file names to Emacs through |
| 43 | ;; the server subprocess, and Emacs visits them and lets you edit them. | 43 | ;; the server subprocess, and Emacs visits them and lets you edit them. |
| 44 | 44 | ||
| 45 | ;; Note that any number of clients may dispatch files to emacs to be edited. | 45 | ;; Note that any number of clients may dispatch files to Emacs to be edited. |
| 46 | 46 | ||
| 47 | ;; When you finish editing a Server buffer, again call server-edit | 47 | ;; When you finish editing a Server buffer, again call server-edit |
| 48 | ;; to mark that buffer as done for the client and switch to the next | 48 | ;; to mark that buffer as done for the client and switch to the next |
| @@ -252,7 +252,9 @@ If NOFRAME is non-nil, let the frames live. (To be used from | |||
| 252 | (server-log "Deleted" proc)))) | 252 | (server-log "Deleted" proc)))) |
| 253 | 253 | ||
| 254 | (defun server-log (string &optional client) | 254 | (defun server-log (string &optional client) |
| 255 | "If a *server* buffer exists, write STRING to it for logging purposes." | 255 | "If a *server* buffer exists, write STRING to it for logging purposes. |
| 256 | If CLIENT is non-nil, add a description of it to the logged | ||
| 257 | message." | ||
| 256 | (if (get-buffer "*server*") | 258 | (if (get-buffer "*server*") |
| 257 | (with-current-buffer "*server*" | 259 | (with-current-buffer "*server*" |
| 258 | (goto-char (point-max)) | 260 | (goto-char (point-max)) |
| @@ -290,27 +292,9 @@ If NOFRAME is non-nil, let the frames live. (To be used from | |||
| 290 | "Notify the emacsclient process to suspend itself when its tty device is suspended." | 292 | "Notify the emacsclient process to suspend itself when its tty device is suspended." |
| 291 | (dolist (proc (server-clients-with 'display display)) | 293 | (dolist (proc (server-clients-with 'display display)) |
| 292 | (server-log (format "server-handle-suspend-tty, display %s" display) proc) | 294 | (server-log (format "server-handle-suspend-tty, display %s" display) proc) |
| 293 | (process-send-string proc "-suspend \n"))) | 295 | (condition-case err |
| 294 | 296 | (process-send-string proc "-suspend \n") | |
| 295 | (defun server-select-display (display) | 297 | (file-error (condition-case nil (server-delete-client proc) (error nil)))))) |
| 296 | ;; If the current frame is on `display' we're all set. | ||
| 297 | (unless (equal (frame-parameter (selected-frame) 'display) display) | ||
| 298 | ;; Otherwise, look for an existing frame there and select it. | ||
| 299 | (dolist (frame (frame-list)) | ||
| 300 | (when (equal (frame-parameter frame 'display) display) | ||
| 301 | (select-frame frame))) | ||
| 302 | ;; If there's no frame on that display yet, create a dummy one | ||
| 303 | ;; and select it. | ||
| 304 | (unless (equal (frame-parameter (selected-frame) 'display) display) | ||
| 305 | (select-frame | ||
| 306 | (make-frame-on-display display))))) | ||
| 307 | ;; This frame is only there in place of an actual "current display" | ||
| 308 | ;; setting, so we want it to be as unobtrusive as possible. That's | ||
| 309 | ;; what the invisibility is for. The minibuffer setting is so that | ||
| 310 | ;; we don't end up displaying a buffer in it (which noone would | ||
| 311 | ;; notice). | ||
| 312 | ;; XXX I have found this behaviour to be surprising and annoying. -- Lorentey | ||
| 313 | ;; '((visibility . nil) (minibuffer . only))))))) | ||
| 314 | 298 | ||
| 315 | (defun server-unquote-arg (arg) | 299 | (defun server-unquote-arg (arg) |
| 316 | "Remove &-quotation from ARG." | 300 | "Remove &-quotation from ARG." |
| @@ -356,11 +340,12 @@ Creates the directory if necessary and makes sure: | |||
| 356 | (defun server-start (&optional leave-dead) | 340 | (defun server-start (&optional leave-dead) |
| 357 | "Allow this Emacs process to be a server for client processes. | 341 | "Allow this Emacs process to be a server for client processes. |
| 358 | This starts a server communications subprocess through which | 342 | This starts a server communications subprocess through which |
| 359 | client \"editors\" can send your editing commands to this Emacs job. | 343 | client \"editors\" can send your editing commands to this Emacs |
| 360 | To use the server, set up the program `emacsclient' in the | 344 | job. To use the server, set up the program `emacsclient' in the |
| 361 | Emacs distribution as your standard \"editor\". | 345 | Emacs distribution as your standard \"editor\". |
| 362 | 346 | ||
| 363 | Prefix arg means just kill any existing server communications subprocess." | 347 | Prefix arg LEAVE-DEAD means just kill any existing server |
| 348 | communications subprocess." | ||
| 364 | (interactive "P") | 349 | (interactive "P") |
| 365 | (when (or | 350 | (when (or |
| 366 | (not server-clients) | 351 | (not server-clients) |
| @@ -631,6 +616,9 @@ PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." | |||
| 631 | (delete-process proc))))) | 616 | (delete-process proc))))) |
| 632 | 617 | ||
| 633 | (defun server-goto-line-column (file-line-col) | 618 | (defun server-goto-line-column (file-line-col) |
| 619 | "Move point to the position indicated in FILE-LINE-COL. | ||
| 620 | FILE-LINE-COL should be a three-element list as described in | ||
| 621 | `server-visit-files'." | ||
| 634 | (goto-line (nth 1 file-line-col)) | 622 | (goto-line (nth 1 file-line-col)) |
| 635 | (let ((column-number (nth 2 file-line-col))) | 623 | (let ((column-number (nth 2 file-line-col))) |
| 636 | (if (> column-number 0) | 624 | (if (> column-number 0) |
| @@ -639,6 +627,7 @@ PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." | |||
| 639 | (defun server-visit-files (files client &optional nowait) | 627 | (defun server-visit-files (files client &optional nowait) |
| 640 | "Find FILES and return a list of buffers created. | 628 | "Find FILES and return a list of buffers created. |
| 641 | FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER). | 629 | FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER). |
| 630 | CLIENT is the client that requested this operation. | ||
| 642 | NOWAIT non-nil means this client is not waiting for the results, | 631 | NOWAIT non-nil means this client is not waiting for the results, |
| 643 | so don't mark these buffers specially, just visit them normally." | 632 | so don't mark these buffers specially, just visit them normally." |
| 644 | ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries. | 633 | ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries. |
| @@ -794,6 +783,8 @@ specifically for the clients and did not exist before their request for it." | |||
| 794 | "Non-nil while `server-kill-buffer' or `server-buffer-done' is running.") | 783 | "Non-nil while `server-kill-buffer' or `server-buffer-done' is running.") |
| 795 | 784 | ||
| 796 | (defun server-kill-buffer () | 785 | (defun server-kill-buffer () |
| 786 | "Remove the current buffer from its clients' buffer list. | ||
| 787 | Designed to be added to `kill-buffer-hook'." | ||
| 797 | ;; Prevent infinite recursion if user has made server-done-hook | 788 | ;; Prevent infinite recursion if user has made server-done-hook |
| 798 | ;; call kill-buffer. | 789 | ;; call kill-buffer. |
| 799 | (or server-kill-buffer-running | 790 | (or server-kill-buffer-running |
| @@ -825,11 +816,12 @@ starts server process and that is all. Invoked by \\[server-edit]." | |||
| 825 | 816 | ||
| 826 | (defun server-switch-buffer (&optional next-buffer killed-one) | 817 | (defun server-switch-buffer (&optional next-buffer killed-one) |
| 827 | "Switch to another buffer, preferably one that has a client. | 818 | "Switch to another buffer, preferably one that has a client. |
| 828 | Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it." | 819 | Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it. |
| 829 | ;; KILLED-ONE is t in a recursive call | 820 | |
| 830 | ;; if we have already killed one temp-file server buffer. | 821 | KILLED-ONE is t in a recursive call if we have already killed one |
| 831 | ;; This means we should avoid the final "switch to some other buffer" | 822 | temp-file server buffer. This means we should avoid the final |
| 832 | ;; since we've already effectively done that. | 823 | \"switch to some other buffer\" since we've already effectively |
| 824 | done that." | ||
| 833 | (if (null next-buffer) | 825 | (if (null next-buffer) |
| 834 | (progn | 826 | (progn |
| 835 | (let ((rest server-clients)) | 827 | (let ((rest server-clients)) |
| @@ -919,6 +911,7 @@ If FRAME is nil or missing, then the selected frame is used." | |||
| 919 | (cdr (assoc variable env)))))) | 911 | (cdr (assoc variable env)))))) |
| 920 | 912 | ||
| 921 | (defun server-unload-hook () | 913 | (defun server-unload-hook () |
| 914 | "Unload the server library." | ||
| 922 | (server-start t) | 915 | (server-start t) |
| 923 | (remove-hook 'suspend-tty-functions 'server-handle-suspend-tty) | 916 | (remove-hook 'suspend-tty-functions 'server-handle-suspend-tty) |
| 924 | (remove-hook 'delete-frame-functions 'server-handle-delete-frame) | 917 | (remove-hook 'delete-frame-functions 'server-handle-delete-frame) |