Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'url:pypi': 0.03; 'messages.': 0.04; 'apis': 0.07; 'returned.': 0.07; 'python': 0.09; 'tab': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '"test': 0.16; '2.7.3': 0.16; 'bindings.': 0.16; 'function"': 0.16; 'newlines': 0.16; 'ubuntu.': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'stefan': 0.17; 'tests': 0.18; 'all,': 0.21; 'back.': 0.22; 'cc:2**0': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'exposed': 0.29; 'prints': 0.29; 'readline': 0.29; 'received:192.168.1.3': 0.29; "i'm": 0.29; 'function': 0.30; 'url:python': 0.32; 'mac': 0.32; 'print': 0.32; 'skip:s 30': 0.33; 'problem': 0.33; 'done': 0.34; 'there': 0.35; 'created': 0.36; 'tool': 0.36; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'display': 0.36; 'correctly': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'registered': 0.38; 'behind': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'system.': 0.39; 'received:192': 0.39; 'called': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'enable': 0.60; 'header:Message-Id:1': 0.62; 'more': 0.63; 'press': 0.71; 'received:at': 0.71; 'completion': 0.78; 'prompt': 0.78 Subject: Re: how-to use readline.set_completion_display_matches_hook()? Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: "Stefan H. Holek" In-Reply-To: Date: Wed, 7 Nov 2012 14:14:56 +0100 Content-Transfer-Encoding: quoted-printable References: To: Jean-Pierre Miceli X-Mailer: Apple Mail (2.1085) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352294105 news.xs4all.nl 6949 [2001:888:2000:d::a6]:42897 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32885 On 07.11.2012, at 11:36, Jean-Pierre Miceli wrote: > Hi all, >=20 > I'm working on a tool which enable support of tab completion using the > readline modul. > And I have a problem with set_completion_display_matches_hook function >=20 > I've created a display hook function and registered it. It is called > and it prints the desire messages. But once it has completed, > readline/python does not display the prompt. > I've got to press the 'return' key to see the prompt again. > What should the display hook function do to return correctly and let > the prompt be displayed? >=20 > Example: > def completerHook(self, substitution, matches, longest_match_length): > print "" > print "Test of the display hook function" > for i in range(len(matches)): > print matches[i], >=20 > I use Python 2.7.3 and done some tests on Mac OS 10.7 (Lion) and > Ubuntu. I got the same issue on both system. This always happens when you print newlines behind readline's back. To = update the prompt area, you'd have to call rl_forced_update_display() = which is AFAIK not exposed by the stdlib's readline bindings. There is a more complete implementation of the GNU Readline APIs at = http://pypi.python.org/pypi/rl. With rl you can fix the prompt by = calling rl.readline.redisplay(force=3DTrue) after the hook has returned. Hope this helps, Stefan --=20 Stefan H. Holek stefan@epy.co.at