Rev f86046893 adds two important commands: reload-settings and 
reload-all-settings.  The first reloads settings in the present outline, 
the second reloads settings in all tabs.

This completes #340, Enhancement: reload-abbreviations 
<https://github.com/leo-editor/leo-editor/issues/340>. Please report any 
problems immediately.

*Note:* These commands work completely *only *for abbreviations. These 
commands will be extended to other important settings soon.  See the Post 
Script for details.

Edward

P.S. This is an Engineering Notebook entry.  Feel free to ignore.

These commands *do* truly go through the complete process of reloading all 
settings, but at present the commands to not change any *saved settings 
ivars* in subcommanders. These ivars are set during startup, usually in the 
ctor or in finishCreate. There are roughly 30 classes that save setting in 
ivars. I'm not sure whether syntax coloring and stylesheet settings are 
saved.  I suspect they are, so they are *not* updated by the 
reload-settings command.

*Note*: Terry created a style-reload command that works independently of 
the reload-settings command.  But it will be easy to fold this into the 
reload-settings command, just by adding one easy method, as described next.

The new code sets up a *simple* framework for updating all such stored 
settings ivars.  If a subcommander has a *reload settings method*, the 
reload-settings commands will call that method. The *name* of the reload 
settings method will be either *reloadSettings *or *reload_settings*, 
depending on whether the subcommander uses camelCase or not. Each 
subcommander that saves settings and wants to support reload-settings will 
define a reload settings method. Typically, either the ctor or the 
finishCreate method will call it.

This is a super-simple broadcast/listener pattern, much better than other 
schemes I have considered. And it can easily be be used in other contexts 
because the c object now defines *c.subCommanders*, a list of all of c's 
subcommander instances.

In short, this is the simplest (and most general) thing that could possibly 
work.  Here the code that calls the reload methods:

    def reloadSubcommanderSettings(self):
        '''
        Reload settings in all subcommanders that have either a
        reload_settings or reloadSettings method.
        '''
        c = self
        for subcommander in c.subCommanders:
            for ivar in ('reloadSettings', 'reload_settings'):
                func = getattr(subcommander, ivar, None)
                if func:
                    func()

A cff reveals that there are about 35 methods containing code that matches 
the regex equivalent of "self.whatever = c.config.get*"  All containing 
classes are candidates for one of the reload settings methods.  However, it 
will suffice to do the most important ones first.

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.

Reply via email to