On Wed, Nov 27, 2013 at 1:51 PM, Brian Theado <[email protected]>wrote:

I wanted to be able to define my mode in an @script node, so I
> refactored some of the colorizer code in order to make it possible. I
> pulled out into a separate method the part of the jeditColorizer
> init_mode method which didn't care about how the mode got loaded. Now
> my @script code can call that new method.
>

Looks reasonable to me.  


>
> My refactoring seems a little clumsy to me...I don't understand how
> all the ivars in that class are used and settled for the small change
> I made. Edward, feel free to polish.
>

There has never been anything elegant about this code.  The word "polish"
does not apply ;-)



> There is still another class which also assumes colorizer modes must
> have a corresponding file in the modes directory. I didn't figure out
> how to resolve that issue and settled for a very ugly hack of
> monkey-patching that method with hard-coded recognition of my mode.
> The c.frame.body.colorizer.isValidLanguage method is the one I
> monkey-patched. Anyone with ideas on how I should fix this without
> monkey-patching, let me know.
>

Just commit a generalization of the monkey-patched version.

 And then document it, please.

The idea is to add a keyword argument.  Something like this (not tested):

    def isValidLanguage (self,language,path=None):
        if path is None:
            path = g.os_path_join(g.app.loadDir,'..','modes')
        fn = g.os_path_finalize_join(path,'%s.py' % (language))
        return g.os_path_exists(fn)

I use this keyword arg trick all the time to add special cases to methods.

HTH.

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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to