Sublime Forum

On_load() EventListener not called on first launch

#1

I’m using ST3 as an external editor to display error logs from another application (katana) with syntax highlighting. So katana launches sublime via a wrapper script that includes sublime_text --wait pathToErrorLog.txt. My package includes the .tmLanguage with highlighting rules and .tmTheme for custom color scheme, and an EventListener subclass that uses on_load() to watch for katana log files being opened.

This works perfectly when a ST3 instance happens to be already running. However, if ST3 is being newly launched via the above command, on_load() doesn’t get called after the log is loaded. Also tried on_load_async(), same problem. Should I be using a different callback? I’m wondering if maybe plugins have not finished loading and registering callbacks by the time this first buffer is loaded. Thanks!

class PxOpenKatanaRenderLog (sublime_plugin.EventListener):

    def on_load (self, view):
        filePath = view.file_name()
        fileName = os.path.basename (filePath)
        if fileName.startswith ('katanaRenderLog'):
            view.run_command ('px_katana_strip_progress_warnings')
            view.run_command ('px_katana_pretty_print_render_log')
            view.settings().set ('syntax', 'Packages/Katana/KatanaRenderLog.tmLanguage')
            view.settings().set ('color_scheme', 'Packages/Katana/KatanaRenderLog.tmTheme')
            view.settings().set ('line_numbers', False)
            view.settings().set ('fade_fold_buttons', False)
            view.set_scratch (True)
0 Likes

#2
1 Like

#3

Thanks for that link. Very helpful.

0 Likes