From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#33403: [Geiser-users] bug#33403: Data length limit in Guile/Geiser/Scheme evaluation Date: Sat, 17 Nov 2018 02:09:54 -0500 Message-ID: <87zhu8w55u.fsf__17787.7701855779$1542438545$gmane$org@netris.org> References: <87sh021kw2.fsf@ossau.homelinux.net> <878t1ugyf9.fsf@nicolasgoaziou.fr> <87h8gi1g5g.fsf@ossau.homelinux.net> <871s7mz357.fsf@imladris> <87bm6q1c33.fsf@ossau.homelinux.net> <87o9aq55tl.fsf@ossau.homelinux.net> <87d0r5349t.fsf@netris.org> <87y39t1olc.fsf@netris.org> <878t1t1ety.fsf@ossau.homelinux.net> <875zwx1dcn.fsf@ossau.homelinux.net> <87va4wwra7.fsf@imladris> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1542438545 23035 195.159.176.226 (17 Nov 2018 07:09:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Nov 2018 07:09:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: geiser-users@nongnu.org, Neil Jerram , emacs-orgmode@gnu.org, 33403@debbugs.gnu.org To: "Jose A. Ortega Ruiz" Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Nov 17 08:09:01 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNuiz-0005tO-1T for guile-bugs@m.gmane.org; Sat, 17 Nov 2018 08:09:01 +0100 Original-Received: from localhost ([::1]:48233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNul5-000188-EH for guile-bugs@m.gmane.org; Sat, 17 Nov 2018 02:11:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNul0-000183-I1 for bug-guile@gnu.org; Sat, 17 Nov 2018 02:11:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNukw-0006ud-Jj for bug-guile@gnu.org; Sat, 17 Nov 2018 02:11:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52765) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNukw-0006uV-GW for bug-guile@gnu.org; Sat, 17 Nov 2018 02:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gNukw-0004tm-8o for bug-guile@gnu.org; Sat, 17 Nov 2018 02:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 17 Nov 2018 07:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33403 X-GNU-PR-Package: guile X-GNU-PR-Keywords: notabug Original-Received: via spool by 33403-submit@debbugs.gnu.org id=B33403.154243864718808 (code B ref 33403); Sat, 17 Nov 2018 07:11:02 +0000 Original-Received: (at 33403) by debbugs.gnu.org; 17 Nov 2018 07:10:47 +0000 Original-Received: from localhost ([127.0.0.1]:57023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNukh-0004tI-75 for submit@debbugs.gnu.org; Sat, 17 Nov 2018 02:10:47 -0500 Original-Received: from world.peace.net ([64.112.178.59]:34376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNukd-0004t4-Tt for 33403@debbugs.gnu.org; Sat, 17 Nov 2018 02:10:44 -0500 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gNukX-0002rC-7C; Sat, 17 Nov 2018 02:10:37 -0500 In-Reply-To: <87va4wwra7.fsf@imladris> (Jose A. Ortega Ruiz's message of "Fri, 16 Nov 2018 23:12:32 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9275 Archived-At: Hello all, "Jose A. Ortega Ruiz" writes: > On Fri, Nov 16 2018, Neil Jerram wrote: > >> Neil Jerram writes: >> >>> Mark H Weaver writes: >>> >>>> This is a documented limitation in Linux's terminal handling when in >>>> canonical mode. See the termios(3) man page, which includes this text: >>>> >>>> Canonical and noncanonical mode >>>> >>>> The setting of the ICANON canon flag in c_lflag determines >>>> whether the terminal is operating in canonical mode (ICANON set) >>>> or noncanonical mode (ICANON unset). By default, ICANON is set. >>> [...] >>>> * The maximum line length is 4096 chars (including the >>>> terminating newline character); lines longer than 4096 chars >>>> are truncated. After 4095 characters, input processing (e.g., >>>> ISIG and ECHO* processing) continues, but any input data after >>>> 4095 characters up to (but not including) any terminating >>>> newline is discarded. This ensures that the terminal can >>>> always receive more input until at least one line can be read. >>>> >>>> Note that last item above. >>> >>> Awesome; thank you Mark. >>> >>> So possibly this limit can be removed, in my Org/Geiser context, by >>> evaluating (system* "stty" "-icanon") when initializing the Geiser-Guile >>> connection. I'll try that. Will the terminal that that 'stty' sees be >>> the same as Guile's stdin? >>> >>> Jao, if that works, I wonder if it should be the default for Geiser? It >>> appears to me that Geiser shouldn't ever need the features of canonical >>> mode. Is that right? >>> >>> Anyway, I'll see first if the stty call is effective. >> >> Yes, with this in my ~/.guile-geiser - >> >> (system* "stty" "-icanon") >> >> - I can do evaluations past the 4K line length limit, and the Org-driven >> problem that I first reported [1] has disappeared. > > Ah, system* is a scheme call! So yeah, maybe we could add that call to > Geiser's guile initialization... i don't really see how that would cause > any problem elsewhere. I think something like this should be done, not only in the Guile initialization, but ideally in the generic Geiser code that connects to inferior processes via pseudo-tty. After the pseudo-tty is allocated but before launching the inferior Scheme process, something like "stty --file=/dev/pts/N -icanon" should be run. However, before doing this, some warnings are in order: When in noncanonical mode, the normal processing of ERASE (usually DEL or Ctrl-H) and KILL (usually Ctrl-U) characters are disabled, and input characters are delivered to the subprocess immediately as they are typed, rather than waiting for the newline as normally happens in canonical mode. At least in the case of the Guile REPL, one notable side effect of running in noncanonical mode is that when a list is entered at the REPL, the 'read' returns as soon as the final close parenthesis is entered. Nothing after that is read, not even the usual newline. The final newline is only read if the reader is not yet sure that it has finished reading the token, e.g. if a number or symbol is entered. In those cases, typically any delimiter may be typed to terminate the read, e.g. space. To see this, you can try running Guile from a traditional terminal program (e.g. xterm or GNOME Terminal), and type: (system* "stty" "-icanon") and then: (display "hello") You will see that as soon as you type that close paren, "hello" is immediately printed, followed by another REPL prompt, all on the same line. You might also try (use-modules (ice-9 rdelim)) and then: (read-line) and you'll see that the newline you type at the end of that line is read by 'read-line', which then immediately returns the empty string. The input that you wish for 'read-line' to see must be typed on the same line, immediately after the close parenthesis. So, it might be that Geiser needs to be adjusted somewhat to deal with these differences. Finally, you might consider the possibility that 'stty' might not be available in PATH, or fails for some reason, and ideally this case should be handled as well. It might be simpler to always use REPL servers over a socket, than to deal with these headaches, although I don't know if that will be an option for the other Scheme implementations. Regards, Mark