From 1bea47a9ebe72b2d59b660e233ca7c3f265b3210 2007-09-07 18:53:01 From: vivainio Date: 2007-09-07 18:53:01 Subject: [PATCH] add ipy_editors.py, start it out with scite and komodo --- diff --git a/IPython/Extensions/ipy_editors.py b/IPython/Extensions/ipy_editors.py new file mode 100644 index 0000000..b308810 --- /dev/null +++ b/IPython/Extensions/ipy_editors.py @@ -0,0 +1,31 @@ +""" 'editor' hooks for common editors that work well with ipython + +They should honor the line number argument, at least. + +Contributions are *very* welcome. +""" + +import IPython.ipapi +ip = IPython.ipapi.get() + +from IPython.Itpl import itplns +import os + +def install_editor(run_template): + def call_editor(self, file, line): + if line is None: + line = 0 + cmd = itplns(run_template, locals()) + print ">",cmd + os.system(cmd) + + ip.set_hook('editor',call_editor) + +def komodo(exe = 'komodo'): + """ Warning - komodo does not block """ + install_editor(exe + ' -l $line "$file"') + +def scite(exe = "scite"): + """ Exe is the executable name of your scite. + """ + install_editor(exe + ' "$file" -goto:$line') \ No newline at end of file