Mercurial > hg > xemacs-beta
comparison lisp/code-process.el @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | 8626e4521993 |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
27 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 27 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
28 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 28 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
29 ;; 02111-1307, USA. | 29 ;; 02111-1307, USA. |
30 | 30 |
31 ;;; Code: | 31 ;;; Code: |
32 | |
33 (eval-when-compile | |
34 (defvar buffer-file-type) | |
35 (defvar binary-process-output)) | |
36 | 32 |
37 (defvar process-coding-system-alist nil | 33 (defvar process-coding-system-alist nil |
38 "Alist to decide a coding system to use for a process I/O operation. | 34 "Alist to decide a coding system to use for a process I/O operation. |
39 The format is ((PATTERN . VAL) ...), | 35 The format is ((PATTERN . VAL) ...), |
40 where PATTERN is a regular expression matching a program name, | 36 where PATTERN is a regular expression matching a program name, |
110 and returns a numeric exit status or a signal description string. | 106 and returns a numeric exit status or a signal description string. |
111 If you quit, the process is first killed with SIGINT, then with SIGKILL if | 107 If you quit, the process is first killed with SIGINT, then with SIGKILL if |
112 you quit again before the process exits." | 108 you quit again before the process exits." |
113 (let ((temp | 109 (let ((temp |
114 (make-temp-name | 110 (make-temp-name |
115 (concat (file-name-as-directory (temp-directory)) | 111 (concat (file-name-as-directory (temp-directory)) "emacs")))) |
116 (if (memq system-type '(ms-dos windows-nt)) "em" "emacs"))))) | |
117 (unwind-protect | 112 (unwind-protect |
118 (let (cs-r cs-w) | 113 (let (cs-r cs-w) |
119 (let (ret) | 114 (let (ret) |
120 (catch 'found | 115 (catch 'found |
121 (let ((alist process-coding-system-alist) | 116 (let ((alist process-coding-system-alist) |
135 cs-w ret)))) | 130 cs-w ret)))) |
136 (let ((coding-system-for-read | 131 (let ((coding-system-for-read |
137 (or coding-system-for-read cs-r)) | 132 (or coding-system-for-read cs-r)) |
138 (coding-system-for-write | 133 (coding-system-for-write |
139 (or coding-system-for-write cs-w))) | 134 (or coding-system-for-write cs-w))) |
140 (if (memq system-type '(ms-dos windows-nt)) | 135 (write-region start end temp nil 'silent) |
141 (let ((buffer-file-type binary-process-output)) | |
142 (write-region start end temp nil 'silent)) | |
143 (write-region start end temp nil 'silent)) | |
144 (if deletep (delete-region start end)) | 136 (if deletep (delete-region start end)) |
145 (apply #'call-process program temp buffer displayp args))) | 137 (apply #'call-process program temp buffer displayp args))) |
146 (ignore-file-errors (delete-file temp))))) | 138 (ignore-file-errors (delete-file temp))))) |
147 | 139 |
148 (defun start-process (name buffer program &rest program-args) | 140 (defun start-process (name buffer program &rest program-args) |
196 If VAL is a function symbol, the function must return a coding system | 188 If VAL is a function symbol, the function must return a coding system |
197 or a cons of coding systems which are used as above. | 189 or a cons of coding systems which are used as above. |
198 | 190 |
199 See also the function `find-operation-coding-system'.") | 191 See also the function `find-operation-coding-system'.") |
200 | 192 |
201 (defun open-network-stream (name buffer host service) | 193 (defun open-network-stream (name buffer host service &optional protocol) |
202 "Open a TCP connection for a service to a host. | 194 "Open a TCP connection for a service to a host. |
203 Returns a subprocess-object to represent the connection. | 195 Return a subprocess-object to represent the connection. |
204 Input and output work as for subprocesses; `delete-process' closes it. | 196 Input and output work as for subprocesses; `delete-process' closes it. |
205 Args are NAME BUFFER HOST SERVICE. | 197 Args are NAME BUFFER HOST SERVICE. |
206 NAME is name for process. It is modified if necessary to make it unique. | 198 NAME is name for process. It is modified if necessary to make it unique. |
207 BUFFER is the buffer (or buffer-name) to associate with the process. | 199 BUFFER is the buffer (or buffer-name) to associate with the process. |
208 Process output goes at end of that buffer, unless you specify | 200 Process output goes at end of that buffer, unless you specify |
209 an output stream or filter function to handle the output. | 201 an output stream or filter function to handle the output. |
210 BUFFER may be also nil, meaning that this process is not associated | 202 BUFFER may be also nil, meaning that this process is not associated |
211 with any buffer | 203 with any buffer |
212 Third arg is name of the host to connect to, or its IP address. | 204 Third arg is name of the host to connect to, or its IP address. |
213 Fourth arg SERVICE is name of the service desired, or an integer | 205 Fourth arg SERVICE is name of the service desired, or an integer |
214 specifying a port number to connect to." | 206 specifying a port number to connect to. |
207 Fifth argument PROTOCOL is a network protocol. Currently 'tcp | |
208 (Transmission Control Protocol) and 'udp (User Datagram Protocol) are | |
209 supported. When omitted, 'tcp is assumed. | |
210 | |
211 Ouput via `process-send-string' and input via buffer or filter (see | |
212 `set-process-filter') are stream-oriented. That means UDP datagrams are | |
213 not guaranteed to be sent and received in discrete packets. (But small | |
214 datagrams around 500 bytes that are not truncated by `process-send-string' | |
215 are usually fine.) Note further that UDP protocol does not guard against | |
216 lost packets." | |
215 (let (cs-r cs-w) | 217 (let (cs-r cs-w) |
216 (let (ret) | 218 (let (ret) |
217 (catch 'found | 219 (catch 'found |
218 (let ((alist network-coding-system-alist) | 220 (let ((alist network-coding-system-alist) |
219 (case-fold-search nil) | 221 (case-fold-search nil) |
243 cs-w ret)))) | 245 cs-w ret)))) |
244 (let ((coding-system-for-read | 246 (let ((coding-system-for-read |
245 (or coding-system-for-read cs-r)) | 247 (or coding-system-for-read cs-r)) |
246 (coding-system-for-write | 248 (coding-system-for-write |
247 (or coding-system-for-write cs-w))) | 249 (or coding-system-for-write cs-w))) |
248 (open-network-stream-internal name buffer host service)))) | 250 (open-network-stream-internal name buffer host service protocol)))) |
249 | 251 |
250 ;;; mule-process.el ends here | 252 ;;; code-process.el ends here |