PR #4324 rewrites the code that handles Leo's directives. Imo, revising this code was essential. The new code has a simpler interface and is easier to understand. Work has gone well, aided by all of Python's code-checking tools.
This post highlights potential breaking changes that may arise from the PR. These changes:
- Arise from edge cases involving the subtle details about how Leo handles directives.
- Might cause Leo to write external files differently when next you write them.
The next section describes how to make your outlines immune from these effects.
Make all your @<file> nodes self-contained
We say that an @<file> node is self-contained if the write the contents of the external file will remain unchanged if you move the @<file> node within your outline. The following two guidelines will ensure that Leo will not change your external files unexpectedly:
- All @<file> nodes should contain exactly one @language directive.
- @comment, @delims, @encoding, @pagewidth and @tabwidth directives should only appear only in @<file> nodes.
Compatibility
I have taken care not to change Leo's operation unnecessarily. However, recent work has revealed unexpected edge cases in how Leo handles various directives. Some of these edge cases could be improved.
The code involved is complex. There are ample opportunities for mistakes in the PR. I may be mistaken about what the old code did. I may be mistaken about what the new could should do. Happily, the new code will be much easier to revise if I have made mistakes.
I think the changes are necessary. They are the precondition for handling issue #4323. It's not correct to think only of compatibility. That's looking only to the past. We must also look to the future. I'd like to ease the work of future maintainers and to help others to improve Leo.
Summary
There are ample opportunities for mistakes in the PR. There should be an extended period of testing. Some people may feel (temporary!) pain. However, the PR will benefit us all in the long run.
You can guard against problems by making all your @<file> nodes self-contained:
- Every @<file> node should contain exactly one @language directive.
- Don't put @comment, @delims, @encoding, @pagewidth and @tabwidth directives outside @<file> nodes.
All of your questions and comments are welcome.
Edward
- @comment, @delims, @encoding, @pagewidth and @tabwidth directives should only appear only in @<file> nodes.
- @comment, @delims, @encoding, @pagewidth and @tabwidth directives should only appear only in @<file> nodes.
I strongly object to this one. I write files all the time that use @c and @pagewidth directives even though they are not @files.
I rewrote by cutting and pasting code from the old framework to the new. I intended to change nothing about how the new code actually works. Changes might come later, in one or more much smaller PRs.
On Apr 6, 2025, at 8:51 AM, Thomas Passin <tbp1...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/leo-editor/0ec3c4d7-f83d-435a-af3f-d920c4a222d4n%40googlegroups.com.
On Sun, Apr 6, 2025 at 7:51 AM Thomas Passin wrote:- @comment, @delims, @encoding, @pagewidth and @tabwidth directives should only appear only in @<file> nodes.
I strongly object to this one. I write files all the time that use @c and @pagewidth directives even though they are not @files.Good point. What do you think of the following amendments?
- An @encoding directive needs to appear in an @<file> node only if the encoding in the directivedoesn't match the encoding in the @string default-file-encoding setting.
I also have an objection, albeit a minor one — I use @tabwidth all over the place — and most of my Leo work doesn’t have any external files at all.