From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dan Davison Newsgroups: gmane.emacs.bugs Subject: bug#24322: [PATCH] Re: 25.1.50; Python completion should not strip trailing space Date: Sat, 27 Aug 2016 22:58:25 +0000 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114aae5e282572053b159288 X-Trace: blaine.gmane.org 1472338765 24935 195.159.176.226 (27 Aug 2016 22:59:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Aug 2016 22:59:25 +0000 (UTC) To: 24322@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 28 00:59:21 2016 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 1bdmZK-0005rI-PE for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Aug 2016 00:59:19 +0200 Original-Received: from localhost ([::1]:37456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdmZI-0005EB-8n for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Aug 2016 18:59:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdmZA-0005CU-N9 for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2016 18:59:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bdmZ4-0006Un-RO for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2016 18:59:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44561) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdmZ4-0006UY-LT for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2016 18:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bdmZ4-0004pL-8Y for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2016 18:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dan Davison Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2016 22:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24322 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24322-submit@debbugs.gnu.org id=B24322.147233872418529 (code B ref 24322); Sat, 27 Aug 2016 22:59:02 +0000 Original-Received: (at 24322) by debbugs.gnu.org; 27 Aug 2016 22:58:44 +0000 Original-Received: from localhost ([127.0.0.1]:42273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdmYm-0004on-1c for submit@debbugs.gnu.org; Sat, 27 Aug 2016 18:58:44 -0400 Original-Received: from mail-it0-f52.google.com ([209.85.214.52]:35290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdmYj-0004oW-Rn for 24322@debbugs.gnu.org; Sat, 27 Aug 2016 18:58:42 -0400 Original-Received: by mail-it0-f52.google.com with SMTP id x131so50457273ite.0 for <24322@debbugs.gnu.org>; Sat, 27 Aug 2016 15:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=PGDcl3f1zcEiLJaxCA8elDx3LHfT0yz7Nw5CCkrxVxY=; b=oqQmXfRF4QoSCODMpuBpDi5V1x0Et4gHxs5VEreQCpBwgGkctKb8yLDz9boEwehvKQ cOc5SvwvMA1zaDq2wTO9tN5ds3KRMgxfCgih3q02O7lFImhGMILJxcbbNhWwq29n1sEt cGeVRLufwbO6NoWw3pToBmd1EcJGCaH+oyhV/Ww7JM/DsV1uCB9NyRftQCPd6RlOWvA9 RmI6bm7HYJLbhle+EPrSo2sOaClsC4z/+GzvXrtpRGddgTeCZagzONQLATOayOW3E10F dpzDbe6oatAjQxccaUp7u0/uCPeBW3j+eIrfi2bC63pLMgYw7BgDKNvK+N+wR3+8BqNL MEHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=PGDcl3f1zcEiLJaxCA8elDx3LHfT0yz7Nw5CCkrxVxY=; b=RXE5zXVWPaxWlIhX6kfLY61myLEPZoRcUTmRzOfkz2vCszFKSuTdc1g20SGRPaNEq4 XeFpxmq0v5lx0iXhmKyAiOtgsemRKb07OC5iPl1yPls5no+kCR7zG1l3wwL4GEZUkktM iOu9+gLgltT+7plUUS4fQm0KrCukRWsyZLz4TCSao+hDuBB1NYr4m4QvL5XrI5W/PZpt f0xENMcbUPRcHUGi5fzAdqLagbZtOP4vNMRb6obUD75PqXoIIroImLTOZM5Aq/bjSvN5 kTuJFr5Lc74ph7T+aIULICU+vjxNY4IbSoaM5+WUBrzp7nv4R0uRbAZYut+tYzFlwEDq SBQA== X-Gm-Message-State: AE9vXwMbZPZ2ZWXsTPNOMSDEd0q57nnm6FLd3g3ZOh6WssFW2CGGgvGrLQ4817n6Qq63AScv7fiOFVqdIoowQg== X-Received: by 10.36.46.203 with SMTP id i194mr6017045ita.69.1472338716008; Sat, 27 Aug 2016 15:58:36 -0700 (PDT) In-Reply-To: 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:122730 Archived-At: --001a114aae5e282572053b159288 Content-Type: text/plain; charset=UTF-8 The patch currently only fixes "native" (readline-based) completion. If it is agreed that this is the correct direction I can prepare a similar patch for the non-native / legacy completion function `python-shell-completion-get-completions', which shows the same behavior. On Sat, 27 Aug 2016 at 14:47 Dan Davison wrote: > Here is the patch pasted into the body of an email: > > From 8e69b33a53ea30389a5e3946dd711320a77e0d23 Mon Sep 17 00:00:00 2001 > From: Dan Davison > Date: Fri, 5 Aug 2016 12:19:20 -0700 > Subject: [PATCH] Don't strip space from python completions > > The returned completion deliberately includes a space after a word like > 'import', which is always followed by more words. > > * lisp/progmodes/python.el > (python-shell-completion-native-get-completions): > Remove space from regular expression character class > --- > 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..8616279 100644 > --- a/lisp/progmodes/python.el > +++ b/lisp/progmodes/python.el > @@ -3551,7 +3551,7 @@ completion." > (split-string > (buffer-substring-no-properties > (line-beginning-position) (point-min)) > - "[ \f\t\n\r\v()]+" t) > + "[\f\t\n\r\v()]+" t) > :test #'string=)))) > (set-process-filter process original-filter-fn))))) > > -- > 2.3.2 (Apple Git-55) > > > On Sat, 27 Aug 2016 at 14:21 Dan Davison wrote: > >> Patch attached. >> >> This patch is also available as a pull request at at >> https://github.com/dandavison/emacs/pull/1 The commit hash >> is 8e69b33a53ea30389a5e3946dd711320a77e0d23. >> >> I have only tested this on macOS. As far as I am aware, when the space >> character is present, it is present deliberately and it is appropriate to >> retain it, but I would appreciate feedback from python.el experts. >> >> On Sat, 27 Aug 2016 at 14:10 Dan Davison wrote: >> >>> From emacs -Q: >>> >>> (setq python-shell-interpreter "ipython" >>> python-shell-interpreter-args "-i") >>> >>> M-x run-python >>> >>> In the python comint buffer insert "from itertools imp" and hit tab. >>> >>> You will see "imp" completed as "import" (no trailing space). >>> >>> However, if you do this in ipython itself, you will see "imp" completed >>> as "import ". This (i.e. what ipython does) is the desired behavior >>> (because import is always followed by another word). >>> >>> In GNU Emacs 25.1.50.1 (x86_64-apple-darwin14.5.0, NS appkit-1348.17 >>> Version 10.10.5 (Build 14F27)) >>> of 2016-04-16 built on hemiprocne >>> Repository revision: 934549e23d6bda5231375dbfed7b42a966c85d14 >>> Windowing system distributor 'Apple', version 10.3.1348 >>> Configured using: >>> 'configure --prefix=/usr/local/Cellar/emacs/HEAD >>> --enable-locallisppath=/usr/local/share/emacs/site-lisp >>> --infodir=/usr/local/Cellar/emacs/HEAD/share/info/emacs --with-xml2 >>> --without-dbus --without-gnutls --with-ns --disable-ns-self-contained' >>> >>> Configured features: >>> JPEG NOTIFY ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS >>> >>> Important settings: >>> value of $LANG: en_US.UTF-8 >>> locale-coding-system: utf-8-unix >>> >>> Major mode: Lisp Interaction >>> >>> Minor modes in effect: >>> tooltip-mode: t >>> global-eldoc-mode: t >>> electric-indent-mode: t >>> mouse-wheel-mode: t >>> tool-bar-mode: t >>> menu-bar-mode: t >>> file-name-shadow-mode: t >>> global-font-lock-mode: t >>> font-lock-mode: t >>> blink-cursor-mode: t >>> auto-composition-mode: t >>> auto-encryption-mode: t >>> auto-compression-mode: t >>> line-number-mode: t >>> transient-mark-mode: t >>> >>> Recent messages: >>> For information about GNU Emacs and the GNU system, type C-h C-a. >>> >>> Load-path shadows: >>> None found. >>> >>> Features: >>> (shadow sort mail-extr emacsbug message dired dired-loaddefs format-spec >>> rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config >>> gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse >>> rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 >>> ietf-drums mm-util mail-prsvr mail-utils time-date mule-util tooltip >>> eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel >>> term/ns-win ns-win ucs-normalize term/common-win tool-bar dnd fontset >>> image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode >>> prog-mode register page menu-bar rfn-eshadow timer select scroll-bar >>> mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame >>> cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai >>> tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian >>> slovak czech european ethiopic indian cyrillic chinese charscript >>> case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer >>> cl-preloaded nadvice loaddefs button faces cus-face macroexp files >>> text-properties overlay sha1 md5 base64 format env code-pages mule >>> custom widget hashtable-print-readable backquote kqueue cocoa ns >>> multi-tty make-network-process emacs) >>> >>> Memory information: >>> ((conses 16 195970 9329) >>> (symbols 48 19431 0) >>> (miscs 40 43 170) >>> (strings 32 14792 5110) >>> (string-bytes 1 431078) >>> (vectors 16 32763) >>> (vector-slots 8 640839 4764) >>> (floats 8 156 54) >>> (intervals 56 194 0) >>> (buffers 976 11)) >>> >>> --001a114aae5e282572053b159288 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The patch currently only fixes "native" (readlin= e-based) completion. If it is agreed that this is the correct direction I c= an prepare a similar patch for the non-native / legacy completion function = `python-shell-completion-get-completions', which shows the same behavio= r.

On Sat, 27 Aug 2016= at 14:47 Dan Davison <dandavis= on7@gmail.com> wrote:
Here is the patch pasted into the body of an email:

From 8e69b33a53ea30389a5e3946dd711320a77e0d23 Mon Sep 17 00:00:= 00 2001
From: Dan Davison <dandavison7@gmail.com>
Date: Fri, = 5 Aug 2016 12:19:20 -0700
Subject: [PATCH] Don't strip space = from python completions

The returned completion de= liberately includes a space after a word like
'import', w= hich is always followed by more words.

* lisp/prog= modes/python.el (python-shell-completion-native-get-completions):
Remove space from regular expression character class
---
=C2=A0lisp/progmodes/python.el | 2 +-
=C2=A01 file changed, 1 = insertion(+), 1 deletion(-)

diff --git a/lisp/prog= modes/python.el b/lisp/progmodes/python.el
index ad69f87..8616279= 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progm= odes/python.el
@@ -3551,7 +3551,7 @@ completion."
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (split-strin= g
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(buffer-substring-no-properties
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (line-beginning-position) (point= -min))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0"[ \f\t\n\r\v()]+" t)
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"[\f\t\n\r\v()]+" t)
<= div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :test #&= #39;string=3D))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(set-process-= filter process original-filter-fn)))))
=C2=A0
--=C2=A0
2.3.2 (Apple Git-55)
=

On Sa= t, 27 Aug 2016 at 14:21 Dan Davison <dandavison7@gmail.com> wrote:
Patch attached.

This patch is also available as a pull request at at=C2=A0https://github.c= om/dandavison/emacs/pull/1=C2=A0The commit hash is=C2=A08e69b33a53ea303= 89a5e3946dd711320a77e0d23.

I have only tested this= on macOS. As far as I am aware, when the space character is present, it is= present deliberately and it is appropriate to retain it, but I would appre= ciate feedback from python.el experts.

On Sat, 27 Aug 2016 at 14:10 Dan Davison <dandavison7@gmail.com> wrote:



In the python comint buffer insert "from itertools imp" = and hit tab.

You will see "imp" complete= d as "import" (no trailing space).

Howev= er, if you do this in ipython itself, you will see "imp" complete= d
as "import ". This (i.e. what ipython does) is the de= sired behavior
(because import is always followed by another word= ).

In GNU Emacs 25.1.50.1 (x86_64-apple-darwin14.5= .0, NS appkit-1348.17 Version 10.10.5 (Build 14F27))
=C2=A0of 201= 6-04-16 built on hemiprocne
Repository revision: 934549e23d6bda52= 31375dbfed7b42a966c85d14
Windowing system distributor 'Apple&= #39;, version 10.3.1348
Configured using:
=C2=A0'co= nfigure --prefix=3D/usr/local/Cellar/emacs/HEAD
=C2=A0--enable-lo= callisppath=3D/usr/local/share/emacs/site-lisp
=C2=A0--infodir=3D= /usr/local/Cellar/emacs/HEAD/share/info/emacs --with-xml2
=C2=A0-= -without-dbus --without-gnutls --with-ns --disable-ns-self-contained'

Configured features:
JPEG NOTIFY ACL LIBX= ML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings= :
=C2=A0 value of $LANG: en_US.UTF-8
=C2=A0 locale-codi= ng-system: utf-8-unix

Major mode: Lisp Interaction=

Minor modes in effect:
=C2=A0 tooltip-m= ode: t
=C2=A0 global-eldoc-mode: t
=C2=A0 electric-inde= nt-mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-m= ode: t
=C2=A0 menu-bar-mode: t
=C2=A0 file-name-shadow-= mode: t
=C2=A0 global-font-lock-mode: t
=C2=A0 font-loc= k-mode: t
=C2=A0 blink-cursor-mode: t
=C2=A0 auto-compo= sition-mode: t
=C2=A0 auto-encryption-mode: t
=C2=A0 au= to-compression-mode: t
=C2=A0 line-number-mode: t
=C2= =A0 transient-mark-mode: t

Recent messages:
<= div>For information about GNU Emacs and the GNU system, type C-h C-a.
=

Load-path shadows:
None found.

=
Features:
(shadow sort mail-extr emacsbug message dire= d dired-loaddefs format-spec
rfc822 mml easymenu mml-sec password= -cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs = mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-u= tils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-= prsvr mail-utils time-date mule-util tooltip
eldoc electric uniqu= ify ediff-hook vc-hooks lisp-float-type mwheel
term/ns-win ns-win= ucs-normalize term/common-win tool-bar dnd fontset
image regexp-= opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mo= de register page menu-bar rfn-eshadow timer select scroll-bar
mou= se jit-lock font-lock syntax facemenu font-core term/tty-colors frame
=
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai<= /div>
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romani= an
slovak czech european ethiopic indian cyrillic chinese charscr= ipt
case-table epa-hook jka-cmpr-hook help simple abbrev obarray = minibuffer
cl-preloaded nadvice loaddefs button faces cus-face ma= croexp files
text-properties overlay sha1 md5 base64 format env c= ode-pages mule
custom widget hashtable-print-readable backquote k= queue cocoa ns
multi-tty make-network-process emacs)
Memory information:
((conses 16 195970 9329)
=C2=A0(symbols 48 19431 0)
=C2=A0(miscs 40 43 170)
= =C2=A0(strings 32 14792 5110)
=C2=A0(string-bytes 1 431078)
=
=C2=A0(vectors 16 32763)
=C2=A0(vector-slots 8 640839 4764)<= /div>
=C2=A0(floats 8 156 54)
=C2=A0(intervals 56 194 0)
=C2=A0(buffers 976 11))

=
--001a114aae5e282572053b159288--