Show More
@@ -5,9 +5,10 b' They should honor the line number argument, at least.' | |||||
5 | Contributions are *very* welcome. |
|
5 | Contributions are *very* welcome. | |
6 | """ |
|
6 | """ | |
7 |
|
7 | |||
8 | from IPython.core.error import TryNext |
|
|||
9 | from IPython.frontend.qt.console import ipython_widget |
|
|||
10 | import os |
|
8 | import os | |
|
9 | import pipes | |||
|
10 | import subprocess | |||
|
11 | from IPython.core.error import TryNext | |||
11 |
|
12 | |||
12 |
|
13 | |||
13 | def install_editor(template, wait=False): |
|
14 | def install_editor(template, wait=False): | |
@@ -38,11 +39,10 b' def install_editor(template, wait=False):' | |||||
38 | # ' for string substitution. You supplied "%s"' % (substitution, |
|
39 | # ' for string substitution. You supplied "%s"' % (substitution, | |
39 | # run_template))) |
|
40 | # run_template))) | |
40 |
|
41 | |||
41 |
|
||||
42 | def call_editor(self, filename, line=0): |
|
42 | def call_editor(self, filename, line=0): | |
43 | if line is None: |
|
43 | if line is None: | |
44 | line = 0 |
|
44 | line = 0 | |
45 | cmd = template.format(filename=filename, line=line) |
|
45 | cmd = template.format(filename=pipes.quote(filename), line=line) | |
46 | print ">", cmd |
|
46 | print ">", cmd | |
47 | proc = subprocess.Popen(cmd, shell=True) |
|
47 | proc = subprocess.Popen(cmd, shell=True) | |
48 | if wait and proc.wait() != 0: |
|
48 | if wait and proc.wait() != 0: | |
@@ -58,22 +58,22 b' def install_editor(template, wait=False):' | |||||
58 | # if you don't have the editor directory in your path |
|
58 | # if you don't have the editor directory in your path | |
59 | def komodo(exe=u'komodo'): |
|
59 | def komodo(exe=u'komodo'): | |
60 | """ Activestate Komodo [Edit] """ |
|
60 | """ Activestate Komodo [Edit] """ | |
61 |
install_editor(exe + u' -l {line} |
|
61 | install_editor(exe + u' -l {line} {filename}', wait=True) | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | def scite(exe=u"scite"): |
|
64 | def scite(exe=u"scite"): | |
65 | """ SciTE or Sc1 """ |
|
65 | """ SciTE or Sc1 """ | |
66 |
install_editor(exe + u' |
|
66 | install_editor(exe + u' {filename} -goto:{line}') | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | def notepadplusplus(exe=u'notepad++'): |
|
69 | def notepadplusplus(exe=u'notepad++'): | |
70 | """ Notepad++ http://notepad-plus.sourceforge.net """ |
|
70 | """ Notepad++ http://notepad-plus.sourceforge.net """ | |
71 |
install_editor(exe + u' -n{line} |
|
71 | install_editor(exe + u' -n{line} {filename}') | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | def jed(exe=u'jed'): |
|
74 | def jed(exe=u'jed'): | |
75 | """ JED, the lightweight emacsish editor """ |
|
75 | """ JED, the lightweight emacsish editor """ | |
76 |
install_editor(exe + u' +{line} |
|
76 | install_editor(exe + u' +{line} {filename}') | |
77 |
|
77 | |||
78 |
|
78 | |||
79 | def idle(exe=u'idle'): |
|
79 | def idle(exe=u'idle'): | |
@@ -87,16 +87,16 b" def idle(exe=u'idle'):" | |||||
87 | if exe is None: |
|
87 | if exe is None: | |
88 | import idlelib |
|
88 | import idlelib | |
89 | p = os.path.dirname(idlelib.__filename__) |
|
89 | p = os.path.dirname(idlelib.__filename__) | |
90 |
# i'm not sure if this actually works. Is this idle.py script |
|
90 | # i'm not sure if this actually works. Is this idle.py script | |
91 | # to be executable? |
|
91 | # guarenteed to be executable? | |
92 | exe = os.path.join(p, 'idle.py') |
|
92 | exe = os.path.join(p, 'idle.py') | |
93 |
install_editor(exe + u' |
|
93 | install_editor(exe + u' {filename}') | |
94 |
|
94 | |||
95 |
|
95 | |||
96 | def mate(exe=u'mate'): |
|
96 | def mate(exe=u'mate'): | |
97 | """ TextMate, the missing editor""" |
|
97 | """ TextMate, the missing editor""" | |
98 | # wait=True is not required since we're using the -w flag to mate |
|
98 | # wait=True is not required since we're using the -w flag to mate | |
99 |
install_editor(exe + u' -w -l {line} |
|
99 | install_editor(exe + u' -w -l {line} {filename}') | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | # ########################################## |
|
102 | # ########################################## | |
@@ -105,16 +105,16 b" def mate(exe=u'mate'):" | |||||
105 |
|
105 | |||
106 |
|
106 | |||
107 | def emacs(exe=u'emacs'): |
|
107 | def emacs(exe=u'emacs'): | |
108 |
install_editor(exe + u' +{line} |
|
108 | install_editor(exe + u' +{line} {filename}') | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | def gnuclient(exe=u'gnuclient'): |
|
111 | def gnuclient(exe=u'gnuclient'): | |
112 |
install_editor(exe + u' -nw +{line} |
|
112 | install_editor(exe + u' -nw +{line} {filename}') | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | def crimson_editor(exe=u'cedt.exe'): |
|
115 | def crimson_editor(exe=u'cedt.exe'): | |
116 |
install_editor(exe + u' /L:{line} |
|
116 | install_editor(exe + u' /L:{line} {filename}') | |
117 |
|
117 | |||
118 |
|
118 | |||
119 | def kate(exe=u'kate'): |
|
119 | def kate(exe=u'kate'): | |
120 |
install_editor(exe + u' -u -l {line} |
|
120 | install_editor(exe + u' -u -l {line} {filename}') |
General Comments 0
You need to be logged in to leave comments.
Login now