From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.user Subject: Re: Syntax locations are ambiguous: can we track source 'offset' and 'length'? Date: Wed, 04 Aug 2021 15:41:50 +0200 Message-ID: <87pmutpbs1.fsf@gnu.org> References: <771a6e88782e288143be269b14751b761523e4c1.camel@planete-kraus.eu> <87v94lpg7s.fsf@gnu.org> <871r799z1y.fsf@planete-kraus.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29916"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: guile-user@gnu.org To: Vivien Kraus Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 04 15:42:28 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBHAC-0007br-5l for guile-user@m.gmane-mx.org; Wed, 04 Aug 2021 15:42:28 +0200 Original-Received: from localhost ([::1]:33234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBHAA-0007yN-UJ for guile-user@m.gmane-mx.org; Wed, 04 Aug 2021 09:42:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBH9d-0007y9-U6 for guile-user@gnu.org; Wed, 04 Aug 2021 09:41:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:59632) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBH9d-0004gq-50; Wed, 04 Aug 2021 09:41:53 -0400 Original-Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=43030 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBH9c-0004JE-SS; Wed, 04 Aug 2021 09:41:53 -0400 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 17 Thermidor an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <871r799z1y.fsf@planete-kraus.eu> (Vivien Kraus's message of "Wed, 04 Aug 2021 14:25:45 +0200") X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17671 Archived-At: Hi, Vivien Kraus skribis: > Ludovic Court=C3=A8s writes: >>> I am trying to use the guile reader to read scheme comments, in >>> addition to the syntax elements. I know with syntax-source where a >>> syntax object starts, and I can know where it ends by using a spying >>> soft port and re-reading it. However, the #\return ambiguity makes all >>> my efforts pointless. >> >> As you know, =E2=80=98read-syntax=E2=80=99 appeared in 3.0.7, so it=E2= =80=99s brand new and we >> could certainly extend (ice-9 read) with more features, including >> reading comments. > I did not know that, to be honest. > >> In the meantime, I needed the ability to read comments in Guix, >> including with Guile < 3.0.7, so I hacked up this thing: >> >> https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/style.scm= ?h=3Dcore-updates&id=3D8419221620191d2988c22f6e7811d9ce1e0837bf#n50 >> >> It can read and write while preserving comments. > I was tempted not to use the guile reader and go and implement a new > reader like you did, but I was too afraid to miss one important thing in > the syntax. This hack is layered on top of the real =E2=80=98read=E2=80=99, so it canno= t miss things. > I=E2=80=99m happy to see this pretty-print-with-comments function. I want= guile > to have a tool that can automatically reformat scheme code, to avoid > indentation problems with code reviews and pointless discussions about > style. We could even tweak text editors to convert between different > styles for viewing the source and for git commits. I=E2=80=99m sure wisp = people > would like it. I hope to see "guix style" one day :) It *is* =E2=80=98guix style=E2=80=99. :-) Currently the command is focusing on one very specific style issue, but we could certainly expand it for more general formatting. Ludo=E2=80=99.