-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgotodrupalapi.py
More file actions
22 lines (19 loc) · 844 Bytes
/
gotodrupalapi.py
File metadata and controls
22 lines (19 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sublime_plugin
import webbrowser
# -------------------------------------------
# { "keys": ["super+shift+a"], "command": "open_drupalapi" }
# -------------------------------------------
# Open the URL in the current selection
class GotoDrupalapiCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
# if region.begin and region.begin are the same
# no selection has been made, so grab the whole word
if region.begin() == region.end():
word = self.view.word(region)
# otherwise, grab just the selection
else:
word = region
if not word.empty():
keyword = self.view.substr(word)
webbrowser.open_new_tab("http://api.drupal.org/api/search/7/%s" % keyword)