##// END OF EJS Templates
Add `wait` optional argument to `hooks.editor`...
Takafumi Arakaki -
Show More
@@ -42,6 +42,7 b' somewhere in your configuration files or ipython command line.'
42 #*****************************************************************************
42 #*****************************************************************************
43
43
44 import os, bisect
44 import os, bisect
45 import subprocess
45 import sys
46 import sys
46
47
47 from IPython.core.error import TryNext
48 from IPython.core.error import TryNext
@@ -54,7 +55,7 b" __all__ = ['editor', 'fix_error_editor', 'synchronize_with_editor',"
54 'show_in_pager','pre_prompt_hook',
55 'show_in_pager','pre_prompt_hook',
55 'pre_run_code_hook', 'clipboard_get']
56 'pre_run_code_hook', 'clipboard_get']
56
57
57 def editor(self,filename, linenum=None):
58 def editor(self, filename, linenum=None, wait=True):
58 """Open the default editor at the given filename and linenumber.
59 """Open the default editor at the given filename and linenumber.
59
60
60 This is IPython's default editor hook, you can use it as an example to
61 This is IPython's default editor hook, you can use it as an example to
@@ -76,7 +77,9 b' def editor(self,filename, linenum=None):'
76 editor = '"%s"' % editor
77 editor = '"%s"' % editor
77
78
78 # Call the actual editor
79 # Call the actual editor
79 if os.system('%s %s %s' % (editor,linemark,filename)) != 0:
80 proc = subprocess.Popen('%s %s %s' % (editor, linemark, filename),
81 shell=True)
82 if wait and proc.wait() != 0:
80 raise TryNext()
83 raise TryNext()
81
84
82 import tempfile
85 import tempfile
General Comments 0
You need to be logged in to leave comments. Login now