On Jan 11, 3:43 pm, "Edward K. Ream" <[email protected]> wrote:

> When I awoke this morning I saw the way forward.  Rather than
> remembering a single path for each @<file> node, Leo should remember
> *all* paths for each (possibly cloned) @<file> node.

Done at rev 4925.  What I did:

- Added rememberReadPath.

- Changed shouldPromptForDangerousWrite so that it suppresses warnings
if the given file name appears in a list of remembered file names.

- All expected unit tests pass (one unrelated failure), which is a
good, but not perfect, test.

**Important**: The new code resolves the "policy questions" mentioned
in previous posts in the simplest possible way: it issues a warning
only if the path specified by an @<file> node (and its ancestors,
including possibly @path nodes) appears nowhere in the list of
remembered paths.  Here is the code::

    def shouldPromptForDangerousWrite(self,fn,p):

        if not g.os_path_exists(fn):
            return False
                # No danger of overwriting fn.
        elif hasattr(p.v,'at_read'):
            return fn not in p.v.at_read
                # The path is new.
        else:
            return True
                # The file was never read.

This code will not catch all pathological cases, such as changing an
@path node so that a descendant @file node now refers to the same
path  as a previous clone, thereby not updating an external file that
was previously updated.  But it would be impossible to guess what the
user meant in such cases, and difficult to issue meaning warnings for
cases that will likely never happen.

In short, this simple code is probably the best that can be done.
Don't ask Leo to catch every possible mistake you could possibly
make :-)

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