[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax locations are ambiguous: can we track source 'offset' and 'le
Re: Syntax locations are ambiguous: can we track source 'offset' and 'length'?
Wed, 04 Aug 2021 15:41:50 +0200
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Vivien Kraus <email@example.com> 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:
>> 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
> 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.