On Jul 9, 7:22 am, "Edward K. Ream" <[email protected]> wrote:

> >  Does your fix affect round-tripping capability?
>
> It might.  This is just one instance of what I call the 'cursed
> newline problem'.
>
> I'll rethink the logic so as to preserve the "spellings" of newlines:
> as you imply, stripping '\r' characters is not a good idea.

Upon further review, I believe the present code is good.  As always,
newline issues are tricky...

1. There will be no problem as long as the user does not change the
file imported by @auto.  The "perfect import" tests explicitly ignore
'\r' characters.

2. The question arises, "what should Leo do when the user *does*
change the external file?"

At present, Leo (that is, the @auto write logic) regularizes the
trailing newline by calling self.os(self.output_newline). This writes
to at.output_newline which is a *binary* file.  Thus, whatever the
output newline string is, it *will* be written unchanged.

The @string output_newline option (in leoSettings.leo or
myLeoSettings.leo, or the .leo file being loaded) controls this code.
The comment in the body of the @string setting is:

QQQ
nl or lf: (recommended) All lines end with "\n"
cr:       All lines end with "\r"
crlf:     All lines end with "\r\n"
platform: Lines end in platform-specific way.

With platform Leo opens output files in "w" mode rather than "wb" mode
and writes '\n'
[ EKR: this comment is no longer correct.  Leo *always* uses "wb"
mode, but writes os.linesep when platform mode is in effect. ]

Please specify nl when uploading files to Leo's CVS site.
QQQ

One of these settings should suffice for you.

The alternatives to regularizing line endings would be bad.  It would
be horrid internally, and quite pointless, to remember the spelling of
the endings of individual lines.  Either the lines all match the lines
generated by one of the @string output_newline option, or they don't.
If they don't, I fail to see how Leo should choose the line endings of
newly-inserted lines.  The last thing we want is to do AI to choose
the least-bad line ending.

In short, there is no good alternative to having Leo regularize
newlines in *all* files, including @auto files.  Thus, as long as the
importers don't crash, the output should be about as good as can
reasonably expected.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to