From: "Ludovic Courtès" <ludo@gnu.org>
To: Vivien Kraus <vivien@planete-kraus.eu>
Cc: guile-user@gnu.org
Subject: Re: Syntax locations are ambiguous: can we track source 'offset' and 'length'?
Date: Wed, 04 Aug 2021 15:41:50 +0200 [thread overview]
Message-ID: <87pmutpbs1.fsf@gnu.org> (raw)
In-Reply-To: <871r799z1y.fsf@planete-kraus.eu> (Vivien Kraus's message of "Wed, 04 Aug 2021 14:25:45 +0200")
Hi,
Vivien Kraus <vivien@planete-kraus.eu> skribis:
> Ludovic Courtès 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, ‘read-syntax’ appeared in 3.0.7, so it’s 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=core-updates&id=8419221620191d2988c22f6e7811d9ce1e0837bf#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 ‘read’, so it cannot miss
things.
> I’m 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’m sure wisp people
> would like it. I hope to see "guix style" one day :)
It *is* ‘guix style’. :-)
Currently the command is focusing on one very specific style issue, but
we could certainly expand it for more general formatting.
Ludo’.
next prev parent reply other threads:[~2021-08-04 13:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 22:50 Syntax locations are ambiguous: can we track source 'offset' and 'length'? Vivien Kraus via General Guile related discussions
2021-08-03 19:29 ` Linus Björnstam
2021-08-03 23:51 ` Vivien Kraus via General Guile related discussions
2021-08-04 1:20 ` Keith Wright
2021-08-04 10:01 ` Vivien Kraus via General Guile related discussions
2021-08-04 12:05 ` Ludovic Courtès
2021-08-04 12:25 ` Vivien Kraus via General Guile related discussions
2021-08-04 13:41 ` Ludovic Courtès [this message]
2021-08-04 14:09 ` Vivien Kraus via General Guile related discussions
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=87pmutpbs1.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-user@gnu.org \
--cc=vivien@planete-kraus.eu \
/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).