Style fixes.
This commit is contained in:
parent
748f54b2f9
commit
2c4c95725e
@ -26,6 +26,7 @@
|
|||||||
# DEALINGS IN THE SOFTWARE.
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
docomplete = True
|
docomplete = True
|
||||||
|
|
||||||
@ -79,32 +80,27 @@ class Completer(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class completion(object):
|
@contextmanager
|
||||||
|
def completion(completer=None):
|
||||||
delims = "()[]{} "
|
delims = "()[]{} "
|
||||||
|
|
||||||
def __init__(self, completer=None):
|
|
||||||
if not completer:
|
if not completer:
|
||||||
completer = Completer()
|
completer = Completer()
|
||||||
|
|
||||||
self.completer = completer
|
if docomplete:
|
||||||
|
readline.set_completer(completer.complete)
|
||||||
|
readline.set_completer_delims(delims)
|
||||||
|
|
||||||
def __enter__(self):
|
history = os.path.expanduser("~/.hy-history")
|
||||||
if not docomplete:
|
|
||||||
return
|
|
||||||
|
|
||||||
readline.set_completer(self.completer.complete)
|
|
||||||
readline.set_completer_delims(self.delims)
|
|
||||||
|
|
||||||
self.history = os.path.expanduser("~/.hy-history")
|
|
||||||
readline.parse_and_bind("set blink-matching-paren on")
|
readline.parse_and_bind("set blink-matching-paren on")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
readline.read_history_file(self.history)
|
readline.read_history_file(history)
|
||||||
except IOError:
|
except IOError:
|
||||||
open(self.history, 'a').close()
|
open(history, 'a').close()
|
||||||
|
|
||||||
readline.parse_and_bind("tab: complete")
|
readline.parse_and_bind("tab: complete")
|
||||||
|
|
||||||
def __exit__(self, type, value, tb):
|
yield
|
||||||
|
|
||||||
if docomplete:
|
if docomplete:
|
||||||
readline.write_history_file(self.history)
|
readline.write_history_file(history)
|
||||||
|
Loading…
Reference in New Issue
Block a user