homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: rlcompleter add "real tab" when text is empty feature
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Thomas Fenzl, dieresys, facundobatista, georg.brandl, gpolo, lesmana, lilaboc, pitrou, r.david.murray, rnd0110
Priority: normal Keywords: patch

Created on 2010年02月10日 08:19 by lilaboc, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
rlcompleter.diff lilaboc, 2010年02月10日 08:19 patch to rlcompleter which does almost as described
Messages (5)
msg99159 - (view) Author: zhou wei (lilaboc) Date: 2010年02月10日 08:19
When I use rlcompleter in interactive Python mode, I think it will be more convenient if autocomplete produce a real tab when text-to-autocomplete is empty.
For example:
>>> def test():
...<TAB>
will give:
Display all 182 possibilities? (y or n)
instead of a real tab
So, when indentation is needed, 4 times of spacebar pressing are required. That's why I think it will make more sense to just return a tab character when there is nothing to autocomplete.
This behavior is similar to autocompletion in ipython
msg99161 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010年02月10日 11:51
On the one hand, it makes sense for the common case of completing using the Tab key.
On the other hand, it will appear quite bizarre to people who have another, dedicated key for auto-completion.
By the way, rather than inserting a tab character, it should probably insert 4 spaces instead.
msg99613 - (view) Author: zhou wei (lilaboc) Date: 2010年02月20日 06:28
Pitrou,
I think you are right on "On the other hand, it will appear quite bizarre to people who have another, dedicated key for auto-completion." If I assign another key for auto-completion, the behavior becomes really strange. It happens in ipython too.
But I guess most people just use tab as the default key for auto-completion, and the readline module document say:"
get_begidx( ) 
 Get the beginning index of the readline tab-completion scope. 
get_endidx( ) 
 Get the ending index of the readline tab-completion scope. 
set_completer_delims( string) 
 Set the readline word delimiters for tab-completion. 
get_completer_delims( ) 
 Get the readline word delimiters for tab-completion. 
"
And now, I think the problem becomes:convenience for the majority or protection for the minority. If we decide to protect the minority, I think I can submit another patch for the readline module document, to make the document constant, so, the document looks like:
get_endidx( ) 
 Get the ending index of the readline auto-completion scope. 
PS: Is there a way to find out the current key-binding on auto-completion? If we can find this, I think we can "if else" this behavior to satisfy everybody.
msg184526 - (view) Author: Thomas Fenzl (Thomas Fenzl) * Date: 2013年03月18日 21:19
It's not (easily) possible to get the invoked character that caused the completion function. 
Multiple keys can be bound to complete and the bindable function rl_complete provided in libreadline does not forward the invoking key to rl_complete_internal, through which Completer.complete is eventually called.
msg184528 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013年03月18日 21:24
Thomas's analysis is that in order to make this work, changes would be required in libreadline. That being the case, and given that changing this without being able to special case tab would break things for people using other complete characters, I'm going to close this issue.
History
Date User Action Args
2022年04月11日 14:56:57adminsetgithub: 52146
2013年03月18日 21:24:52r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg184528

stage: resolved
2013年03月18日 21:19:34Thomas Fenzlsetnosy: + Thomas Fenzl
messages: + msg184526
2010年06月06日 15:32:39lesmanasetnosy: + lesmana
2010年02月20日 06:28:41lilabocsetmessages: + msg99613
2010年02月10日 11:51:18pitrousetmessages: + msg99161
2010年02月10日 08:19:17lilaboccreate

AltStyle によって変換されたページ (->オリジナル) /