Show More
@@ -12,6 +12,7 b' update upgrade' | |||||
12 |
|
12 | |||
13 | """ |
|
13 | """ | |
14 | import IPython.ipapi |
|
14 | import IPython.ipapi | |
|
15 | import glob,os,shlex | |||
15 |
|
16 | |||
16 | ip = IPython.ipapi.get() |
|
17 | ip = IPython.ipapi.get() | |
17 |
|
18 | |||
@@ -91,4 +92,28 b' def svn_completer(self,event):' | |||||
91 |
|
92 | |||
92 | return svn_commands.split() |
|
93 | return svn_commands.split() | |
93 |
|
94 | |||
94 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') No newline at end of file |
|
95 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') | |
|
96 | ||||
|
97 | def runlistpy(self, event): | |||
|
98 | comps = shlex.split(event.line) | |||
|
99 | relpath = (len(comps) > 1 and comps[-1] or '') | |||
|
100 | ||||
|
101 | print "rp",relpath | |||
|
102 | if relpath.startswith('~'): | |||
|
103 | relpath = os.path.expanduser(relpath) | |||
|
104 | dirs = [f.replace('\\','/') + "/" for f in glob.glob(relpath+'*') if os.path.isdir(f)] | |||
|
105 | pys = [f.replace('\\','/') for f in glob.glob(relpath+'*.py')] | |||
|
106 | return dirs + pys | |||
|
107 | ||||
|
108 | ip.set_hook('complete_command', runlistpy, str_key = '%run') | |||
|
109 | ||||
|
110 | def listdirs(self, event): | |||
|
111 | relpath = event.symbol | |||
|
112 | if relpath.startswith('~'): | |||
|
113 | relpath = os.path.expanduser(relpath).replace('\\','/') | |||
|
114 | found = [f.replace('\\','/')+'/' for f in glob.glob(relpath+'*') if os.path.isdir(f)] | |||
|
115 | if not found: | |||
|
116 | return [relpath] | |||
|
117 | return found | |||
|
118 | ||||
|
119 | ip.set_hook('complete_command', listdirs, str_key = '%cd') No newline at end of file |
@@ -540,8 +540,19 b' class IPCompleter(Completer):' | |||||
540 | event.symbol = text |
|
540 | event.symbol = text | |
541 | cmd = line.split(None,1)[0] |
|
541 | cmd = line.split(None,1)[0] | |
542 | event.command = cmd |
|
542 | event.command = cmd | |
|
543 | #print "\ncustom:{%s]\n" % event # dbg | |||
|
544 | ||||
|
545 | # for foo etc, try also to find completer for %foo | |||
|
546 | if not cmd.startswith(self.magic_escape): | |||
|
547 | try_magic = self.custom_completers.s_matches( | |||
|
548 | self.magic_escape + cmd) | |||
|
549 | else: | |||
|
550 | try_magic = [] | |||
|
551 | ||||
|
552 | ||||
543 | for c in itertools.chain( |
|
553 | for c in itertools.chain( | |
544 | self.custom_completers.s_matches(cmd), |
|
554 | self.custom_completers.s_matches(cmd), | |
|
555 | try_magic, | |||
545 | self.custom_completers.flat_matches(self.lbuf)): |
|
556 | self.custom_completers.flat_matches(self.lbuf)): | |
546 | # print "try",c # dbg |
|
557 | # print "try",c # dbg | |
547 | try: |
|
558 | try: |
@@ -1,3 +1,10 b'' | |||||
|
1 | 2006-11-02 Ville Vainio <vivainio@gmail.com> | |||
|
2 | ||||
|
3 | * ipy_stock_completers.py: Add %run and %cd completers. | |||
|
4 | ||||
|
5 | * completer.py: Try running custom completer for both | |||
|
6 | "foo" and "%foo" if the command is just "foo". | |||
|
7 | ||||
1 | 2006-10-31 Ville Vainio <vivainio@gmail.com> |
|
8 | 2006-10-31 Ville Vainio <vivainio@gmail.com> | |
2 |
|
9 | |||
3 | * strdispatch.py, completer.py, ipy_stock_completers.py: |
|
10 | * strdispatch.py, completer.py, ipy_stock_completers.py: |
General Comments 0
You need to be logged in to leave comments.
Login now