#NEWLINE# def edit_text( text , prompt = 'Edit text' ) : #NEWLINE# #INDENT# 'Run $EDITOR on text. Defaults to vim.' #NEWLINE# fname = os . path . join ( os . environ [ 'HOME' ] , '.edit_text.txt' ) #NEWLINE# fo = open ( fname , 'w' ) #NEWLINE# fo . write ( ( prompt + ':\n' ) ) #NEWLINE# fo . write ( text ) #NEWLINE# fo . close ( ) #NEWLINE# os . system ( ( '%s "%s"' % ( os . environ . get ( 'EDITOR' , '/usr/bin/vim' ) , fname ) ) ) #NEWLINE# fo = open ( fname , 'r' ) #NEWLINE# try : #NEWLINE# #INDENT# text = fo . read ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# fo . close ( ) #NEWLINE# os . unlink ( fname ) #NEWLINE# #UNINDENT# return text [ ( text . find ( '\n' ) + 1 ) : ]