​​
​​
​​
On Thu, Feb 12, 2015 at 3:47 PM, Kent Tenney <kten...@gmail.com> wrote:

> > Perhaps the proper @auto importer could be used
>
> if that would mean a new @nosent <file> got brought in
> with the simple elegance of @auto:
> +1
>
> I'm not fond of menu->import file->browse->click
> ... file appearing parented by
> ​​
> an 'imported files' node
>

​Thanks for raising these issues.  When I awoke this morning I realized
that they are subtle, though perhaps not as important as you think.

Indeed, automagically doing an @auto import is a "recovery" case.  In most
cases, the user would naturally populate the @nosent node *before* saving
the .leo file. One typically wants to see the @nosent file immediately.

There are three ways to create or populate an @nosent node, creating a tree
of nodes in the process:

1. refresh-from-disk.

2.  import-file. As you say, the import-file command should *not* create an
"imported files" node if only one file is being imported.  I've made a note
of this.

3. Use a recursive import script to create and populate *many* @nosent
nodes. I personally create all my @nosent (formerly @file) nodes this way.

Note 1: Recursive import scripts use c.recursiveImport. At present,
c.recursiveImport doesn't handle @nosent properly.  I'll fix this asap.

Note 2: When importing multiple files, it *is* reasonable to have all
imported nodes be children of a parent "imported nodes" node.  A single new
root node simplifies the undo logic and minimizes the amount of information
needed to undo the operation.

So the only remaining question is: what should happen if the user doesn't
populate an @nosent tree using either the refresh-from-disk or import-file?

If the user saves an empty @nosent node, Leo's "significant file" check
will prevent the user from inadvertently overwriting an existing file.
This logic warns if:

a) the file has never been written and
b) the external file exists and
c) the @nosent node does *not* contain a significant amount of text.

Or something like that ;-)  The details don't much matter here.  What does
matter is that the user is protected.

To repeat, the question is what should happen if the user has *not* already
populated the @nosent tree before exiting Leo.

At present Leo just slurps the entire file into the @nosent node, just as
if it were an @edit node.

Alternatively Leo could do the full @auto logic. It should be clean. There
is already a special case that bypasses the @shadow logic if the @nosent
node is empty.  This special case could call the appropriate importer
instead of setting p.b to the entire contents of the node.

But there are two niggling downsides to automatic imports:

1. It is not always clear which importer to use.  That's why we have
@auto-rst, @auto-vo, @auto-otl.  I shall be *so* happy when these wretched
hacks sail off into the sunset.  Otoh, we shall soon need the corresponding
flavors of the import-file command.  But these new commands will only tell
Leo how to create the outline the *first* time.  Thereafter, unlike @auto,
the user is in complete charge of outline organization.

2. If the @nosent node is empty, the user might prefer everything to be
placed into the @nosent node.  There are two commands that populate an
@nosent node with a tree. If the user hasn't done either, why assume the
user wants a tree?

===== Summary

Automatically using import logic to populate an empty @nosent node can be
done cleanly.  However, it does have drawbacks, and it will rarely be
necessary.  This discussion is interesting, but it's outcome isn't all that
important.

I'll be happy to hear your further comments.

Edward

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to