Mercurial > emacs
comparison lisp/eshell/esh-io.el @ 31241:3099993cba0f
See ChangeLog
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Tue, 29 Aug 2000 00:47:45 +0000 |
parents | 34b1ab9d583d |
children | 8e57189d61b4 |
comparison
equal
deleted
inserted
replaced
31240:10b1c85c0bbe | 31241:3099993cba0f |
---|---|
130 argument (which is the symbol `overwrite', `append' or `insert'), and | 130 argument (which is the symbol `overwrite', `append' or `insert'), and |
131 the function is expected to return another function -- which is the | 131 the function is expected to return another function -- which is the |
132 output function. Otherwise, the second element itself is the output | 132 output function. Otherwise, the second element itself is the output |
133 function. | 133 function. |
134 | 134 |
135 The output function is then called repeatedly with a single strings, | 135 The output function is then called repeatedly with single strings, |
136 with represents success pieces of the output of the command, until nil | 136 which represents successive pieces of the output of the command, until nil |
137 is passed, meaning EOF. | 137 is passed, meaning EOF. |
138 | 138 |
139 NOTE: /dev/null is handled specially as a virtual target, and should | 139 NOTE: /dev/null is handled specially as a virtual target, and should |
140 not be added to this variable." | 140 not be added to this variable." |
141 :type '(repeat | 141 :type '(repeat |
229 | 229 |
230 (defun eshell-create-handles | 230 (defun eshell-create-handles |
231 (standard-output output-mode &optional standard-error error-mode) | 231 (standard-output output-mode &optional standard-error error-mode) |
232 "Create a new set of file handles for a command. | 232 "Create a new set of file handles for a command. |
233 The default location for standard output and standard error will go to | 233 The default location for standard output and standard error will go to |
234 STANDARD-OUTPUT and STANDARD-ERROR, respectively." | 234 STANDARD-OUTPUT and STANDARD-ERROR, respectively. |
235 OUTPUT-MODE and ERROR-MODE are either `overwrite', `append' or `insert'; | |
236 a nil value of mode defaults to `insert'." | |
235 (let ((handles (make-vector eshell-number-of-handles nil)) | 237 (let ((handles (make-vector eshell-number-of-handles nil)) |
236 (output-target (eshell-get-target standard-output output-mode)) | 238 (output-target (eshell-get-target standard-output output-mode)) |
237 (error-target (eshell-get-target standard-error error-mode))) | 239 (error-target (eshell-get-target standard-error error-mode))) |
238 (aset handles eshell-output-handle (cons output-target 1)) | 240 (aset handles eshell-output-handle (cons output-target 1)) |
239 (if standard-error | 241 (if standard-error |
270 (or status (set-buffer-modified-p nil)) | 272 (or status (set-buffer-modified-p nil)) |
271 (kill-buffer buf))))))) | 273 (kill-buffer buf))))))) |
272 | 274 |
273 ;; If we're redirecting to a process (via a pipe, or process | 275 ;; If we're redirecting to a process (via a pipe, or process |
274 ;; redirection), send it EOF so that it knows we're finished. | 276 ;; redirection), send it EOF so that it knows we're finished. |
275 ((processp target) | 277 ((eshell-processp target) |
276 (if (eq (process-status target) 'run) | 278 (if (eq (process-status target) 'run) |
277 (process-send-eof target))) | 279 (process-send-eof target))) |
278 | 280 |
279 ;; A plain function redirection needs no additional arguments | 281 ;; A plain function redirection needs no additional arguments |
280 ;; passed. | 282 ;; passed. |
324 (let ((x-select-enable-clipboard t)) | 326 (let ((x-select-enable-clipboard t)) |
325 (kill-append string nil)))) | 327 (kill-append string nil)))) |
326 | 328 |
327 (defun eshell-get-target (target &optional mode) | 329 (defun eshell-get-target (target &optional mode) |
328 "Convert TARGET, which is a raw argument, into a valid output target. | 330 "Convert TARGET, which is a raw argument, into a valid output target. |
329 MODE is either `overwrite', `append' or `insert'." | 331 MODE is either `overwrite', `append' or `insert'; if it is omitted or nil, |
332 it defaults to `insert'." | |
330 (setq mode (or mode 'insert)) | 333 (setq mode (or mode 'insert)) |
331 (cond | 334 (cond |
332 ((stringp target) | 335 ((stringp target) |
333 (let ((redir (assoc target eshell-virtual-targets))) | 336 (let ((redir (assoc target eshell-virtual-targets))) |
334 (if redir | 337 (if redir |
365 nil) | 368 nil) |
366 ((symbolp target) | 369 ((symbolp target) |
367 (if (eq mode 'overwrite) | 370 (if (eq mode 'overwrite) |
368 (set target nil)) | 371 (set target nil)) |
369 target) | 372 target) |
370 ((or (processp target) | 373 ((or (eshell-processp target) |
371 (markerp target)) | 374 (markerp target)) |
372 target) | 375 target) |
373 (t | 376 (t |
374 (error "Illegal redirection target: %s" | 377 (error "Illegal redirection target: %s" |
375 (eshell-stringify target))))) | 378 (eshell-stringify target))))) |
392 (let ((where (eshell-get-target target mode)) | 395 (let ((where (eshell-get-target target mode)) |
393 (current (car (aref eshell-current-handles index)))) | 396 (current (car (aref eshell-current-handles index)))) |
394 (if (and (listp current) | 397 (if (and (listp current) |
395 (not (member where current))) | 398 (not (member where current))) |
396 (setq current (append current (list where))) | 399 (setq current (append current (list where))) |
397 (setq current (list where))) | 400 (setq current where)) |
398 (if (not (aref eshell-current-handles index)) | 401 (if (not (aref eshell-current-handles index)) |
399 (aset eshell-current-handles index (cons nil 1))) | 402 (aset eshell-current-handles index (cons nil 1))) |
400 (setcar (aref eshell-current-handles index) current))))) | 403 (setcar (aref eshell-current-handles index) current))))) |
401 | 404 |
402 (defun eshell-interactive-output-p () | 405 (defun eshell-interactive-output-p () |
436 (setq eshell-print-queue | 439 (setq eshell-print-queue |
437 (concat eshell-print-queue (apply 'concat strings)) | 440 (concat eshell-print-queue (apply 'concat strings)) |
438 eshell-print-queue-count (1+ eshell-print-queue-count)))) | 441 eshell-print-queue-count (1+ eshell-print-queue-count)))) |
439 | 442 |
440 (defsubst eshell-print (object) | 443 (defsubst eshell-print (object) |
441 "Output OBJECT to the error handle." | 444 "Output OBJECT to the standard output handle." |
442 (eshell-output-object object eshell-output-handle)) | 445 (eshell-output-object object eshell-output-handle)) |
443 | 446 |
444 (defsubst eshell-error (object) | 447 (defsubst eshell-error (object) |
445 "Output OBJECT to the error handle." | 448 "Output OBJECT to the standard error handle." |
446 (eshell-output-object object eshell-error-handle)) | 449 (eshell-output-object object eshell-error-handle)) |
447 | 450 |
448 (defsubst eshell-errorn (object) | 451 (defsubst eshell-errorn (object) |
449 "Output OBJECT to the error handle." | 452 "Output OBJECT followed by a newline to the standard error handle." |
450 (eshell-error object) | 453 (eshell-error object) |
451 (eshell-error "\n")) | 454 (eshell-error "\n")) |
452 | 455 |
453 (defsubst eshell-printn (object) | 456 (defsubst eshell-printn (object) |
454 "Output OBJECT to the error handle." | 457 "Output OBJECT followed by a newline to the standard output handle." |
455 (eshell-print object) | 458 (eshell-print object) |
456 (eshell-print "\n")) | 459 (eshell-print "\n")) |
457 | 460 |
458 (defun eshell-output-object-to-target (object target) | 461 (defun eshell-output-object-to-target (object target) |
459 "Insert OBJECT into TARGET. | 462 "Insert OBJECT into TARGET. |
483 (insert-and-inherit object) | 486 (insert-and-inherit object) |
484 (set-marker target (point-marker))) | 487 (set-marker target (point-marker))) |
485 (if moving | 488 (if moving |
486 (goto-char target)))))) | 489 (goto-char target)))))) |
487 | 490 |
488 ((processp target) | 491 ((eshell-processp target) |
489 (when (eq (process-status target) 'run) | 492 (when (eq (process-status target) 'run) |
490 (setq object (eshell-stringify object)) | 493 (setq object (eshell-stringify object)) |
491 (process-send-string target object))) | 494 (process-send-string target object))) |
492 | 495 |
493 ((consp target) | 496 ((consp target) |