-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscholar-sublime.py
25 lines (20 loc) · 1007 Bytes
/
scholar-sublime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import sublime, sublime_plugin
import webbrowser
class ScholarsublimeSearchPaperCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
# if the user didn't select anything, search the currently highlighted word
if selection.empty():
text = self.view.word(selection)
text = self.view.substr(selection)
url = "http://scholar.google.com/scholar?hl=en&q=" + text
webbrowser.open_new(url)
class ScholarsublimeSearchAuthorCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
# if the user didn't select anything, search the currently highlighted word
if selection.empty():
text = self.view.word(selection)
text = self.view.substr(selection)
url = "http://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=" + text
webbrowser.open_new(url)