#| -*-Scheme-*-
-$Id: edwin.pkg,v 1.214 1997/11/04 11:04:52 cph Exp $
+$Id: edwin.pkg,v 1.215 1997/11/20 05:27:37 cph Exp $
Copyright (c) 1989-97 Massachusetts Institute of Technology
(parent (edwin))
(export (edwin)
accept-process-output
+ add-process-filter
buffer-default-directory
buffer-processes ; always present
continue-process
process-status-changes? ; always present
process-status-message
quit-process
+ remove-process-filter
+ run-synchronous-process
set-process-buffer!
set-process-filter!
set-process-kill-without-query!
set-process-sentinel!
shell-command
+ standard-process-filter
start-process
stop-process
subprocesses-available? ; always present
- run-synchronous-process))
+ ))
\f
(os-type-case
((dos)
;;; -*-Scheme-*-
;;;
-;;; $Id: process.scm,v 1.52 1997/11/19 23:40:59 cph Exp $
+;;; $Id: process.scm,v 1.53 1997/11/20 05:27:30 cph Exp $
;;;
;;; Copyright (c) 1991-97 Massachusetts Institute of Technology
;;;
(message-with-reason "exited abnormally" "with code")))
((SIGNAL) (message-with-reason "terminated by signal" false))
(else (error "illegal process status" status)))))
-
+\f
(define (output-substring process string length)
(cond ((process-filter process)
=>
(set-mark-index! mark (+ index length)))
true))
(else false)))
+
+(define (add-process-filter process filter)
+ (let ((filter* (process-filter process)))
+ (if (filter-dispatcher? filter*)
+ (add-filter-to-dispatcher filter* filter)
+ (set-process-filter! process
+ (make-filter-dispatcher (if filter*
+ (list filter* filter)
+ (list filter)))))))
+
+(define (remove-process-filter process filter)
+ (set-process-filter!
+ process
+ (let ((filter* (process-filter process)))
+ (cond ((eq? filter filter*) #f)
+ ((filter-dispatcher? filter*)
+ (remove-filter-from-dispatcher filter* filter))
+ (else filter*)))))
+
+(define (make-filter-dispatcher filters)
+ (make-entity filter-dispatcher-procedure filters))
+
+(define (filter-dispatcher? object)
+ (and (entity? object)
+ (eq? filter-dispatcher-procedure (entity-procedure object))))
+
+(define (filter-dispatcher-procedure dispatcher process string start end)
+ (let loop ((filters (entity-extra dispatcher)))
+ (and (not (null? filters))
+ (or ((car filters) process string start end)
+ (loop (cdr filters))))))
+
+(define (add-filter-to-dispatcher dispatcher filter)
+ (let ((filters (entity-extra dispatcher)))
+ (if (pair? filters)
+ (set-cdr! (last-pair filters) (list filter))
+ (set-entity-extra! dispatcher (list filter)))))
+
+(define (remove-filter-from-dispatcher dispatcher filter)
+ (let ((filters (delq! filter (entity-extra dispatcher))))
+ (set-entity-extra! dispatcher filters)
+ (and (not (null? filters))
+ dispatcher)))
+
+(define (standard-process-filter filter)
+ (lambda (process string start end)
+ (let ((mark (process-mark process)))
+ (and mark
+ (begin
+ (filter mark string start end)
+ #t)))))
\f
;;;; Signals
#| -*-Scheme-*-
-$Id: telnet.scm,v 1.11 1997/11/19 23:40:53 cph Exp $
+$Id: telnet.scm,v 1.12 1997/11/20 05:27:45 cph Exp $
Copyright (c) 1991-97 Massachusetts Institute of Technology
(make-comint mode buffer-name "telnet" host)))))
(let ((process (get-buffer-process buffer)))
(if process
- (set-process-filter! process
- (make-telnet-filter process))))
+ (add-process-filter process
+ (standard-process-filter telnet-filter))))
(select-buffer buffer))))
(define-command telnet-send-input
((> argument 1)
(process-send-string process (make-string argument char)))))))
\f
-(define (telnet-filter process string start end)
- (let ((mark (process-mark process)))
- (and mark
- (let ((index (mark-index mark))
- (new-string (telnet-filter-substring string start end)))
- (let ((new-length (string-length new-string)))
- (group-insert-substring! (mark-group mark) index
- new-string 0 new-length)
- (set-mark-index! mark (+ index new-length))
- #t)))))
+(define (telnet-filter mark string start end)
+ (let ((index (mark-index mark))
+ (new-string (telnet-filter-substring string start end)))
+ (let ((new-length (string-length new-string)))
+ (group-insert-substring! (mark-group mark) index new-string 0 new-length)
+ (set-mark-index! mark (+ index new-length)))))
(define (telnet-filter-substring string start end)
(substring-substitute string start end