def run(self, edit):
        if len(self.view.file_name()) > 0:
            settings = sublime.load_settings('orgmode.sublime-settings')
            item = None
            word = self.view.substr(self.view.word(self.view.sel()[0].begin()))
            scope = self.view.scope_name(self.view.sel()[0].begin()).strip()
            getlang = scope.split('.')
            language = getlang[-1]
            if language == 'basic':
                language = getlang[-2]

            if language == 'html':  # HTML shows up A LOT for internal CSS, PHP and JS
                if 'php' in getlang:
                    language = 'php'
                elif 'js' in getlang:
                    language = 'js'
                elif 'css' in getlang:
                    language = 'css'

            # Map languages if needed. For example: Map .less files to .css
            # searches
            print('language: ' + language)
            if settings.get(language) is not None:
                print('lang found in settings: ' + language)
                item = settings.get(language)
                if 'map' in item:
                    language = item['map']

            sublime.status_message(
                'helpIt invoked-- ' + 'Scope: ' + scope + ' Word: ' + word + ' Language: ' + language)
            for region in self.view.sel():
                phrase = self.view.substr(region)
                search = 'http://google.com/search?q=%s'
                custom = False

                # Define our search term
                if not region.empty():
                    term = phrase
                else:
                    term = word

                if item != None:
                    if 'sub' in item:  # check for sub searches based on our term
                        subs = item['sub']
                        for sub in subs:
                            if 'contains' in sub and 'url' in sub:  # Make sure we have everything
                                if term.count(sub['contains']):
                                    if 'remove' in sub:
                                        term = re.sub(sub['remove'], '', term)
                                    search = sub['url']
                                    custom = True
                                    break

                    if not custom:
                        if isinstance(item, str):
                            search = item
                            custom = True
                        elif 'url' in item:
                            search = item['url']
                            custom = True

                if not custom:
                    term += " " + language

                try:
                    search = search % (term)
                    print(search)
                except TypeError:
                    print("No replacements")

                webbrowser.open_new_tab(search)
        else:
            pass
dataset/ETHPy150Open danielmagnussons/orgmode/help_it.py/helpItCommand.run/original