From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.sources Subject: workaround for spurious EOF on stdin when operating as subprocess of emacs Date: Fri, 27 Apr 2007 21:19:30 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1177701575 5390 80.91.229.12 (27 Apr 2007 19:19:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2007 19:19:35 +0000 (UTC) Cc: guile-user@gnu.org To: guile-sources@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Apr 27 21:19:34 2007 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HhVyf-0002de-Uy for guile-user@m.gmane.org; Fri, 27 Apr 2007 21:19:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhW4X-0004YZ-W9 for guile-user@m.gmane.org; Fri, 27 Apr 2007 15:25:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HhW4R-0004X2-8A for guile-user@gnu.org; Fri, 27 Apr 2007 15:25:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HhW4Q-0004WS-DX for guile-user@gnu.org; Fri, 27 Apr 2007 15:25:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhW4O-0004TS-6Z; Fri, 27 Apr 2007 15:25:28 -0400 Original-Received: from smtp-out2.libero.it ([212.52.84.42]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HhVyU-0004fd-IF; Fri, 27 Apr 2007 15:19:23 -0400 Original-Received: from localhost (172.31.0.47) by smtp-out2.libero.it (7.3.120) id 4611FD98018ADA96; Fri, 27 Apr 2007 21:19:21 +0200 X-Scanned: with antispam and antivirus automated system at libero.it Original-Received: from smtp-out3.libero.it ([172.31.0.39]) by localhost (asav-out6.libero.it [192.168.32.34]) (amavisd-new, port 10024) with ESMTP id Llean7LQ2DBv; Fri, 27 Apr 2007 21:19:21 +0200 (CEST) Original-Received: from ambire.localdomain (151.21.37.221) by smtp-out3.libero.it (7.3.120) id 4611FDB60233BBF1; Fri, 27 Apr 2007 21:19:21 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.50) id 1HhVyc-0003R4-3x; Fri, 27 Apr 2007 21:19:30 +0200 X-Draft-From: ("nnml:mail.emacs-devel" 1894) X-detected-kernel: Linux 2.4-2.6 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5935 gmane.lisp.guile.sources:275 Archived-At: 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