Show More
@@ -49,16 +49,16 b' pkg_cache = None' | |||||
49 |
|
49 | |||
50 | def module_completer(self,event): |
|
50 | def module_completer(self,event): | |
51 | """ Give completions after user has typed 'import' """ |
|
51 | """ Give completions after user has typed 'import' """ | |
52 |
|
52 | |||
53 | # only a local version for py 2.4, pkgutil has no walk_packages() there |
|
53 | # only a local version for py 2.4, pkgutil has no walk_packages() there | |
54 | if sys.version_info < (2,5): |
|
54 | if sys.version_info < (2,5): | |
55 | for el in [f[:-3] for f in glob.glob("*.py")]: |
|
55 | for el in [f[:-3] for f in glob.glob("*.py")]: | |
56 | yield el |
|
56 | yield el | |
57 | return |
|
57 | return | |
58 |
|
58 | |||
59 | global pkg_cache |
|
59 | global pkg_cache | |
60 | import pkgutil,imp,time |
|
60 | import pkgutil,imp,time | |
61 | #current = |
|
61 | #current = | |
62 | if pkg_cache is None: |
|
62 | if pkg_cache is None: | |
63 | print "\n\n[Standby while scanning modules, this can take a while]\n\n" |
|
63 | print "\n\n[Standby while scanning modules, this can take a while]\n\n" | |
64 | pkg_cache = list(pkgutil.walk_packages()) |
|
64 | pkg_cache = list(pkgutil.walk_packages()) | |
@@ -95,11 +95,14 b' def runlistpy(self, event):' | |||||
95 | comps = shlex.split(event.line) |
|
95 | comps = shlex.split(event.line) | |
96 | relpath = (len(comps) > 1 and comps[-1] or '') |
|
96 | relpath = (len(comps) > 1 and comps[-1] or '') | |
97 |
|
97 | |||
98 | print "rp",relpath |
|
98 | #print "rp",relpath # dbg | |
|
99 | glob = glob.glob | |||
|
100 | isdir = os.path.isdir | |||
99 | if relpath.startswith('~'): |
|
101 | if relpath.startswith('~'): | |
100 | relpath = os.path.expanduser(relpath) |
|
102 | relpath = os.path.expanduser(relpath) | |
101 |
dirs = [f.replace('\\','/') + "/" for f in |
|
103 | dirs = [f.replace('\\','/') + "/" for f in glob(relpath+'*') | |
102 | pys = [f.replace('\\','/') for f in glob.glob(relpath+'*.py')] |
|
104 | if isdir(f)] | |
|
105 | pys = [f.replace('\\','/') for f in glob(relpath+'*.py')] | |||
103 | return dirs + pys |
|
106 | return dirs + pys | |
104 |
|
107 | |||
105 | ip.set_hook('complete_command', runlistpy, str_key = '%run') |
|
108 | ip.set_hook('complete_command', runlistpy, str_key = '%run') | |
@@ -127,4 +130,4 b' def cd_completer(self, event):' | |||||
127 | return [relpath] |
|
130 | return [relpath] | |
128 | return found |
|
131 | return found | |
129 |
|
132 | |||
130 | ip.set_hook('complete_command', cd_completer, str_key = '%cd') |
|
133 | ip.set_hook('complete_command', cd_completer, str_key = '%cd') |
@@ -344,7 +344,7 b' class IPCompleter(Completer):' | |||||
344 | current (as of Python 2.3) Python readline it's possible to do |
|
344 | current (as of Python 2.3) Python readline it's possible to do | |
345 | better.""" |
|
345 | better.""" | |
346 |
|
346 | |||
347 |
# |
|
347 | #print 'Completer->file_matches: <%s>' % text # dbg | |
348 |
|
348 | |||
349 | # chars that require escaping with backslash - i.e. chars |
|
349 | # chars that require escaping with backslash - i.e. chars | |
350 | # that readline treats incorrectly as delimiters, but we |
|
350 | # that readline treats incorrectly as delimiters, but we | |
@@ -406,7 +406,9 b' class IPCompleter(Completer):' | |||||
406 | # Takes care of links to directories also. Use '/' |
|
406 | # Takes care of links to directories also. Use '/' | |
407 | # explicitly, even under Windows, so that name completions |
|
407 | # explicitly, even under Windows, so that name completions | |
408 | # don't end up escaped. |
|
408 | # don't end up escaped. | |
409 | matches[0] += '/' |
|
409 | pjoin = os.path.join | |
|
410 | d = matches[0] | |||
|
411 | matches = [ pjoin(d,p) for p in os.listdir(d) ] | |||
410 | return matches |
|
412 | return matches | |
411 |
|
413 | |||
412 | def alias_matches(self, text): |
|
414 | def alias_matches(self, text): |
@@ -1,3 +1,10 b'' | |||||
|
1 | 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/completer.py (IPCompleter.file_matches): Fix | |||
|
4 | tab-completion so that quotes are not closed unless the completion | |||
|
5 | is unambiguous. After a request by Stefan. Minor cleanups in | |||
|
6 | ipy_stock_completers. | |||
|
7 | ||||
1 | 2006-11-02 Ville Vainio <vivainio@gmail.com> |
|
8 | 2006-11-02 Ville Vainio <vivainio@gmail.com> | |
2 |
|
9 | |||
3 | * ipy_stock_completers.py: Add %run and %cd completers. |
|
10 | * ipy_stock_completers.py: Add %run and %cd completers. |
General Comments 0
You need to be logged in to leave comments.
Login now