Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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; '\xe9crit': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'stefan': 0.17; 'thanks,': 0.18; '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; 'received:10.0.0': 0.28; 'exposed': 0.29; 'prints': 0.29; 'readline': 0.29; "i'm": 0.29; 'function': 0.30; 'url:python': 0.32; 'mac': 0.32; 'print': 0.32; 'skip:s 30': 0.33; 'received:10.0': 0.33; 'problem': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'created': 0.36; 'tool': 0.36; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'display': 0.36; 'correctly': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'registered': 0.38; 'behind': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'received:10': 0.38; 'system.': 0.39; 'called': 0.39; 'subject:-': 0.40; 'enable': 0.60; 'received:194': 0.61; 'header :Message-Id:1': 0.62; 'more': 0.63; 'received:ch': 0.69; 'press': 0.71; 'day': 0.73; 'completion': 0.78; 'prompt': 0.78 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=JvTLszKX4nIB/0x0EqjQZhsuy7Qap1/KIFhkathYR48=; b=M2Au+a7Mpgng5Mwp0pOp+mxgQ2HwtZ5pLc51RJQQ/eDjFP6PTi3cKF4sKUzcADgjSo Z3MFeraZ+qxjaOoWac28W/KnmZVYr+MFqKRqJrj2gFTmqvHvtHLYavDeFm5zseHYa6W1 NJ2vT+8AknK3pXqUzvb5FFC0mzDR2MdWd/fntOvXCqDYucWPpWafsJPznIzN/paUvDBf xcWb7/Y1GYwRq9yblFQZ72IWEG3pZvQFgLD14qtM8q4LBquK3j1R3/egEzswXISoUs+O xtTUCn//gpolLGsZPlI9j5qrRxmulqh8yernVbC2k8oDKzel+naBKnTOv8qBJvRPkDEY 4D8w== Subject: Re: how-to use readline.set_completion_display_matches_hook()? Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=iso-8859-1 From: Jean-Pierre Miceli In-Reply-To: Date: Thu, 8 Nov 2012 06:53:09 +0100 Content-Transfer-Encoding: quoted-printable References: To: "Stefan H. Holek" X-Mailer: Apple Mail (2.1257) X-Gm-Message-State: ALoCoQnpCUF3nxHNE3QElGkSTf/lH8Mo+WJzAXtOkJxO/87T38FVfNdxrBig6Ym/pQr3l83+l4BZeQfKkbj7Q7ktN550DRgEgFHkkAEszJTtrzaPa/hpXLs/B+uPi7NbebQypv5M4TEqaU7L5WGAJQYVZpPu498HKg== 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352353985 news.xs4all.nl 6933 [2001:888:2000:d::a6]:34717 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32932 Thanks, I will try rl.=20 Have a nice day J-P Le 7 nov. 2012 =E0 14:14, Stefan H. Holek a =E9crit : > On 07.11.2012, at 11:36, Jean-Pierre Miceli wrote: >=20 >> 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. >=20 > 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. >=20 > 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. >=20 > Hope this helps, > Stefan >=20 > --=20 > Stefan H. Holek > stefan@epy.co.at >=20