Mercurial > hg > xemacs-beta
comparison lisp/packages/gnuserv.el @ 167:85ec50267440 r20-3b10
Import from CVS: tag r20-3b10
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:45:46 +0200 |
parents | 5a88923fcbfe |
children | 929b76928fce |
comparison
equal
deleted
inserted
replaced
166:7a77eb660975 | 167:85ec50267440 |
---|---|
1 ;;; gnuserv.el --- Lisp interface code between Emacs and gnuserv | 1 ;;; gnuserv.el --- Lisp interface code between Emacs and gnuserv |
2 ;; Copyright (C) 1989-1997 Free Software Foundation, Inc. | 2 ;; Copyright (C) 1989-1997 Free Software Foundation, Inc. |
3 | 3 |
4 ;; Version: 3.4 | 4 ;; Version: 3.6 |
5 ;; Author: Andy Norman (ange@hplb.hpl.hp.com), originally based on server.el | 5 ;; Author: Andy Norman (ange@hplb.hpl.hp.com), originally based on server.el |
6 ;; Hrvoje Niksic <hniksic@srce.hr> | 6 ;; Hrvoje Niksic <hniksic@srce.hr> |
7 ;; Maintainer: Jan Vroonhof <vroonhof@math.ethz.ch>, | 7 ;; Maintainer: Jan Vroonhof <vroonhof@math.ethz.ch>, |
8 ;; Hrvoje Niksic <hniksic@srce.hr> | 8 ;; Hrvoje Niksic <hniksic@srce.hr> |
9 ;; Keywords: environment, processes, terminals | 9 ;; Keywords: environment, processes, terminals |
78 | 78 |
79 | 79 |
80 ;;; Code: | 80 ;;; Code: |
81 | 81 |
82 (defconst gnuserv-rcs-version | 82 (defconst gnuserv-rcs-version |
83 "$Id: gnuserv.el,v 1.11 1997/06/26 02:31:17 steve Exp $") | 83 "$Id: gnuserv.el,v 1.12 1997/06/29 23:13:06 steve Exp $") |
84 | 84 |
85 (defgroup gnuserv nil | 85 (defgroup gnuserv nil |
86 "The gnuserv suite of programs to talk to Emacs from outside." | 86 "The gnuserv suite of programs to talk to Emacs from outside." |
87 :group 'environment | 87 :group 'environment |
88 :group 'processes | 88 :group 'processes |
89 :group 'terminals) | 89 :group 'terminals) |
90 | 90 |
91 | |
92 | |
93 ;; Provide the old variables as aliases, to avoid breaking .emacs | |
94 ;; files. However, they are obsolete and should be converted to the | |
95 ;; new forms. This ugly crock must be before the variable | |
96 ;; declaration, or the scheme fails. | |
97 | |
98 (define-obsolete-variable-alias 'server-frame 'gnuserv-frame) | |
99 (define-obsolete-variable-alias 'server-done-function | |
100 'gnuserv-done-function) | |
101 (define-obsolete-variable-alias 'server-done-temp-file-function | |
102 'gnuserv-done-temp-file-function) | |
103 (define-obsolete-variable-alias 'server-find-file-function | |
104 'gnuserv-find-file-function) | |
105 (define-obsolete-variable-alias 'server-program | |
106 'gnuserv-program) | |
107 (define-obsolete-variable-alias 'server-visit-hook | |
108 'gnuserv-visit-hook) | |
109 (define-obsolete-variable-alias 'server-done-hook | |
110 'gnuserv-done-hook) | |
111 (define-obsolete-variable-alias 'server-kill-quietly | |
112 'gnuserv-kill-quietly) | |
113 (define-obsolete-variable-alias 'server-temp-file-regexp | |
114 'gnuserv-temp-file-regexp) | |
115 (define-obsolete-variable-alias 'server-make-temp-file-backup | |
116 'gnuserv-make-temp-file-backup) | |
91 | 117 |
92 ;;;###autoload | 118 ;;;###autoload |
93 (defcustom gnuserv-frame nil | 119 (defcustom gnuserv-frame nil |
94 "*The frame to be used to display all edited files. | 120 "*The frame to be used to display all edited files. |
95 If nil, then a new frame is created for each file edited. | 121 If nil, then a new frame is created for each file edited. |
182 "*Non-nil makes the server backup temporary files also." | 208 "*Non-nil makes the server backup temporary files also." |
183 :type 'boolean | 209 :type 'boolean |
184 :group 'gnuserv) | 210 :group 'gnuserv) |
185 | 211 |
186 | 212 |
187 ;; The old functions are provided as aliases, to avoid breaking .emacs | |
188 ;; files. However, they are obsolete and should be avoided. | |
189 | |
190 (define-obsolete-variable-alias 'server-frame 'gnuserv-frame) | |
191 (define-obsolete-variable-alias 'server-done-function 'gnuserv-done-function) | |
192 (define-obsolete-variable-alias 'server-done-temp-file-function | |
193 'gnuserv-done-temp-file-function) | |
194 (define-obsolete-variable-alias 'server-find-file-function | |
195 'gnuserv-find-file-function) | |
196 (define-obsolete-variable-alias 'server-program | |
197 'gnuserv-program) | |
198 (define-obsolete-variable-alias 'server-visit-hook | |
199 'gnuserv-visit-hook) | |
200 (define-obsolete-variable-alias 'server-done-hook | |
201 'gnuserv-done-hook) | |
202 (define-obsolete-variable-alias 'server-kill-quietly | |
203 'gnuserv-kill-quietly) | |
204 (define-obsolete-variable-alias 'server-temp-file-regexp | |
205 'gnuserv-temp-file-regexp) | |
206 (define-obsolete-variable-alias 'server-make-temp-file-backup | |
207 'gnuserv-make-temp-file-backup) | |
208 | |
209 | |
210 ;;; Internal variables: | 213 ;;; Internal variables: |
211 | 214 |
212 (defstruct gnuclient | 215 (defstruct gnuclient |
213 "An object that encompasses several buffers in one. | 216 "An object that encompasses several buffers in one. |
214 Normally, a client connecting to Emacs will be assigned an id, and | 217 Normally, a client connecting to Emacs will be assigned an id, and |
286 ;;; Communication functions | 289 ;;; Communication functions |
287 | 290 |
288 ;; We used to restart the server here, but it's too risky -- if | 291 ;; We used to restart the server here, but it's too risky -- if |
289 ;; something goes awry, it's too easy to wind up in a loop. | 292 ;; something goes awry, it's too easy to wind up in a loop. |
290 (defun gnuserv-sentinel (proc msg) | 293 (defun gnuserv-sentinel (proc msg) |
294 (let ((msgstring (concat "Gnuserv process %s; restart with `%s'")) | |
295 (keystring (substitute-command-keys "\\[gnuserv-start]"))) | |
291 (case (process-status proc) | 296 (case (process-status proc) |
292 (exit | 297 (exit |
293 (message | 298 (message msgstring "exited" keystring) |
294 (substitute-command-keys | |
295 "Gnuserv subprocess exited; restart with `\\[gnuserv-start]'")) | |
296 (gnuserv-prepare-shutdown)) | 299 (gnuserv-prepare-shutdown)) |
297 (signal | 300 (signal |
298 (message | 301 (message msgstring "killed" keystring) |
299 (substitute-command-keys | |
300 "Gnuserv subprocess killed; restart with `\\[gnuserv-start]'")) | |
301 (gnuserv-prepare-shutdown)) | 302 (gnuserv-prepare-shutdown)) |
302 (closed | 303 (closed |
303 (message | 304 (message msgstring "closed" keystring)) |
304 (substitute-command-keys | |
305 "Gnuserv subprocess closed; restart with `\\[gnuserv-start]'")) | |
306 (gnuserv-prepare-shutdown)))) | 305 (gnuserv-prepare-shutdown)))) |
307 | 306 |
308 ;; This function reads client requests from our current server. Every | 307 ;; This function reads client requests from our current server. Every |
309 ;; client is identified by a unique ID within the server | 308 ;; client is identified by a unique ID within the server |
310 ;; (incidentally, the same ID is the file descriptor the server uses | 309 ;; (incidentally, the same ID is the file descriptor the server uses |
464 ;; user can exit via `delete-frame'. OTOH, if FLAGS are nil | 463 ;; user can exit via `delete-frame'. OTOH, if FLAGS are nil |
465 ;; and there are some buffers, the user can exit via | 464 ;; and there are some buffers, the user can exit via |
466 ;; `gnuserv-edit'. | 465 ;; `gnuserv-edit'. |
467 (if (and (not (or quick view)) | 466 (if (and (not (or quick view)) |
468 (gnuclient-buffers client)) | 467 (gnuclient-buffers client)) |
469 (message (substitute-command-keys | 468 (message "%s" |
469 (substitute-command-keys | |
470 "Type `\\[gnuserv-edit]' to finish editing")) | 470 "Type `\\[gnuserv-edit]' to finish editing")) |
471 (or dest-frame | 471 (or dest-frame |
472 (message (substitute-command-keys | 472 (message "%s" |
473 (substitute-command-keys | |
473 "Type `\\[delete-frame]' to finish editing"))))))))) | 474 "Type `\\[delete-frame]' to finish editing"))))))))) |
474 | 475 |
475 | 476 |
476 ;;; Functions that hook into Emacs in various way to enable operation | 477 ;;; Functions that hook into Emacs in various way to enable operation |
477 | 478 |
541 (dolist (client gnuserv-clients) | 542 (dolist (client gnuserv-clients) |
542 (when (eq device (gnuclient-device client)) | 543 (when (eq device (gnuclient-device client)) |
543 ;; we must make sure that the server kill doesn't result in | 544 ;; we must make sure that the server kill doesn't result in |
544 ;; killing the device, because it would cause a device-dead | 545 ;; killing the device, because it would cause a device-dead |
545 ;; error when `delete-device' tries to do the job later. | 546 ;; error when `delete-device' tries to do the job later. |
546 (gnuserv-kill-client (car client) t)))) | 547 (gnuserv-kill-client client t)))) |
547 (callf2 delq device gnuserv-devices)) | 548 (callf2 delq device gnuserv-devices)) |
548 | 549 |
549 (add-hook 'delete-device-hook 'gnuserv-check-device) | 550 (add-hook 'delete-device-hook 'gnuserv-check-device) |
550 | 551 |
551 (defun gnuserv-temp-file-p (buffer) | 552 (defun gnuserv-temp-file-p (buffer) |