Show More
@@ -599,12 +599,19 b' class IPCompleter(Completer):' | |||||
599 | return None |
|
599 | return None | |
600 |
|
600 | |||
601 |
|
601 | |||
602 |
|
602 | def complete(self, text, state,line_buffer=None): | ||
603 | def complete(self, text, state): |
|
|||
604 | """Return the next possible completion for 'text'. |
|
603 | """Return the next possible completion for 'text'. | |
605 |
|
604 | |||
606 | This is called successively with state == 0, 1, 2, ... until it |
|
605 | This is called successively with state == 0, 1, 2, ... until it | |
607 |
returns None. The completion should begin with 'text'. |
|
606 | returns None. The completion should begin with 'text'. | |
|
607 | ||||
|
608 | :Keywords: | |||
|
609 | - line_buffer: string | |||
|
610 | If not given, the completer attempts to obtain the current line buffer | |||
|
611 | via readline. This keyword allows clients which are requesting for | |||
|
612 | text completions in non-readline contexts to inform the completer of | |||
|
613 | the entire text. | |||
|
614 | """ | |||
608 |
|
615 | |||
609 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg |
|
616 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg | |
610 |
|
617 | |||
@@ -616,16 +623,20 b' class IPCompleter(Completer):' | |||||
616 |
|
623 | |||
617 | # don't apply this on 'dumb' terminals, such as emacs buffers, so we |
|
624 | # don't apply this on 'dumb' terminals, such as emacs buffers, so we | |
618 | # don't interfere with their own tab-completion mechanism. |
|
625 | # don't interfere with their own tab-completion mechanism. | |
619 | self.full_lbuf = self.get_line_buffer() |
|
626 | if line_buffer is None: | |
620 |
self.lbuf = self. |
|
627 | self.full_lbuf = self.get_line_buffer() | |
621 | if not (self.dumb_terminal or self.get_line_buffer().strip()): |
|
628 | else: | |
|
629 | self.full_lbuf = line_buffer | |||
|
630 | ||||
|
631 | if not (self.dumb_terminal or self.full_lbuf.strip()): | |||
622 | self.readline.insert_text('\t') |
|
632 | self.readline.insert_text('\t') | |
623 | return None |
|
633 | return None | |
624 |
|
||||
625 |
|
634 | |||
626 | magic_escape = self.magic_escape |
|
635 | magic_escape = self.magic_escape | |
627 | magic_prefix = self.magic_prefix |
|
636 | magic_prefix = self.magic_prefix | |
628 |
|
637 | |||
|
638 | self.lbuf = self.full_lbuf[:self.readline.get_endidx()] | |||
|
639 | ||||
629 | try: |
|
640 | try: | |
630 | if text.startswith(magic_escape): |
|
641 | if text.startswith(magic_escape): | |
631 | text = text.replace(magic_escape,magic_prefix) |
|
642 | text = text.replace(magic_escape,magic_prefix) |
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.' | |||||
6 |
|
6 | |||
7 | This file contains all the classes and helper functions specific to IPython. |
|
7 | This file contains all the classes and helper functions specific to IPython. | |
8 |
|
8 | |||
9 |
$Id: iplib.py 219 |
|
9 | $Id: iplib.py 2197 2007-04-02 07:36:55Z fperez $ | |
10 | """ |
|
10 | """ | |
11 |
|
11 | |||
12 | #***************************************************************************** |
|
12 | #***************************************************************************** | |
@@ -1003,10 +1003,11 b' class InteractiveShell(object,Magic):' | |||||
1003 | complete = self.Completer.complete |
|
1003 | complete = self.Completer.complete | |
1004 | state = 0 |
|
1004 | state = 0 | |
1005 | # use a dict so we get unique keys, since ipyhton's multiple |
|
1005 | # use a dict so we get unique keys, since ipyhton's multiple | |
1006 | # completers can return duplicates. |
|
1006 | # completers can return duplicates. When we make 2.4 a requirement, | |
|
1007 | # start using sets instead, which are faster. | |||
1007 | comps = {} |
|
1008 | comps = {} | |
1008 | while True: |
|
1009 | while True: | |
1009 | newcomp = complete(text,state) |
|
1010 | newcomp = complete(text,state,line_buffer=text) | |
1010 | if newcomp is None: |
|
1011 | if newcomp is None: | |
1011 | break |
|
1012 | break | |
1012 | comps[newcomp] = 1 |
|
1013 | comps[newcomp] = 1 |
@@ -1,5 +1,9 b'' | |||||
1 | 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1 | 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
2 | |||
|
3 | * IPython/completer.py (IPCompleter.complete): extend the | |||
|
4 | complete() call API to support completions by other mechanisms | |||
|
5 | than readline. Closes #109. | |||
|
6 | ||||
3 | * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to |
|
7 | * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to | |
4 | protect against a bug in Python's execfile(). Closes #123. |
|
8 | protect against a bug in Python's execfile(). Closes #123. | |
5 |
|
9 |
General Comments 0
You need to be logged in to leave comments.
Login now