##// END OF EJS Templates
Changed doc on how to enable a hook
vivainio -
Show More
@@ -19,20 +19,20 b" For example, suppose that you have a module called 'myiphooks' in your"
19 PYTHONPATH, which contains the following definition:
19 PYTHONPATH, which contains the following definition:
20
20
21 import os
21 import os
22 import IPython.ipapi
23 ip = IPython.ipapi.get()
24
22 def calljed(self,filename, linenum):
25 def calljed(self,filename, linenum):
23 "My editor hook calls the jed editor directly."
26 "My editor hook calls the jed editor directly."
24 print "Calling my own editor, jed ..."
27 print "Calling my own editor, jed ..."
25 os.system('jed +%d %s' % (linenum,filename))
28 os.system('jed +%d %s' % (linenum,filename))
26
29
27 You can then execute the following line of code to make it the new IPython
30 ip.set_hook('editor', calljed)
28 editor hook, after having imported 'myiphooks':
29
30 ip_set_hook('editor',myiphooks.calljed)
31
31
32 The ip_set_hook function is put by IPython into the builtin namespace, so it
32 You can then enable the functionality by doing 'import myiphooks'
33 is always available from all running code.
33 somewhere in your configuration files or ipython command line.
34
34
35 $Id: hooks.py 1087 2006-01-27 17:02:42Z vivainio $"""
35 $Id: hooks.py 1095 2006-01-28 19:43:56Z vivainio $"""
36
36
37 #*****************************************************************************
37 #*****************************************************************************
38 # Copyright (C) 2005 Fernando Perez. <fperez@colorado.edu>
38 # Copyright (C) 2005 Fernando Perez. <fperez@colorado.edu>
@@ -61,7 +61,7 b' def editor(self,filename, linenum=None):'
61
61
62 This is IPython's default editor hook, you can use it as an example to
62 This is IPython's default editor hook, you can use it as an example to
63 write your own modified one. To set your own editor function as the
63 write your own modified one. To set your own editor function as the
64 new editor hook, call ip_set_hook('editor',yourfunc)."""
64 new editor hook, call ip.set_hook('editor',yourfunc)."""
65
65
66 # IPython configures a default editor at startup by reading $EDITOR from
66 # IPython configures a default editor at startup by reading $EDITOR from
67 # the environment, and falling back on vi (unix) or notepad (win32).
67 # the environment, and falling back on vi (unix) or notepad (win32).
@@ -82,7 +82,7 b' def fix_error_editor(self,filename,linenum,column,msg):'
82 The current implementation only has special support for the VIM editor,
82 The current implementation only has special support for the VIM editor,
83 and falls back on the 'editor' hook if VIM is not used.
83 and falls back on the 'editor' hook if VIM is not used.
84
84
85 Call ip_set_hook('fix_error_editor',youfunc) to use your own function,
85 Call ip.set_hook('fix_error_editor',youfunc) to use your own function,
86 """
86 """
87 def vim_quickfix_file():
87 def vim_quickfix_file():
88 t = tempfile.NamedTemporaryFile()
88 t = tempfile.NamedTemporaryFile()
General Comments 0
You need to be logged in to leave comments. Login now