##// END OF EJS Templates
TryNext editor if editor hook fails. Patch by Lukasz Pankowski
Ville M. Vainio -
Show More
@@ -28,7 +28,8 b' def install_editor(run_template, wait = False):'
28 line = 0
28 line = 0
29 cmd = itplns(run_template, locals())
29 cmd = itplns(run_template, locals())
30 print ">",cmd
30 print ">",cmd
31 os.system(cmd)
31 if os.system(cmd) != 0:
32 raise IPython.ipapi.TryNext()
32 if wait:
33 if wait:
33 raw_input("Press Enter when done editing:")
34 raw_input("Press Enter when done editing:")
34
35
@@ -2332,7 +2332,11 b' Currently the magic system has the following functions:\\n"""'
2332 # do actual editing here
2332 # do actual editing here
2333 print 'Editing...',
2333 print 'Editing...',
2334 sys.stdout.flush()
2334 sys.stdout.flush()
2335 try:
2335 self.shell.hooks.editor(filename,lineno)
2336 self.shell.hooks.editor(filename,lineno)
2337 except IPython.ipapi.TryNext:
2338 warn('Could not open editor')
2339 return
2336
2340
2337 # XXX TODO: should this be generalized for all string vars?
2341 # XXX TODO: should this be generalized for all string vars?
2338 # For now, this is special-cased to blocks created by cpaste
2342 # For now, this is special-cased to blocks created by cpaste
@@ -25,7 +25,8 b' ip = IPython.ipapi.get()'
25 def calljed(self,filename, linenum):
25 def calljed(self,filename, linenum):
26 "My editor hook calls the jed editor directly."
26 "My editor hook calls the jed editor directly."
27 print "Calling my own editor, jed ..."
27 print "Calling my own editor, jed ..."
28 os.system('jed +%d %s' % (linenum,filename))
28 if os.system('jed +%d %s' % (linenum,filename)) != 0:
29 raise ipapi.TryNext()
29
30
30 ip.set_hook('editor', calljed)
31 ip.set_hook('editor', calljed)
31
32
@@ -84,7 +85,8 b' def editor(self,filename, linenum=None):'
84 editor = '"%s"' % editor
85 editor = '"%s"' % editor
85
86
86 # Call the actual editor
87 # Call the actual editor
87 os.system('%s %s %s' % (editor,linemark,filename))
88 if os.system('%s %s %s' % (editor,linemark,filename)) != 0:
89 raise ipapi.TryNext()
88
90
89 import tempfile
91 import tempfile
90 def fix_error_editor(self,filename,linenum,column,msg):
92 def fix_error_editor(self,filename,linenum,column,msg):
@@ -105,7 +107,8 b' def fix_error_editor(self,filename,linenum,column,msg):'
105 return
107 return
106 t = vim_quickfix_file()
108 t = vim_quickfix_file()
107 try:
109 try:
108 os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name)
110 if os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name):
111 raise ipapi.TryNext()
109 finally:
112 finally:
110 t.close()
113 t.close()
111
114
@@ -1419,8 +1419,12 b' want to merge them back into the new files.""" % locals()'
1419 except TypeError:
1419 except TypeError:
1420 return 0
1420 return 0
1421 # always pass integer line and offset values to editor hook
1421 # always pass integer line and offset values to editor hook
1422 try:
1422 self.hooks.fix_error_editor(e.filename,
1423 self.hooks.fix_error_editor(e.filename,
1423 int0(e.lineno),int0(e.offset),e.msg)
1424 int0(e.lineno),int0(e.offset),e.msg)
1425 except IPython.ipapi.TryNext:
1426 warn('Could not open editor')
1427 return False
1424 return True
1428 return True
1425
1429
1426 def edit_syntax_error(self):
1430 def edit_syntax_error(self):
General Comments 0
You need to be logged in to leave comments. Login now