[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
workaround for spurious EOF on stdin when operating as subprocess of ema
From: |
Thien-Thi Nguyen |
Subject: |
workaround for spurious EOF on stdin when operating as subprocess of emacs |
Date: |
Fri, 27 Apr 2007 21:19:30 +0200 |
greetings,
below is a `(read-line port)' replacement that works around a bug in the
way the emacs lisp function `process-send-string' works. the gist is
that emacs will send EOF after every 500 bytes or so, which means that
something like:
(process-send-string PROC (make-string 512 ?A))
from emacs tends to show up (in guile) as #\A 508 times followed by EOF
followed by #\A four times. this is generally undesirable.
note that this doesn't replace `read-line' per se, but the construct
`(read-line port)', which returns a string or EOF.
long-term, a better fix would involve examining the need for:
/* If we sent just part of the string, put in an EOF
to force it through, before we send the rest. */
if (len > 0)
Fprocess_send_eof (proc);
in emacs/src/process.c (line 5664 in cvs revision 1.512) and change
emacs to flush via some out-of-band mechanism instead of via EOF.
thi
__________________________________________________________
(use-modules ((ice-9 rdelim) #:select (read-line)))
(define (get-line port)
(define (next)
(read-line port 'split))
(let ((so-far ""))
(let loop ((pair (next)))
(let ((s (car pair))
(d (cdr pair)))
(cond ((and (eof-object? d)
(or (eof-object? s)
(and (string-null? s)
(string-null? so-far))))
d)
((and (eof-object? d)
(string-null? s))
so-far)
((eof-object? d)
(set! so-far (string-append so-far s))
(loop (next)))
(else
(string-append so-far s)))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- workaround for spurious EOF on stdin when operating as subprocess of emacs,
Thien-Thi Nguyen <=