Show More
@@ -599,12 +599,19 b' class IPCompleter(Completer):' | |||
|
599 | 599 | return None |
|
600 | 600 | |
|
601 | 601 | |
|
602 | ||
|
603 | def complete(self, text, state): | |
|
602 | def complete(self, text, state,line_buffer=None): | |
|
604 | 603 | """Return the next possible completion for 'text'. |
|
605 | 604 | |
|
606 | 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 | 616 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg |
|
610 | 617 | |
@@ -616,16 +623,20 b' class IPCompleter(Completer):' | |||
|
616 | 623 | |
|
617 | 624 | # don't apply this on 'dumb' terminals, such as emacs buffers, so we |
|
618 | 625 | # don't interfere with their own tab-completion mechanism. |
|
619 | self.full_lbuf = self.get_line_buffer() | |
|
620 |
self.lbuf = self. |
|
|
621 | if not (self.dumb_terminal or self.get_line_buffer().strip()): | |
|
626 | if line_buffer is None: | |
|
627 | self.full_lbuf = self.get_line_buffer() | |
|
628 | else: | |
|
629 | self.full_lbuf = line_buffer | |
|
630 | ||
|
631 | if not (self.dumb_terminal or self.full_lbuf.strip()): | |
|
622 | 632 | self.readline.insert_text('\t') |
|
623 | 633 | return None |
|
624 | ||
|
625 | 634 | |
|
626 | 635 | magic_escape = self.magic_escape |
|
627 | 636 | magic_prefix = self.magic_prefix |
|
628 | 637 | |
|
638 | self.lbuf = self.full_lbuf[:self.readline.get_endidx()] | |
|
639 | ||
|
629 | 640 | try: |
|
630 | 641 | if text.startswith(magic_escape): |
|
631 | 642 | text = text.replace(magic_escape,magic_prefix) |
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.' | |||
|
6 | 6 | |
|
7 | 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 | 1003 | complete = self.Completer.complete |
|
1004 | 1004 | state = 0 |
|
1005 | 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 | 1008 | comps = {} |
|
1008 | 1009 | while True: |
|
1009 | newcomp = complete(text,state) | |
|
1010 | newcomp = complete(text,state,line_buffer=text) | |
|
1010 | 1011 | if newcomp is None: |
|
1011 | 1012 | break |
|
1012 | 1013 | comps[newcomp] = 1 |
@@ -1,5 +1,9 b'' | |||
|
1 | 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 | 7 | * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to |
|
4 | 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