From: James Porter <james@jamesporter.me>
To: 24110@debbugs.gnu.org
Subject: bug#24110: [PATCH] Fix python.el completion with IPython 5.0 and python 2
Date: Fri, 29 Jul 2016 21:01:16 -0400 [thread overview]
Message-ID: <CAHaOWCsQ2t6hHHp_GFT9=jAhp23ZRZ_A4Zc-V3Dx4WO8MuTgQw@mail.gmail.com> (raw)
In version 5.0 of IPython, which was recently released, the
IPCompleter.all_completions method changed slightly when running under
Python 2--it returns a unicode object rather than a str object. This
causes python.el completion to fail, since it uses this function and
the string Emacs gets back from the Python subprocess is e.g. if the
two valid completions are random and range: `u'random;range'` as
opposed to `'random;range'`, which isn't parsed correctly on the Emacs
side due to the spurious leading `u`. The below patch fixes this issue
by wrapping the string sent to Python for evaluation in a call to
`print`, which avoids printing the `u` when the return value is a
unicode object.
Cheers,
James Porter
* lisp/progmodes/python.el(python-shell-completion-string-code): Wrap
in a call to print to correctly handle the case that the return value
is unicode.
---
lisp/progmodes/python.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ad69f87..f87052f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3258,7 +3258,7 @@ def __PYTHON_EL_get_completions(text):
:group 'python)
(defcustom python-shell-completion-string-code
- "';'.join(__PYTHON_EL_get_completions('''%s'''))"
+ "print(';'.join(__PYTHON_EL_get_completions('''%s''')))"
"Python code used to get a string of completions separated by semicolons.
The string passed to the function is the current python name or
the full statement in the case of imports."
--
2.6.4 (Apple Git-63)
next reply other threads:[~2016-07-30 1:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-30 1:01 James Porter [this message]
2017-07-03 15:15 ` bug#24110: [PATCH] Fix python.el completion with IPython 5.0 and python 2 npostavs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHaOWCsQ2t6hHHp_GFT9=jAhp23ZRZ_A4Zc-V3Dx4WO8MuTgQw@mail.gmail.com' \
--to=james@jamesporter.me \
--cc=24110@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.