Show More
@@ -1,31 +1,43 b'' | |||
|
1 | 1 | """ 'editor' hooks for common editors that work well with ipython |
|
2 | 2 | |
|
3 | 3 | They should honor the line number argument, at least. |
|
4 | 4 | |
|
5 | 5 | Contributions are *very* welcome. |
|
6 | 6 | """ |
|
7 | 7 | |
|
8 | 8 | import IPython.ipapi |
|
9 | 9 | ip = IPython.ipapi.get() |
|
10 | 10 | |
|
11 | 11 | from IPython.Itpl import itplns |
|
12 | 12 | import os |
|
13 | 13 | |
|
14 | def install_editor(run_template): | |
|
14 | def install_editor(run_template, wait = False): | |
|
15 | """ Gets a template in format "myeditor bah bah $file bah bah $line | |
|
16 | ||
|
17 | Installs the editor that is called by IPython, instead of the default | |
|
18 | notepad or vi. | |
|
19 | """ | |
|
20 | ||
|
15 | 21 | def call_editor(self, file, line): |
|
16 | 22 | if line is None: |
|
17 | 23 | line = 0 |
|
18 | 24 | cmd = itplns(run_template, locals()) |
|
19 | 25 | print ">",cmd |
|
20 | 26 | os.system(cmd) |
|
27 | if wait: | |
|
28 | raw_input("Press Enter when done editing:") | |
|
21 | 29 | |
|
22 | 30 | ip.set_hook('editor',call_editor) |
|
23 | 31 | |
|
24 | 32 | def komodo(exe = 'komodo'): |
|
25 | """ Warning - komodo does not block """ | |
|
26 | install_editor(exe + ' -l $line "$file"') | |
|
33 | """ Activestate Komodo [Edit] | |
|
34 | ||
|
35 | Warning - komodo does not block, so can't be used for plain %edit | |
|
36 | ||
|
37 | """ | |
|
38 | install_editor(exe + ' -l $line "$file"', wait = True) | |
|
27 | 39 | |
|
28 | 40 | def scite(exe = "scite"): |
|
29 | 41 | """ Exe is the executable name of your scite. |
|
30 | 42 | """ |
|
31 | 43 | install_editor(exe + ' "$file" -goto:$line') No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now