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