unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work
       [not found] <87iq0dhwwd.fsf@neo.paramonovs>
@ 2010-11-04 17:11 ` Андрей Парамонов
  2010-11-12 20:08   ` bug#7329: [Patch] Enable completion in inferior-python-mode Андрей Парамонов
  2012-07-28 14:23   ` bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work Chong Yidong
  0 siblings, 2 replies; 18+ messages in thread
From: Андрей Парамонов @ 2010-11-04 17:11 UTC (permalink / raw)
  To: 7329

---------- Forwarded message ----------
From: Andrey Paramonov <pent@aparamon.msk.ru>
Date: 2010/11/4
Subject: 23.2; inferior-python-mode: completion does not work
To: bug-gnu-emacs@gnu.org
Копия: Andrey Paramonov <cmr.pent@gmail.com>


Hello!

M-Tab completion works for me in python-mode but not in
inferior-python-mode. Please implement M-Tab completion for
inferior-python-mode (it should be easy given it works for python-mode).

I'm ready to provide any additional info,
Andrey Paramonov

In GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0)
 of 2010-08-15 on raven, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure  '--build' 'i486-linux-gnu' '--build'
'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var/lib'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim'
'--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g'
'CPPFLAGS=''

Important settings:
 value of $LC_ALL: nil
 value of $LC_COLLATE: nil
 value of $LC_CTYPE: nil
 value of $LC_MESSAGES: nil
 value of $LC_MONETARY: nil
 value of $LC_NUMERIC: nil
 value of $LC_TIME: nil
 value of $LANG: ru_RU.UTF-8
 value of $XMODIFIERS: nil
 locale-coding-system: utf-8-unix
 default enable-multibyte-characters: t

Major mode: Inferior Python

Minor modes in effect:
 diff-auto-refine-mode: t
 delete-selection-mode: t
 show-paren-mode: t
 pc-selection-mode: t
 compilation-shell-minor-mode: t
 shell-dirtrack-mode: t
 pretty-control-l-mode: t
 tooltip-mode: t
 mouse-wheel-mode: t
 menu-bar-mode: t
 file-name-shadow-mode: t
 global-font-lock-mode: t
 font-lock-mode: t
 auto-encryption-mode: t
 auto-compression-mode: t
 column-number-mode: t
 line-number-mode: t
 global-visual-line-mode: t
 visual-line-mode: t
 transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/23.2/site-lisp/auctex/tex-style hides
/usr/share/emacs/site-lisp/auctex/tex-style
/usr/share/emacs/23.2/site-lisp/auctex/tex-font hides
/usr/share/emacs/site-lisp/auctex/tex-font
/usr/share/emacs/23.2/site-lisp/auctex/bib-cite hides
/usr/share/emacs/site-lisp/auctex/bib-cite
/usr/share/emacs/23.2/site-lisp/auctex/tex-buf hides
/usr/share/emacs/site-lisp/auctex/tex-buf
/usr/share/emacs/23.2/site-lisp/auctex/context-nl hides
/usr/share/emacs/site-lisp/auctex/context-nl
/usr/share/emacs/23.2/site-lisp/auctex/tex-info hides
/usr/share/emacs/site-lisp/auctex/tex-info
/usr/share/emacs/23.2/site-lisp/auctex/tex hides
/usr/share/emacs/site-lisp/auctex/tex
/usr/share/emacs/23.2/site-lisp/auctex/font-latex hides
/usr/share/emacs/site-lisp/auctex/font-latex
/usr/share/emacs/23.2/site-lisp/auctex/context hides
/usr/share/emacs/site-lisp/auctex/context
/usr/share/emacs/23.2/site-lisp/auctex/tex-fptex hides
/usr/share/emacs/site-lisp/auctex/tex-fptex
/usr/share/emacs/23.2/site-lisp/auctex/context-en hides
/usr/share/emacs/site-lisp/auctex/context-en
/usr/share/emacs/23.2/site-lisp/auctex/latex hides
/usr/share/emacs/site-lisp/auctex/latex
/usr/share/emacs/23.2/site-lisp/auctex/tex-fold hides
/usr/share/emacs/site-lisp/auctex/tex-fold
/usr/share/emacs/23.2/site-lisp/auctex/tex-jp hides
/usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs/23.2/site-lisp/auctex/multi-prompt hides
/usr/share/emacs/site-lisp/auctex/multi-prompt
/usr/share/emacs/23.2/site-lisp/auctex/texmathp hides
/usr/share/emacs/site-lisp/auctex/texmathp
/usr/share/emacs/23.2/site-lisp/auctex/tex-bar hides
/usr/share/emacs/site-lisp/auctex/tex-bar
/usr/share/emacs/23.2/site-lisp/auctex/tex-mik hides
/usr/share/emacs/site-lisp/auctex/tex-mik
/usr/share/emacs/23.2/site-lisp/auctex/toolbar-x hides
/usr/share/emacs/site-lisp/auctex/toolbar-x
/usr/share/emacs/23.2/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs23/site-lisp/flim/md4 hides /usr/share/emacs/23.2/lisp/md4
/usr/share/emacs23/site-lisp/flim/hex-util hides
/usr/share/emacs/23.2/lisp/hex-util
/usr/share/emacs23/site-lisp/flim/sha1 hides /usr/share/emacs/23.2/lisp/sha1
/usr/share/emacs23/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/23.2/lisp/textmodes/flyspell
/usr/share/emacs23/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/23.2/lisp/textmodes/ispell
/usr/share/emacs23/site-lisp/flim/ntlm hides /usr/share/emacs/23.2/lisp/net/ntlm
/usr/share/emacs23/site-lisp/flim/sasl-cram hides
/usr/share/emacs/23.2/lisp/net/sasl-cram
/usr/share/emacs23/site-lisp/flim/sasl hides /usr/share/emacs/23.2/lisp/net/sasl
/usr/share/emacs23/site-lisp/flim/sasl-ntlm hides
/usr/share/emacs/23.2/lisp/net/sasl-ntlm
/usr/share/emacs23/site-lisp/flim/sasl-digest hides
/usr/share/emacs/23.2/lisp/net/sasl-digest
/usr/share/emacs23/site-lisp/flim/hmac-md5 hides
/usr/share/emacs/23.2/lisp/net/hmac-md5
/usr/share/emacs23/site-lisp/flim/hmac-def hides
/usr/share/emacs/23.2/lisp/net/hmac-def

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev gmm-utils mailheader canlock
sha1 sha1-el hex-util hashcash emacsbug semantic/find gud semantic/edit
etags semantic/db-file cedet-files semantic/wisent/python
semantic/decorate/include semantic/db-find semantic/db-ref
semantic/decorate/mode semantic/decorate pulse semantic/dep
semantic/wisent/python-wy semantic/wisent semantic/wisent/wisent
semantic/db-mode semantic/db eieio-base semantic/idle semantic/format
ezimage semantic/tag-ls semantic/ctxt semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw eieio byte-opt bytecomp
byte-compile mode-local cedet vc-dispatcher vc-svn python-21 python psvn
derived edmacro kmacro cl cl-19 log-edit pcvs-util add-log diff-mode pp
elp ediff-merg ediff-diff ediff-wind ediff-mult ediff-help ediff-init
ediff-util dired help-mode view tmm electric server ropemacs pymacs
advice help-fns advice-preload ibuf-ext ibuffer delsel disp-table paren
pc-select gnus gnus-ems nnheader gnus-util netrc time-date mail-utils
mm-util mail-prsvr wid-edit cus-start cus-load pp-c-l debian-el
debian-el-loaddefs w3m-load compile ess-toolbar ess-mouse mouseme
thingatpt browse-url ess-menu ess-swv ess-noweb noweb-font-lock-mode
ess-bugs-l essd-els ess-sas-d ess-sas-l ess-sas-a executable shell
ess-arc-d ess-vst-d ess-xls-d ess-lsp-l ess-sta-d ess-sta-l cc-vars
cc-defs make-regexp ess-sp6-d ess-sp5-d ess-sp3-d ess-r-d ess-r-args
assoc ess-s-l ess-inf ess-utils comint ring ess-mode noweb-mode ess
ess-custom regexp-opt easymenu ess-compat ess-site emacs-goodies-el
emacs-goodies-custom emacs-goodies-loaddefs easy-mmode preview-latex
tex-site auto-loads cyril-util tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-04 17:11 ` bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work Андрей Парамонов
@ 2010-11-12 20:08   ` Андрей Парамонов
  2010-11-12 21:35     ` Stefan Monnier
  2012-07-28 14:23   ` bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work Chong Yidong
  1 sibling, 1 reply; 18+ messages in thread
From: Андрей Парамонов @ 2010-11-12 20:08 UTC (permalink / raw)
  To: 7329; +Cc: fx

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]

Hello!

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

[-- Attachment #2: inferior-python-completion.patch --]
[-- Type: text/x-diff, Size: 1012 bytes --]

--- /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)))))
 
 ;; Fixme:  Is there anything reasonable we can do with random methods?
 ;; (Currently only works with functions.)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-12 20:08   ` bug#7329: [Patch] Enable completion in inferior-python-mode Андрей Парамонов
@ 2010-11-12 21:35     ` Stefan Monnier
  2010-11-16  8:41       ` Андрей Парамонов
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2010-11-12 21:35 UTC (permalink / raw)
  To: Андрей Парамонов
  Cc: fx, 7329

> 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





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-12 21:35     ` Stefan Monnier
@ 2010-11-16  8:41       ` Андрей Парамонов
  2010-11-16  8:43         ` Андрей Парамонов
  2010-11-17 13:14         ` Stefan Monnier
  0 siblings, 2 replies; 18+ messages in thread
From: Андрей Парамонов @ 2010-11-16  8:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: fx, 7329

2010/11/13 Stefan Monnier <monnier@iro.umontreal.ca>:
> 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.

The text between >>> and point is what I'm going to complete. I think
it can be anything.

> E.g. maybe we should use
> (re-search-backward "^>>> " (line-beginning-position) t)

Good idea. I missed that re-search-backward jumps over linebreaks by
default. Thinking a bit more, (re-search-backward "^\(>>>|...\) "
(line-beginning-position) t) is even better as it allows completion
inside loops.

> 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.
>

My understanding about these checks is to avoid interacting with
interpreter while we at something like

while True:
    pass

or just doing a long processing. For completion we are using the same
interpreter. Requesting completion would freeze Emacs in such a case.

Thanks for your support,
Andrey Paramonov





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-16  8:41       ` Андрей Парамонов
@ 2010-11-16  8:43         ` Андрей Парамонов
  2010-11-17 13:14         ` Stefan Monnier
  1 sibling, 0 replies; 18+ messages in thread
From: Андрей Парамонов @ 2010-11-16  8:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: fx, 7329

2010/11/16 Андрей Парамонов <cmr.pent@gmail.com>:
> (re-search-backward "^\(>>>|...\) " (line-beginning-position) t)

Should be (re-search-backward "^\(>>>|\.\.\.\) " (line-beginning-position) t)

Andrey Paramonov





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-16  8:41       ` Андрей Парамонов
  2010-11-16  8:43         ` Андрей Парамонов
@ 2010-11-17 13:14         ` Stefan Monnier
  2010-11-19 20:33           ` Андрей Парамонов
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2010-11-17 13:14 UTC (permalink / raw)
  To: Андрей Парамонов
  Cc: fx, 7329

>> 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.

> The text between >>> and point is what I'm going to complete. I think
> it can be anything.

Then maybe another fix is to add a

  (save-excursion
    (goto-char (process-mark (or proc (python-proc))))
    ...)

Since this goto-char should then move point right after the prompt, just
where the current code expects it to be.
    

        Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-17 13:14         ` Stefan Monnier
@ 2010-11-19 20:33           ` Андрей Парамонов
  2010-11-28 16:14             ` Dave Love
  0 siblings, 1 reply; 18+ messages in thread
From: Андрей Парамонов @ 2010-11-19 20:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: fx, 7329

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

Updated version of the patch attached. It does the following:

1) Enables completion in inferior Python mode.

2) Enables describe-symbol in inferior Python mode.

3) Checks for interpreter more intelligently.

Also it works with 23.2.

Andrey Paramonov

[-- Attachment #2: inferior-python-completion.patch --]
[-- Type: text/x-diff, Size: 5139 bytes --]

--- /home/pent/python.el.orig	2010-11-12 21:55:47.000000000 +0300
+++ /home/pent/python.el	2010-11-19 23:20:14.000000000 +0300
@@ -1365,13 +1365,9 @@
     ;; This will inherit from comint-mode-map.
     (define-key map "\C-c\C-l" 'python-load-file)
     (define-key map "\C-c\C-v" 'python-check)
-    ;; Note that we _can_ still use these commands which send to the
-    ;; Python process even at the prompt iff we have a normal prompt,
-    ;; i.e. '>>> ' and not '... '.  See the comment before
-    ;; python-send-region.  Fixme: uncomment these if we address that.
-
-    ;; (define-key map [(meta ?\t)] 'python-complete-symbol)
-    ;; (define-key map "\C-c\C-f" 'python-describe-symbol)
+    (substitute-key-definition 'complete-symbol 'completion-at-point
+			       map global-map)
+    (define-key map "\C-c\C-f" 'python-describe-symbol)
     map))
 
 (defvar inferior-python-mode-syntax-table
@@ -1412,6 +1408,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)
@@ -1771,50 +1769,51 @@
 			    (format "Describe symbol (default %s): " symbol)
 			  "Describe symbol: ")
 			nil nil symbol))))
-  (if (equal symbol "") (error "No symbol"))
-  ;; Ensure we have a suitable help buffer.
-  ;; Fixme: Maybe process `Related help topics' a la help xrefs and
-  ;; allow C-c C-f in help buffer.
-  (let ((temp-buffer-show-hook		; avoid xref stuff
-	 (lambda ()
-	   (toggle-read-only 1)
-	   (setq view-return-to-alist
-		 (list (cons (selected-window) help-return-method))))))
-    (with-output-to-temp-buffer (help-buffer)
-      (with-current-buffer standard-output
- 	;; Fixme: Is this actually useful?
-	(help-setup-xref (list 'python-describe-symbol symbol)
-			 (called-interactively-p 'interactive))
-	(set (make-local-variable 'comint-redirect-subvert-readonly) t)
-	(help-print-return-message))))
-  (comint-redirect-send-command-to-process (format "emacs.ehelp(%S, %s)"
-						   symbol python-imports)
-   "*Help*" (python-proc) nil nil))
-
-(add-to-list 'debug-ignored-errors "^No symbol")
+  (when (python-check-comint-prompt)
+    (if (equal symbol "") (error "No symbol"))
+    ;; Ensure we have a suitable help buffer.
+    ;; Fixme: Maybe process `Related help topics' a la help xrefs and
+    ;; allow C-c C-f in help buffer.
+    (let ((temp-buffer-show-hook		; avoid xref stuff
+	   (lambda ()
+	     (toggle-read-only 1)
+	     (setq view-return-to-alist
+		   (list (cons (selected-window) help-return-method))))))
+      (with-output-to-temp-buffer (help-buffer)
+	(with-current-buffer standard-output
+	  ;; Fixme: Is this actually useful?
+	  (help-setup-xref (list 'python-describe-symbol symbol)
+			   (called-interactively-p 'interactive))
+	  (set (make-local-variable 'comint-redirect-subvert-readonly) t)
+	  (help-print-return-message))))
+    (comint-redirect-send-command-to-process 
+     (format "emacs.ehelp(%S, %s)" symbol python-imports) 
+     "*Help*" (python-proc) nil nil))
+  (add-to-list 'debug-ignored-errors "^No symbol"))
 
 (defun python-send-receive (string)
   "Send STRING to inferior Python (if any) and return result.
 The result is what follows `_emacs_out' in the output.
 This is a no-op if `python-check-comint-prompt' returns nil."
-  (python-send-string string)
-  (let ((proc (python-proc)))
-    (with-current-buffer (process-buffer proc)
-      (when (python-check-comint-prompt proc)
-	(set (make-local-variable 'python-preoutput-result) nil)
-	(while (progn
-		 (accept-process-output proc 5)
-		 (null python-preoutput-result)))
-	(prog1 python-preoutput-result
-	  (kill-local-variable 'python-preoutput-result))))))
+  (when (python-check-comint-prompt)
+    (python-send-string string)
+    (with-current-buffer (process-buffer (python-proc))
+      (set (make-local-variable 'python-preoutput-result) nil)
+      (while (progn
+	       (accept-process-output (python-proc) 5)
+	       (null python-preoutput-result)))
+      (prog1 python-preoutput-result
+	(kill-local-variable 'python-preoutput-result)))))
 
 (defun python-check-comint-prompt (&optional proc)
   "Return non-nil if and only if there's a normal prompt in the inferior buffer.
 If there isn't, it's probably not appropriate to send input to return Eldoc
 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)))))
+  (let ((process (or proc (python-proc))))
+    (with-current-buffer (process-buffer process)
+      (save-excursion
+	(goto-char (process-mark process))
+	(save-match-data (re-search-backward "^>>> \\=" nil t))))))
 
 ;; Fixme:  Is there anything reasonable we can do with random methods?
 ;; (Currently only works with functions.)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-19 20:33           ` Андрей Парамонов
@ 2010-11-28 16:14             ` Dave Love
  2012-04-11 11:31               ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 18+ messages in thread
From: Dave Love @ 2010-11-28 16:14 UTC (permalink / raw)
  To: Андрей Парамонов
  Cc: 7329@debbugs.gnu.org

Thanks for letting me know, but I can't do anything about problems with
the version in Emacs.  The one I maintain has the feature, without the
bugs people tell me about in the Emacs one.  (The communication would
probably be done better with a Python thread separate from the REPL, if
it reflected the REPL's environment, and in this case it would allow
completion in more contexts.)





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2010-11-28 16:14             ` Dave Love
@ 2012-04-11 11:31               ` Lars Magne Ingebrigtsen
  2012-04-11 11:47                 ` Андрей Парамонов
                                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-11 11:31 UTC (permalink / raw)
  To: Dave Love
  Cc: Андрей Парамонов,
	7329

Dave Love <fx@gnu.org> writes:

> Thanks for letting me know, but I can't do anything about problems with
> the version in Emacs.  The one I maintain has the feature, without the
> bugs people tell me about in the Emacs one.

Is there any particular reason why there's an out-of-tree version of
python.el that's newer than the in-tree version?  Would it be possible
to update the in-tree version?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2012-04-11 11:31               ` Lars Magne Ingebrigtsen
@ 2012-04-11 11:47                 ` Андрей Парамонов
  2012-04-11 11:59                   ` Lars Magne Ingebrigtsen
  2012-04-11 11:47                 ` Leo
  2012-04-11 16:26                 ` Glenn Morris
  2 siblings, 1 reply; 18+ messages in thread
From: Андрей Парамонов @ 2012-04-11 11:47 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: Dave Love, 7329

2012/4/11 Lars Magne Ingebrigtsen <larsi@gnus.org>:
> Is there any particular reason why there's an out-of-tree version of
> python.el that's newer than the in-tree version?  Would it be possible
> to update the in-tree version?

If I remember correctly there was strong desire to update in-tree
version with a set of step-by-step patches. However those patches do
not exist -- the two versions have different origins. To produce such
patchset is a separate hard task which no-one wants to undertake
(sadly for users).

Andrey





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2012-04-11 11:31               ` Lars Magne Ingebrigtsen
  2012-04-11 11:47                 ` Андрей Парамонов
@ 2012-04-11 11:47                 ` Leo
  2012-04-11 16:26                 ` Glenn Morris
  2 siblings, 0 replies; 18+ messages in thread
From: Leo @ 2012-04-11 11:47 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen
  Cc: Dave Love,
	Андрей Парамонов,
	7329

On 2012-04-11 19:31 +0800, Lars Magne Ingebrigtsen wrote:
> Dave Love <fx@gnu.org> writes:
>
>> Thanks for letting me know, but I can't do anything about problems with
>> the version in Emacs.  The one I maintain has the feature, without the
>> bugs people tell me about in the Emacs one.
>
> Is there any particular reason why there's an out-of-tree version of
> python.el that's newer than the in-tree version?  Would it be possible
> to update the in-tree version?

I would really like to see this happening. I wonder if anyone has tried
python.el + M-x pdb. It was close to unusable the last time (about a
month ago) I tried.

Leo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2012-04-11 11:47                 ` Андрей Парамонов
@ 2012-04-11 11:59                   ` Lars Magne Ingebrigtsen
  2012-04-11 12:08                     ` Андрей Парамонов
  0 siblings, 1 reply; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-11 11:59 UTC (permalink / raw)
  To: Андрей Парамонов
  Cc: Dave Love, 7329

Андрей Парамонов <cmr.pent@gmail.com> writes:

> If I remember correctly there was strong desire to update in-tree
> version with a set of step-by-step patches.

Was there any particular reason why?  It's not like Emacs requires (say)
the Org maintainers to apply changes in a patch-by-patch version, so I'm
not sure why the python.el maintainer should have to...

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2012-04-11 11:59                   ` Lars Magne Ingebrigtsen
@ 2012-04-11 12:08                     ` Андрей Парамонов
  0 siblings, 0 replies; 18+ messages in thread
From: Андрей Парамонов @ 2012-04-11 12:08 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: Dave Love, 7329

2012/4/11 Lars Magne Ingebrigtsen <larsi@gnus.org>:
> Was there any particular reason why?  It's not like Emacs requires (say)
> the Org maintainers to apply changes in a patch-by-patch version, so I'm
> not sure why the python.el maintainer should have to...

Please look up "Current state of python.el in the Emacs trunk" in emacs-devel.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: [Patch] Enable completion in inferior-python-mode
  2012-04-11 11:31               ` Lars Magne Ingebrigtsen
  2012-04-11 11:47                 ` Андрей Парамонов
  2012-04-11 11:47                 ` Leo
@ 2012-04-11 16:26                 ` Glenn Morris
  2 siblings, 0 replies; 18+ messages in thread
From: Glenn Morris @ 2012-04-11 16:26 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 7329

Lars Magne Ingebrigtsen wrote:

> Is there any particular reason why there's an out-of-tree version of
> python.el that's newer than the in-tree version?  Would it be possible
> to update the in-tree version?

Yes. No.

See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6573#13

for the brief answer; see emacs-devel history for the long version. It's
an unfortunate situation that isn't going to change, so it's probably
best to leave it alone.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work
  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 Андрей Парамонов
@ 2012-07-28 14:23   ` Chong Yidong
  2012-07-28 15:10     ` Андрей Парамонов
  1 sibling, 1 reply; 18+ messages in thread
From: Chong Yidong @ 2012-07-28 14:23 UTC (permalink / raw)
  To: Андрей Парамонов
  Cc: 7329

Андрей Парамонов <cmr.pent@gmail.com> writes:

> M-Tab completion works for me in python-mode but not in
> inferior-python-mode. Please implement M-Tab completion for
> inferior-python-mode (it should be easy given it works for python-mode).

In the version of python.el in the trunk, inferior-python-mode has TAB
completion.  Closing this bug.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work
  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
  0 siblings, 1 reply; 18+ messages in thread
From: Андрей Парамонов @ 2012-07-28 15:10 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 7329

2012/7/28 Chong Yidong <cyd@gnu.org>:
> Андрей Парамонов <cmr.pent@gmail.com> writes:
>
>> M-Tab completion works for me in python-mode but not in
>> inferior-python-mode. Please implement M-Tab completion for
>> inferior-python-mode (it should be easy given it works for python-mode).
>
> In the version of python.el in the trunk, inferior-python-mode has TAB
> completion.  Closing this bug.

Great, thank you! Did you use code by Fabio Ezequiel Gallina?

Best wishes,
Andrey Paramonov





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work
  2012-07-28 15:10     ` Андрей Парамонов
@ 2012-07-28 15:14       ` Chong Yidong
  2012-07-28 15:35         ` Андрей Парамонов
  0 siblings, 1 reply; 18+ messages in thread
From: Chong Yidong @ 2012-07-28 15:14 UTC (permalink / raw)
  To: Андрей Парамонов
  Cc: 7329

Андрей Парамонов <cmr.pent@gmail.com> writes:

> 2012/7/28 Chong Yidong <cyd@gnu.org>:
>> Андрей Парамонов <cmr.pent@gmail.com> writes:
>>
>>> M-Tab completion works for me in python-mode but not in
>>> inferior-python-mode. Please implement M-Tab completion for
>>> inferior-python-mode (it should be easy given it works for python-mode).
>>
>> In the version of python.el in the trunk, inferior-python-mode has TAB
>> completion.  Closing this bug.
>
> Great, thank you! Did you use code by Fabio Ezequiel Gallina?

Yes, his python.el will be the one in Emacs 24.2.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#7329: Fwd: 23.2; inferior-python-mode: completion does not work
  2012-07-28 15:14       ` Chong Yidong
@ 2012-07-28 15:35         ` Андрей Парамонов
  0 siblings, 0 replies; 18+ messages in thread
From: Андрей Парамонов @ 2012-07-28 15:35 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 7329

2012/7/28 Chong Yidong <cyd@gnu.org>:
> Андрей Парамонов <cmr.pent@gmail.com> writes:
>
>> 2012/7/28 Chong Yidong <cyd@gnu.org>:
>>> Андрей Парамонов <cmr.pent@gmail.com> writes:
>>>
>>>> M-Tab completion works for me in python-mode but not in
>>>> inferior-python-mode. Please implement M-Tab completion for
>>>> inferior-python-mode (it should be easy given it works for python-mode).
>>>
>>> In the version of python.el in the trunk, inferior-python-mode has TAB
>>> completion.  Closing this bug.
>>
>> Great, thank you! Did you use code by Fabio Ezequiel Gallina?
>
> Yes, his python.el will be the one in Emacs 24.2.

Awesome news!

Thank you for your great work,
Andrey Paramonov





^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-07-28 15:35 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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
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         ` Андрей Парамонов

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).