On Tue, 14 May 2013 12:43:59 -0700 (PDT)
SegundoBob <[email protected]> wrote:

> I have a Leo-Editor script that pops up a window to interact with the
> user and when the user is happy with his changes, my script closes the
> pop-up window and sets the headline of the currently selected node.
> Note that the user may change one or more nodes in this way and move
> around in the Leo-Editor file for quite some time before closing the
> Leo-Editor file.  Unfortunately, when a script changes a headline, Leo-
> Editor does NOT set the file dirty flag.  This is a serious problem
> for my script because the user could easily lose changes he has made.

If the issue is not becoming dirty for changes made to headlines *by
your script*, then I'd say this:

 - the ' ' append trick shouldn't be needed, your script should
   set the node and outline dirty explicitly with the relevant methods,
   p.v.setDirty(), c.setChanged(True), etc. not sure exactly.

 - there are use cases for scripts setting the dirty flags explicitly,
   and use cases for scripts changing the outline without making it
   dirty.  You use case is the former, the latter is when you're
   constructing views of data that don't need to be saved.

 - at first glance your use case would seem more common and the views
   use case less common, arguing for automatic dirtying in response to
   scripted changes and the views use case needing to explicitly
   undirty the outline

 - *but* it's relatively simple to explicitly dirty the nodes /
   outline, whereas explicitly undirtying them is tricky, because it
   matters whether they were dirty or not before the script started
   changing things, so I would argue that the status quo is cleanest
   for the broadest range of cases.  Scripts usually need to
   explicitly call c.redraw() and other things too, so this
   requirement isn't unique. 

I'm guessing you hadn't seen the p.v.setDirty(), c.setChanged(True)
etc. methods?

Cheers -Terry

> If you are interested in this problem, I give much more detail here:
> 
> https://bugs.launchpad.net/leo-editor/+bug/1174915
> 
> 
> So far the best work around I have come up with is:
> 
>         # Workaround bug: Leo doesn't notice headline change.
>         self._p.b = self._p.b + ' '
>         self._p.b = self._p.b[:-1]
> 
> That is, append a blank to the body of the changed node then drop the
> appended blank.  These two steps are required because simply setting
> the body to itself unchanged does NOT set the file dirty flag.
> 
> Edward requested that discussion of this problem be continued on this
> forum hoping that more people will state their views.
> 
> My view is that a user expects (and should expect) Leo-Editor to
> notice that a headline has been changed.  The file dirty flag should
> be set.  As it is in this case, Leo-Editor is a very quirky, scripting-
> unfriendly application.
> 

-- 
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 http://groups.google.com/group/leo-editor?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to