unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Андрей Парамонов" <cmr.pent@gmail.com>
Cc: fx@gnu.org, 7329@debbugs.gnu.org
Subject: bug#7329: [Patch] Enable completion in inferior-python-mode
Date: Fri, 12 Nov 2010 16:35:46 -0500	[thread overview]
Message-ID: <jwvy68yjknj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <AANLkTin8izchv00ti+pOi=7iA3uEnaGueD=ZqjTLnnaN@mail.gmail.com> ("Андрей Парамонов"'s message of "Fri, 12 Nov 2010 23:08:19 +0300")

> I've managed to enable completion in Python interpreter buffer, patch
> attached. The change in python-check-comint-prompt also fixes
> completion in Python buffer when prompt in interpreter buffer is not
> clear (a command is entered but not yet executed).

> I didn't notice any regressions yet, but maybe the "\\="-thingy was
> actually meaning something :-)  Please review my patch, I'm ready to
> improve it if needed.

> Best wishes,
> Andrey Paramonov
> --- /home/pent/python.el.orig	2010-11-12 21:55:47.000000000 +0300
> +++ /home/pent/python.el	2010-11-12 21:51:26.000000000 +0300
> @@ -1412,6 +1412,8 @@
>    (set (make-local-variable 'comint-input-filter) 'python-input-filter)
>    (add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter
>  	    nil t)
> +  (add-hook 'completion-at-point-functions
> +            'python-completion-at-point nil 'local)
>    ;; Still required by `comint-redirect-send-command', for instance
>    ;; (and we need to match things like `>>> ... >>> '):
>    (set (make-local-variable 'comint-prompt-regexp)
> @@ -1814,7 +1816,7 @@
>  information etc.  If PROC is non-nil, check the buffer for that process."
>    (with-current-buffer (process-buffer (or proc (python-proc)))
>      (save-excursion
> -      (save-match-data (re-search-backward ">>> \\=" nil t)))))
> +      (save-match-data (re-search-backward "^>>> " nil t)))))

That patch doesn't look bad at all.  The \\= construct means "match
point", i.e. (re-search-backward ">>> \\=" nil t) is very much like
(looking-back ">>> ").  So if that doesn't work it's probably because
there is text between the ">>> " prompt and point.
Do you happen to know what that text is, so we can assess whether we can
just plainly ignore it as you do, or whether there's more to it.
E.g. maybe we should use
(re-search-backward "^>>> " (line-beginning-position) t)
so that we won't be searching back for umpteen megabytes of output until
we accidentally find some unrelated prompt.
Then again, maybe the issue is simply that since we're always in the
process-buffer in the first place, point is not at the expected place
(the code currently expects point to stay put right after the prompt,
whereas in the inferior-python case point may have simply been pushed
down by the process's output), in which case the right solution may be
to explicitly store the earlier position of point and don't expect that
(with-current-buffer (process-buffer (or proc (python-proc))) will
automatically place us back at the same position.


        Stefan





  reply	other threads:[~2010-11-12 21:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87iq0dhwwd.fsf@neo.paramonovs>
2010-11-04 17:11 ` bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work Андрей Парамонов
2010-11-12 20:08   ` bug#7329: [Patch] Enable completion in inferior-python-mode Андрей Парамонов
2010-11-12 21:35     ` Stefan Monnier [this message]
2010-11-16  8:41       ` Андрей Парамонов
2010-11-16  8:43         ` Андрей Парамонов
2010-11-17 13:14         ` Stefan Monnier
2010-11-19 20:33           ` Андрей Парамонов
2010-11-28 16:14             ` Dave Love
2012-04-11 11:31               ` Lars Magne Ingebrigtsen
2012-04-11 11:47                 ` Андрей Парамонов
2012-04-11 11:59                   ` Lars Magne Ingebrigtsen
2012-04-11 12:08                     ` Андрей Парамонов
2012-04-11 11:47                 ` Leo
2012-04-11 16:26                 ` Glenn Morris
2012-07-28 14:23   ` bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work Chong Yidong
2012-07-28 15:10     ` Андрей Парамонов
2012-07-28 15:14       ` Chong Yidong
2012-07-28 15:35         ` Андрей Парамонов

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy68yjknj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=7329@debbugs.gnu.org \
    --cc=cmr.pent@gmail.com \
    --cc=fx@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).