On Thursday, April 6, 2017 at 4:06:04 AM UTC-5, Edward K. Ream wrote:
> *To do: eliminate the atAuto switch*
> ...
> After the recent simplifications, the atAuto keyword arg to
> ic.createOutline can now be seen to have two quite different purposes:
>
> A. The atAuto keyword arg is passed to ic.setEncoding, which uses
> c.config.default_at_auto_file_encoding as a default.
>
> B. ic.init_import uses the atAuto and atShadow keyword args to create
> error messages. That's the *only* use for the atShadow keyword arg!
>
A big oops: There are two more *important *uses of atAuto in
ic.createOutline:
C. ic.createOutline passes this mystery arg to the importers (the computed
func).
The atAuto arg to the importers is a big "huh?". Let's see how it affects
the importers.
A cff reveals 26 uses of atAuto in the importer plugins. Happily, all but
one involving setting the atAuto ivar in the importer classes. Heh. *This
a prime example of infection*.
The only "real" use of the atAuto flag is in i.gen_ref. It contains this
code:
if self.is_rst and not self.atAuto:
return None
Again, this is a prime example of "huh?" The next step will be to see if
we can get rid of this flag. I sure hope so. If not, it may be possible to
get the effect in some clearer way.
D. If atAuto is True, ic.createOutline calls at.rememberReadPath. The
actual code is:
if atAuto:
# Fix bug 488894: unsettling dialog when saving Leo file
# Fix bug 889175: Remember the full fileName.
c.atFileCommands.rememberReadPath(fileName, p)
Clearly, this code can not be changed lightly. It will be important to
track down how *all* callers of ic.createOutline set the atAuto flag. I
*suspect* (hope) that unit tests don't need to set the atAuto switch, but I
wouldn't be much...
So the infection and mysteries deepen and continue. This only makes it more
worthwhile to clean the code as much as possible.
Edward
P. S. I have been stung recently by criticisms that Leo's code is too
complex. Sure, parts of it are too complex. But this thread shows the
dangers of naively trying to change things. It takes a lot of time and
care. Here, the time is well spent, but I am not likely to spend more than
one more day on this project.
EKR
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.