* workaround for spurious EOF on stdin when operating as subprocess of emacs
@ 2007-04-27 19:19 Thien-Thi Nguyen
0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2007-04-27 19:19 UTC (permalink / raw)
To: guile-sources; +Cc: guile-user
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)))))))
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-27 19:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-27 19:19 workaround for spurious EOF on stdin when operating as subprocess of emacs Thien-Thi Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).