1
""" 'editor' hooks for common editors that work well with ipython
3
They should honor the line number argument, at least.
5
Contributions are *very* welcome.
9
ip = IPython.ipapi.get()
11
from IPython.Itpl import itplns
14
def install_editor(run_template, wait = False):
15
""" Gets a template in format "myeditor bah bah $file bah bah $line"
17
$file will be replaced by file name, $line by line number (or 0).
18
Installs the editor that is called by IPython, instead of the default
21
If wait is true, wait until the user presses enter before returning,
22
to facilitate non-blocking editors that exit immediately after
26
def call_editor(self, file, line=0):
29
cmd = itplns(run_template, locals())
33
raw_input("Press Enter when done editing:")
35
ip.set_hook('editor',call_editor)
38
# in these, exe is always the path/name of the executable. Useful
39
# if you don't have the editor directory in your path
41
def komodo(exe = 'komodo'):
42
""" Activestate Komodo [Edit] """
43
install_editor(exe + ' -l $line "$file"', wait = True)
45
def scite(exe = "scite"):
47
install_editor(exe + ' "$file" -goto:$line')
49
def notepadplusplus(exe = 'notepad++'):
50
""" Notepad++ http://notepad-plus.sourceforge.net """
51
install_editor(exe + ' -n$line "$file"')
54
""" JED, the lightweight emacsish editor """
55
install_editor(exe + ' +$line "$file"')
58
""" Idle, the editor bundled with python
60
Should be pretty smart about finding the executable.
64
p = os.path.dirname(idlelib.__file__)
66
install_editor(exe + ' "$file"')
69
# these are untested, report any problems
71
def emacs(exe = 'emacs'):
72
install_editor(exe + ' +$line "$file"')
74
def gnuclient(exe= 'gnuclient'):
75
install_editor(exe + ' -nw +$line "$file"')
77
def crimson_editor(exe = 'cedt.exe'):
78
install_editor(exe + ' /L:$line "$file"')
80
def kate(exe = 'kate'):
81
install_editor(exe + ' -u -l $line "$file"')
b'\\ No newline at end of file'