From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: guile-sources@gnu.org
Cc: guile-user@gnu.org
Subject: workaround for spurious EOF on stdin when operating as subprocess of emacs
Date: Fri, 27 Apr 2007 21:19:30 +0200 [thread overview]
Message-ID: <E1HhVyc-0003R4-3x@ambire.localdomain> (raw)
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
reply other threads:[~2007-04-27 19:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1HhVyc-0003R4-3x@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=guile-sources@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).