From 1adb483649146059a2cdc6c452364033646051f7 Mon Sep 17 00:00:00 2001 From: moculus Date: Fri, 6 Mar 2009 14:21:52 +0000 Subject: [PATCH] fixed some completion bugs --HG-- branch : pmacs2 --- completer.py | 8 ++++++++ method/shell.py | 4 ++-- util.py | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/completer.py b/completer.py index 8541403..91d3539 100644 --- a/completer.py +++ b/completer.py @@ -51,6 +51,7 @@ class Completer(object): class FileCompleter(Completer): def get_candidates(self, s, w=None): s = util.expand_tilde(s) + #raise Exception(s + '*') candidates = [util.normal_path(p) for p in glob.glob(s + '*')] # ignore some suffixes by default, unless the only possible completions @@ -67,6 +68,7 @@ class FileCompleter(Completer): if candidates2: candidates = candidates2 + #raise(s + "* :: " + repr(candidates)) return candidates class BufferCompleter(Completer): @@ -76,7 +78,13 @@ class BufferCompleter(Completer): return candidates class CommandCompleter(Completer): + def __init__(self, application): + Completer.__init__(self, application) + self.fc = FileCompleter(application) def get_candidates(self, s, w=None): + if s.startswith('~') or s.startswith('/') or s.startswith('./') or s.startswith('../'): + return self.fc.get_candidates(s) + path = os.getenv('PATH') path_dirs = path.split(':') candidates = set() diff --git a/method/shell.py b/method/shell.py index 68f8837..3273710 100644 --- a/method/shell.py +++ b/method/shell.py @@ -84,7 +84,7 @@ class Man(Exec): class Pipe(Method): '''Pipe the buffer's contents through the command, and display the output in a new buffer''' - args = [Argument('cmd', datatype="str", prompt="Command: ")] + args = [Argument('cmd', datatype="shell", prompt="Pipe: ")] def _parse(self, w, **vargs): # return 3 things: prog name, cmd, and whether to use the shell m = regex.shell_command.match(vargs['cmd']) @@ -139,7 +139,7 @@ class Interact(Method): '''Interact with a program via a PTY''' args = [Argument('bname', datatype="str", prompt="Buffer Name: ", default=default.build_constant('*Interact*')), - Argument('cmd', datatype="str", prompt="Command: ", + Argument('cmd', datatype="shell", prompt="Command: ", default=default.build_constant('bash'))] def _execute(self, w, **vargs): bname = vargs['bname'] diff --git a/util.py b/util.py index 41bfc29..c6036fe 100644 --- a/util.py +++ b/util.py @@ -1,7 +1,8 @@ import os, pwd, regex def normal_path(path): - path = os.path.realpath(path) + #path = os.path.realpath(path) + path = os.path.normpath(path) home = os.getenv('HOME') isdir = os.path.isdir(path) if path.startswith(home): @@ -12,6 +13,7 @@ def normal_path(path): return path def expand_tilde(path): + isd = path.endswith('/') if not path.startswith('~'): return path parts = path.split('/', 1) @@ -27,7 +29,7 @@ def expand_tilde(path): else: s = parts[0] s = os.path.realpath(s) - if os.path.isdir(s): + if os.path.isdir(s) and isd: s += '/' return s