fix for super annoying error

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-11-09 04:13:12 +00:00
parent 756a3e6dd4
commit dc5c58a09f
2 changed files with 15 additions and 9 deletions

View File

@ -5,8 +5,8 @@ from subprocess import Popen, PIPE, STDOUT
import buffer, buffer.about, buffer.color, buffer.console, buffer.data import buffer, buffer.about, buffer.color, buffer.console, buffer.data
import buffer.fs import buffer.fs
import bufferlist, color, completer, keyinput, method, minibuffer, mode import bufferlist, color, completer, ispell, keyinput, method, minibuffer
import util, window import mode, util, window
from point import Point from point import Point
class Application(object): class Application(object):
@ -879,6 +879,7 @@ def run_app(stdscr, buffers, jump_to_line=None, init_mode=None):
curses.def_shell_mode() curses.def_shell_mode()
a = Application(stdscr, buffers, jump_to_line, init_mode) a = Application(stdscr, buffers, jump_to_line, init_mode)
a.run() a.run()
return 0
if __name__ == "__main__": if __name__ == "__main__":
ciphers = { ciphers = {
@ -976,12 +977,16 @@ if __name__ == "__main__":
keyinput.disable_control_chars() keyinput.disable_control_chars()
# ok, now run our app # ok, now run our app
retval = 1
try: try:
retval = curses.wrapper(run_app, buffers, opts.goto, opts.mode) curses.wrapper(run_app, buffers, opts.goto, opts.mode)
err = 0
except: except:
traceback.print_exc() traceback.print_exc()
err = 1
# restore terminal state # restore terminal state
termios.tcsetattr(sys.stdin, termios.TCSANOW, attr) termios.tcsetattr(sys.stdin, termios.TCSANOW, attr)
sys.exit(retval) ispell.free()
if not err:
os.system('clear')
sys.exit(err)

View File

@ -7,11 +7,15 @@ _speller = None
_can_spell = os.system('which ispell > /dev/null 2>&1') == 0 _can_spell = os.system('which ispell > /dev/null 2>&1') == 0
def can_spell(): def can_spell():
global _can_spell
return _can_spell return _can_spell
def get_speller(): def get_speller():
global _speller global _speller
if _can_spell and not _speller:
_speller = Speller()
return _speller return _speller
def free():
if _speller:
_speller.close()
class Speller(object): class Speller(object):
def __init__(self, cmd='ispell'): def __init__(self, cmd='ispell'):
@ -77,9 +81,6 @@ class Speller(object):
self.pipe.stdin.flush() self.pipe.stdin.flush()
self.flush(word) self.flush(word)
if _can_spell:
_speller = Speller()
if __name__ == "__main__": if __name__ == "__main__":
s = Speller() s = Speller()
while True: while True: