Mercurial > hg > xemacs-beta
comparison lisp/process.el @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | d883f39b8495 |
children | 1f50e6fe4f3f |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
31 ;; This file is dumped with XEmacs. | 31 ;; This file is dumped with XEmacs. |
32 | 32 |
33 ;;; Code: | 33 ;;; Code: |
34 | 34 |
35 | 35 |
36 (defvar binary-process-output) | |
37 (defvar buffer-file-type) | |
38 | |
36 (defgroup processes nil | 39 (defgroup processes nil |
37 "Process, subshell, compilation, and job control support." | 40 "Process, subshell, compilation, and job control support." |
38 :group 'external | 41 :group 'external |
39 :group 'development) | 42 :group 'development) |
40 | 43 |
60 BUFFER may be also nil, meaning that this process is not associated | 63 BUFFER may be also nil, meaning that this process is not associated |
61 with any buffer | 64 with any buffer |
62 Third arg is command name, the name of a shell command. | 65 Third arg is command name, the name of a shell command. |
63 Remaining arguments are the arguments for the command. | 66 Remaining arguments are the arguments for the command. |
64 Wildcards and redirection are handled as usual in the shell." | 67 Wildcards and redirection are handled as usual in the shell." |
65 (cond | 68 ;; We used to use `exec' to replace the shell with the command, |
66 ((eq system-type 'vax-vms) | 69 ;; but that failed to handle (...) and semicolon, etc. |
67 (apply 'start-process name buffer args)) | 70 (start-process name buffer shell-file-name shell-command-switch |
68 ;; We used to use `exec' to replace the shell with the command, | 71 (mapconcat #'identity args " "))) |
69 ;; but that failed to handle (...) and semicolon, etc. | |
70 (t | |
71 (start-process name buffer shell-file-name shell-command-switch | |
72 (mapconcat 'identity args " "))))) | |
73 | 72 |
74 (defun call-process (program &optional infile buffer displayp &rest args) | 73 (defun call-process (program &optional infile buffer displayp &rest args) |
75 "Call PROGRAM synchronously in separate process. | 74 "Call PROGRAM synchronously in separate process. |
76 The program's input comes from file INFILE (nil means `/dev/null'). | 75 The program's input comes from file INFILE (nil means `/dev/null'). |
77 Insert output in BUFFER before point; t means current buffer; | 76 Insert output in BUFFER before point; t means current buffer; |
112 If BUFFER is 0, returns immediately with value nil. | 111 If BUFFER is 0, returns immediately with value nil. |
113 Otherwise waits for PROGRAM to terminate | 112 Otherwise waits for PROGRAM to terminate |
114 and returns a numeric exit status or a signal description string. | 113 and returns a numeric exit status or a signal description string. |
115 If you quit, the process is first killed with SIGINT, then with SIGKILL if | 114 If you quit, the process is first killed with SIGINT, then with SIGKILL if |
116 you quit again before the process exits." | 115 you quit again before the process exits." |
117 (let ((temp (cond ((eq system-type 'vax-vms) | 116 (let ((temp |
118 (make-temp-name "tmp:emacs")) | 117 (make-temp-name |
119 ((or (eq system-type 'ms-dos) | 118 (concat (file-name-as-directory (temp-directory)) |
120 (eq system-type 'windows-nt)) | 119 (if (memq system-type '(ms-dos windows-nt)) "em" "emacs"))))) |
121 (make-temp-name | |
122 (concat (file-name-as-directory | |
123 (temp-directory)) | |
124 "em"))) | |
125 (t | |
126 (make-temp-name | |
127 (concat (file-name-as-directory | |
128 (temp-directory)) | |
129 "emacs")))))) | |
130 (unwind-protect | 120 (unwind-protect |
131 (progn | 121 (progn |
132 (if (or (eq system-type 'ms-dos) | 122 (if (memq system-type '(ms-dos windows-nt)) |
133 (eq system-type 'windows-nt)) | |
134 (let ((buffer-file-type binary-process-output)) | 123 (let ((buffer-file-type binary-process-output)) |
135 (write-region start end temp nil 'silent)) | 124 (write-region start end temp nil 'silent)) |
136 (write-region start end temp nil 'silent)) | 125 (write-region start end temp nil 'silent)) |
137 (if deletep (delete-region start end)) | 126 (if deletep (delete-region start end)) |
138 (apply #'call-process program temp buffer displayp args)) | 127 (apply #'call-process program temp buffer displayp args)) |
139 (condition-case () | 128 (ignore-file-errors (delete-file temp))))) |
140 (delete-file temp) | |
141 (file-error nil))))) | |
142 | 129 |
143 | 130 |
144 (defun shell-command (command &optional output-buffer) | 131 (defun shell-command (command &optional output-buffer) |
145 "Execute string COMMAND in inferior shell; display output, if any. | 132 "Execute string COMMAND in inferior shell; display output, if any. |
146 | 133 |
186 | 173 |
187 ;; We have a sentinel to prevent insertion of a termination message | 174 ;; We have a sentinel to prevent insertion of a termination message |
188 ;; in the buffer itself. | 175 ;; in the buffer itself. |
189 (defun shell-command-sentinel (process signal) | 176 (defun shell-command-sentinel (process signal) |
190 (if (memq (process-status process) '(exit signal)) | 177 (if (memq (process-status process) '(exit signal)) |
191 (message "%s: %s." | 178 (message "%s: %s." |
192 (car (cdr (cdr (process-command process)))) | 179 (car (cdr (cdr (process-command process)))) |
193 (substring signal 0 -1)))) | 180 (substring signal 0 -1)))) |
194 | 181 |
195 (defun shell-command-on-region (start end command | 182 (defun shell-command-on-region (start end command |
196 &optional output-buffer replace) | 183 &optional output-buffer replace) |
258 (setq exit-status | 245 (setq exit-status |
259 (call-process-region (point-min) (point-max) | 246 (call-process-region (point-min) (point-max) |
260 shell-file-name t t nil | 247 shell-file-name t t nil |
261 shell-command-switch command)) | 248 shell-command-switch command)) |
262 (setq success t)) | 249 (setq success t)) |
263 ;; Clear the output buffer, | 250 ;; Clear the output buffer, |
264 ;; then run the command with output there. | 251 ;; then run the command with output there. |
265 (save-excursion | 252 (save-excursion |
266 (set-buffer buffer) | 253 (set-buffer buffer) |
267 (setq buffer-read-only nil) | 254 (setq buffer-read-only nil) |
268 ;; XEmacs change | 255 ;; XEmacs change |
293 (set-buffer buffer) | 280 (set-buffer buffer) |
294 (goto-char (point-min)) | 281 (goto-char (point-min)) |
295 (buffer-substring (point) | 282 (buffer-substring (point) |
296 (progn (end-of-line) | 283 (progn (end-of-line) |
297 (point)))))) | 284 (point)))))) |
298 (t | 285 (t |
299 (set-window-start (display-buffer buffer) 1)))))))) | 286 (set-window-start (display-buffer buffer) 1)))))))) |
300 | 287 |
301 | 288 |
302 (defun start-process (name buffer program &rest program-args) | 289 (defun start-process (name buffer program &rest program-args) |
303 "Start a program in a subprocess. Return the process object for it. | 290 "Start a program in a subprocess. Return the process object for it. |