>
>
> Instead initialization code should be kept free and clean of any gui 
> calls. Either writeFromString must not call gui methods like endEditing, 
> either reload_settings, init_env in abbrevCommands must not call 
> writeFromString.
>
> def writeFromString(self, root, s, forcePythonSentinels=True, useSentinels
=True):
    """
    Write a 4.x derived file from a string.

    This is at.write specialized for scripting.
    """
    at = self; c = at.c
    c.endEditing()
        # Capture the current headline, but don't change the focus!
    ... rest of method 

Clearly we should here have two methods:
def writeFromString(self, root, s, forcePythonSentinels=True, useSentinels=
True):
    """
    Write a 4.x derived file from a string.

    This is at.write specialized for scripting.
    """
    self.c.endEditing()
        # Capture the current headline, but don't change the focus!
    return self._writeFromString(root, forcePythonSentinels, useSentinels)

def _writeFromString(root, forcePythonSentinels, useSentinels):
    at = self; c = self.c
    ... rest of method


Then abbrevCommands could safely call at._writeFromString instead of high 
level gui method at.writeFromString.

This way lots of other code parts may be freed from guards that are not 
necessary.

Vitalije

-- 
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 https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to