First time here? Check out the FAQ!

Revision history  [back]

The following should be an equivalent script --

from __future__ import with_statement

import os.path, sys
sys.path += [
    os.path.dirname(__file__), 
    os.path.join(os.path.dirname(__file__), 'third_party.zip'), 
]

import wingapi

def comment_evaluate_sel_in_debug_probe(editor=None):
    '''
    Evaluate a commented selection in debug probe, do `select-more` if no selection.
    Suggested key combination: `Ctrl-Alt-D`
    '''

    if editor is None:
        editor = wingapi.gApplication.GetActiveEditor()

    assert isinstance(editor, wingapi.CAPIEditor)
    wingapi.gApplication.ExecuteCommand('comment-toggle')    
    wingapi.gApplication.ExecuteCommand('evaluate-sel-in-debug-console')
    editor.ExecuteCommand('undo')

There are two changes:

  • The editor=wingapi.kArgEditor is replaced by editor=None followed by if editor is None: editor = wingapi.gApplication.GetActiveEditor()

  • The 'evaluate-sel-in-debug-probe' command name is replaced by 'evaluate-sel-in-debug-console'