Daniel Hartwig <mand...@gmail.com> writes:

> On 31 March 2013 20:47, Nala Ginrut <nalagin...@gmail.com> wrote:
>> On Sat, 2013-03-30 at 17:17 -0400, Mark H Weaver wrote:
>>> Also, as we discussed on IRC, it would be better to show the original
>>> characters in the file instead of the sexp representation.  I want to
>>> see the comments.  I want to see the programmer-chosen indentation.  If
>>> they chose to use curly-infix for some expressions, I want to see that.
>>> More generally, I want to see the presentation that the programmer
>>> thought was most readable, i.e. the *source* code.
>>>
>>
>> For these purposes above, I think there should be a modified 'read' to
>> read the code from source file with comments.
>>
>
> There are other transformations that occur as Mark points out.  It is
> far better to just return the unmodified source from the file.  As
> discussed, the source file, column, line information gives you the
> start, and ‘read’ can be used to locate the end:
>
>  (let ((start (begin
>                 (skip-lines fp (source:line src))
>                 (seek fp (source:column src) SEEK_CUR)
>                 (ftell fp)))
>        (end (begin
>               (read fp)
>               (ftell fp))))
>    …
>
> these two points are enough information to obtain the unmodified
> source from the file.

This is enough to get the original characters, but then there's the
other problem I mentioned: reader directives such as #!curly-infix
earlier in the file.

For this reason, I think we need to use 'read' from the beginning of the
file, and look at the source properties of the returned datums to find
the right top-level datum.  In most cases, a top-level datum is what is
desired, but in some cases not.  In general, you will need to traverse
the sublists of a top-level datum to find the right one.

     Good luck!
        Mark

Reply via email to