From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#28580: python.el: native completion setup failed Date: Sun, 24 Sep 2017 13:51:19 -0400 Message-ID: <87a81km1d4.fsf@users.sourceforge.net> References: <87lgl4m5uo.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1506275534 29394 195.159.176.226 (24 Sep 2017 17:52:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 24 Sep 2017 17:52:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: 28580@debbugs.gnu.org To: =?UTF-8?Q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9_?= =?UTF-8?Q?=D0=9F=D0=B0=D1=80=D0=B0=D0=BC=D0=BE=D0=BD=D0=BE=D0=B2?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 24 19:52:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwB4Z-0007L2-2m for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Sep 2017 19:52:07 +0200 Original-Received: from localhost ([::1]:38935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwB4g-00088Y-F3 for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Sep 2017 13:52:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwB4a-00088B-Er for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 13:52:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwB4U-0007bZ-3I for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 13:52:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47737) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwB4T-0007bP-W6 for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 13:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dwB4T-0007ZM-Ov for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 13:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Sep 2017 17:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28580 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28580-submit@debbugs.gnu.org id=B28580.150627548729051 (code B ref 28580); Sun, 24 Sep 2017 17:52:01 +0000 Original-Received: (at 28580) by debbugs.gnu.org; 24 Sep 2017 17:51:27 +0000 Original-Received: from localhost ([127.0.0.1]:56418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwB3v-0007YV-Dv for submit@debbugs.gnu.org; Sun, 24 Sep 2017 13:51:27 -0400 Original-Received: from mail-it0-f41.google.com ([209.85.214.41]:45625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwB3u-0007YH-9W for 28580@debbugs.gnu.org; Sun, 24 Sep 2017 13:51:26 -0400 Original-Received: by mail-it0-f41.google.com with SMTP id x15so5079367itb.0 for <28580@debbugs.gnu.org>; Sun, 24 Sep 2017 10:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=hG5EMXe3Liq6tCk2gLRAJuU9CG0EmJZ7UmVSTmp07vw=; b=DVAIcvtC0MeZCGNrBtmUsDSvOdKxxygskbI7S22i/dKXQruo+0m/Kq3NmfOBRkkLwg 2amOsHuxvwiAf7xDcX+xV4RMnsq6bkPsDSev6sIN/cUf888XDWhOSLsknlWzTgY22YmA LmEKbMCi+FnnnBJN62TH5f0QBlWjRdkT18K+fCrkHCCGyitjNoSQFQXpiRsI5tB1lrZw Mbx6/xyivCBT1UVCuo5ppVgicjw8GIv5Rrt7lrU5bvrkD2yJt35NLpHBaoDhDuu4RN6z C3bXCK/AD8KEqyIaxyvBplMZPVNQGxjkS31AM6aau9cTD9APztphRGsYHW212sb0FMXX nwug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=hG5EMXe3Liq6tCk2gLRAJuU9CG0EmJZ7UmVSTmp07vw=; b=Ta8o5MF0WrzwwRKWFa0v8IQpnUpgDZc/qRnanPJaqoRy4R2MtoX+pr65BRc+BvOPey ib+7HVM5aCGCU4jGMGQpIalMfyvYJsrVRSQ1z0M6ymzqlZtBnYECXYSpvz0+RYq3WVp3 ZOJRWtCftsiyxk2U0Tuq5ErJYAVC8SyOYyhdjhzwUMYqqQOJlwdA7AvjjDVhZYxNLJ5b W5vNXyQgAQGNUx5pQTgQriXU5RfjUoiOr5TFQNR8ZRmhqPR3KdDmWSNR/zyuRwRyNtk/ uVFRqAyGciBu2rDjfBInQivQrQXB45ZXTboHweE8lWAhbEwZnYifMWMZWgetwcfk8LnB xuFg== X-Gm-Message-State: AHPjjUjwDyVsFSrr6pxNicqDwbmRVb1BQpX7UOhUZm3ecnP8gsUco/Xm naVc9pBBs8LY4eNBPjZ/fx921g== X-Google-Smtp-Source: AOwi7QCLhR3Fiacj8DpN0AXjSYKNsNOkb3U200WYZvQmsbfvgc24EuiJXM0AXFNDex6CsheQmUW6/Q== X-Received: by 10.36.120.142 with SMTP id p136mr14886250itc.55.1506275480399; Sun, 24 Sep 2017 10:51:20 -0700 (PDT) Original-Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id h20sm1208106iob.0.2017.09.24.10.51.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 10:51:19 -0700 (PDT) In-Reply-To: ("=?UTF-8?Q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9_?= =?UTF-8?Q?=D0=9F=D0=B0=D1=80=D0=B0=D0=BC=D0=BE=D0=BD=D0=BE=D0=B2?="'s message of "Sun, 24 Sep 2017 19:56:39 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137353 Archived-At: =D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9 =D0=9F=D0=B0=D1=80=D0=B0=D0=BC=D0=BE= =D0=BD=D0=BE=D0=B2 writes: > It didn't help, unfortunately: I was indeed missing pyreadline, but > installing it from conda repo made no difference :-( > Neither did using "-i -u" as interactive Python arg. > > I vaguely remember this working with older Pythons -- what could > probably change? Hmm, can you try running the python code from python-shell-completion-native-setup manually from a prompt and see what comes out? (or where it goes wrong) def __PYTHON_EL_native_completion_setup(): try: import readline try: import __builtin__ except ImportError: # Python 3 import builtins as __builtin__ builtins =3D dir(__builtin__) is_ipython =3D ('__IPYTHON__' in builtins or '__IPYTHON__active' in builtins) class __PYTHON_EL_Completer: '''Completer wrapper that prints candidates to stdout. It wraps an existing completer function and changes its behavio= r so that the user input is unchanged and real candidates are printe= d to stdout. Returned candidates are '0__dummy_completion__' and '1__dummy_completion__' in that order ('0__dummy_completion__' = is returned repeatedly until all possible candidates are consumed). The real candidates are printed to stdout so that they can be easily retrieved through comint output redirect trickery. ''' PYTHON_EL_WRAPPED =3D True def __init__(self, completer): self.completer =3D completer self.last_completion =3D None self.print_mode =3D True def __call__(self, text, state): if state =3D=3D 0: # Set the first dummy completion. self.last_completion =3D None completion =3D '0__dummy_completion__' else: completion =3D self.completer(text, state - 1) if not completion: if self.last_completion !=3D '1__dummy_completion__': # When no more completions are available, returning= a # dummy with non-sharing prefix allow ensuring outp= ut # while preventing changes to current input. # Coincidentally it's also the end of output. completion =3D '1__dummy_completion__' elif completion.endswith('('): # Remove parens on callables as it breaks completion on # arguments (e.g. str(Ari)). completion =3D completion[:-1] self.last_completion =3D completion if completion in ( '0__dummy_completion__', '1__dummy_completion__'): return completion elif completion: # For every non-dummy completion, return a repeated dum= my # one and print the real candidate so it can be retriev= ed # by comint output filters. if self.print_mode: print (completion) return '0__dummy_completion__' else: return completion else: return completion completer =3D readline.get_completer() if not completer: # Used as last resort to avoid breaking customizations. import rlcompleter completer =3D readline.get_completer() if completer and not getattr(completer, 'PYTHON_EL_WRAPPED', False): # Wrap the existing completer function only once. new_completer =3D __PYTHON_EL_Completer(completer) if not is_ipython: readline.set_completer(new_completer) else: # Try both initializations to cope with all IPython version= s. # This works fine for IPython 3.x but not for earlier: readline.set_completer(new_completer) # IPython<3 hacks readline such that `readline.set_complete= r` # won't work. This workaround injects the new completer # function into the existing instance directly: instance =3D getattr(completer, 'im_self', completer.__self= __) instance.rlcomplete =3D new_completer if readline.__doc__ and 'libedit' in readline.__doc__: readline.parse_and_bind('bind ^I rl_complete') else: readline.parse_and_bind('tab: complete') # Require just one tab to send output. readline.parse_and_bind('set show-all-if-ambiguous on') print ('python.el: native completion setup loaded') except: print ('python.el: native completion setup failed') __PYTHON_EL_native_completion_setup()