##// END OF EJS Templates
update changelog
update changelog

File last commit:

r849:037abd50
r850:2965dc5c
Show More
ipy_editors.py
79 lines | 2.2 KiB | text/x-python | PythonLexer
vivainio
add ipy_editors.py, start it out with scite and komodo
r843 """ '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
vivainio
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
r847 def install_editor(run_template, wait = False):
vivainio
improve install_editor docstring
r849 """ Gets a template in format "myeditor bah bah $file bah bah $line"
vivainio
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
r847
vivainio
improve install_editor docstring
r849 $file will be replaced by file name, $line by line number (or 0).
vivainio
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
r847 Installs the editor that is called by IPython, instead of the default
notepad or vi.
vivainio
add some preconfigured editors
r848
If wait is true, wait until the user presses enter before returning,
to facilitate non-blocking editors that exit immediately after
the call.
vivainio
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
r847 """
vivainio
add ipy_editors.py, start it out with scite and komodo
r843 def call_editor(self, file, line):
if line is None:
line = 0
cmd = itplns(run_template, locals())
print ">",cmd
os.system(cmd)
vivainio
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
r847 if wait:
raw_input("Press Enter when done editing:")
vivainio
add ipy_editors.py, start it out with scite and komodo
r843
ip.set_hook('editor',call_editor)
vivainio
add some preconfigured editors
r848
# in these, exe is always the path/name of the executable. Useful
# if you don't have the editor directory in your path
vivainio
add ipy_editors.py, start it out with scite and komodo
r843 def komodo(exe = 'komodo'):
vivainio
add some preconfigured editors
r848 """ Activestate Komodo [Edit] """
vivainio
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
r847 install_editor(exe + ' -l $line "$file"', wait = True)
vivainio
add ipy_editors.py, start it out with scite and komodo
r843
def scite(exe = "scite"):
vivainio
add some preconfigured editors
r848 """ SciTE or Sc1 """
install_editor(exe + ' "$file" -goto:$line')
def notepadplusplus(exe = 'notepad++'):
""" Notepad++ http://notepad-plus.sourceforge.net """
install_editor(exe + ' -n$line "$file"')
def jed(exe = 'jed'):
""" JED, the lightweight emacsish editor """
install_editor(exe + ' +$line "$file"')
def idle(exe = None):
""" Idle, the editor bundled with python
Should be pretty smart about finding the executable.
vivainio
add ipy_editors.py, start it out with scite and komodo
r843 """
vivainio
add some preconfigured editors
r848 if exe is None:
import idlelib
p = os.path.dirname(idlelib.__file__)
exe = p + '/idle.py'
install_editor(exe + ' "$file"')
# these are untested, report any problems
def emacs(exe = 'emacs'):
install_editor(exe + ' +$line "$file"')
def gnuclient(exe= 'gnuclient'):
install_editor(exe + ' -nw +$line "$file"')
def crimson_editor(exe = 'cedt.exe'):
install_editor(exe + ' /L:%line "$file"')