From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Carlos Pita Newsgroups: gmane.emacs.bugs Subject: bug#19736: Date: Mon, 2 Feb 2015 14:38:15 -0300 Message-ID: References: <87y4ojhpgq.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1422898751 3548 80.91.229.3 (2 Feb 2015 17:39:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2015 17:39:11 +0000 (UTC) Cc: Fabian Ezequiel Gallina To: 19736@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 02 18:39:10 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YIKxq-0003nv-Hn for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Feb 2015 18:39:10 +0100 Original-Received: from localhost ([::1]:55769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIKxp-0005eP-Vw for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Feb 2015 12:39:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIKxm-0005dh-8n for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 12:39:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIKxi-00078n-8O for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 12:39:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIKxi-00078X-49 for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 12:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YIKxh-0003zj-Lc for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 12:39:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87y4ojhpgq.fsf@gmail.com> Resent-From: Carlos Pita Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Feb 2015 17:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19736 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 19736-submit@debbugs.gnu.org id=B19736.142289872415319 (code B ref 19736); Mon, 02 Feb 2015 17:39:01 +0000 Original-Received: (at 19736) by debbugs.gnu.org; 2 Feb 2015 17:38:44 +0000 Original-Received: from localhost ([127.0.0.1]:60607 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YIKxQ-0003z1-3k for submit@debbugs.gnu.org; Mon, 02 Feb 2015 12:38:44 -0500 Original-Received: from mail-la0-f44.google.com ([209.85.215.44]:41788) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YIKxN-0003yh-VJ for 19736@debbugs.gnu.org; Mon, 02 Feb 2015 12:38:42 -0500 Original-Received: by mail-la0-f44.google.com with SMTP id s18so43488000lam.3 for <19736@debbugs.gnu.org>; Mon, 02 Feb 2015 09:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:cc:content-type; bh=sX1GNSP4HutFqZWU1gmkTTen6UcdXULQxw3KxsfTGIs=; b=c1dzAlNl2HyCBbyknt/AwDxN/RceziZRIL6ZE0sg4xp6HZFuHQS+aDAyEZEYJwfsLh g0QukqAnE/342WroFggHbEw7NeFnjdj4kzK3YPF9/UDzXDoGSu+LS6CRKJx8Ar7w2Pxo Ry6smFSzwwXyG88hfoby7Fep8H7h4I6Qwe953/liSYNyeA90TH6YS9rFHtZ2AR6homtQ 8XLoI+ViWahK1akbt4w9ijpe/dkaNq0vwBcis9oj/JxoVnHbjxSMV+FhCFGSh6/lMQw1 Qxth7gAo2QeblW/nVJhUvtWfd5HBxMKNd7D37zxo5aoyVonhC8PFnENxGX/tm/w8efcH Y4sQ== X-Received: by 10.152.4.233 with SMTP id n9mr20892563lan.61.1422898715994; Mon, 02 Feb 2015 09:38:35 -0800 (PST) Original-Received: by 10.112.124.202 with HTTP; Mon, 2 Feb 2015 09:38:15 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98987 Archived-At: Just in case, here is the modified code for both completion setups (I'm not listing the minor changes to python-shell-completion-native-get-completions below): (defcustom python-shell-completion-setup-code "def __PYTHON_EL_get_completions(text): try: import __builtin__ except ImportError: # Python 3 import builtins as __builtin__ builtins = dir(__builtin__) is_ipython = ('__IPYTHON__' in builtins or '__IPYTHON__active' in builtins) completions = [] try: if is_ipython: splits = text.split() is_module = splits and splits[0] in ('from', 'import') if is_module: from IPython.core.completerlib import module_completion completions = module_completion(text.strip()) elif '__IP' in builtins: completions = __IP.complete(text) elif 'get_ipython' in builtins: completions = get_ipython().Completer.all_completions(text) else: # Never do this in IPython as it overrides the completer! import readline, rlcompleter i = 0 while True: res = readline.get_completer()(text, i) if not res: break i += 1 completions.append(res) except: pass return completions" "Code used to setup completion in inferior Python processes." :type 'string :group 'python) (defun python-shell-completion-native-setup () "Try to setup native completion, return non-nil on success." (let ((process (python-shell-get-process))) (python-shell-send-string (funcall 'mapconcat #'identity (list "try:" " import readline" " def completer(text, state, c=readline.get_completer()):" " completion = c(text, state)" " if not completion and state == 1:" " return text + '__dummy_completion__'" " else:" " return completion" " readline.set_completer(completer)" " if readline.__doc__ and 'libedit' in readline.__doc__:" " readline.parse_and_bind('bind ^I rl_complete')" " else:" " readline.parse_and_bind('tab: complete')" " print ('python.el: readline is available')" " del completer, readline # Some cleanup" "except:" " print ('python.el: readline not available')") "\n") process) (python-shell-accept-process-output process) (when (save-excursion (re-search-backward (regexp-quote "python.el: readline is available") nil t 1)) (python-shell-completion-native-try))))