all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Glenn Morris <rgm@gnu.org>
Cc: Evgeniy Sharapov <evgeniy.sharapov@gmail.com>, 28051@debbugs.gnu.org
Subject: bug#28051: Multiline Statement Indentation Error in Inferior Python Mode
Date: Mon, 21 Aug 2017 08:17:41 -0400	[thread overview]
Message-ID: <87shglazdm.fsf@users.sourceforge.net> (raw)
In-Reply-To: <87y3qlzoom.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Mon, 14 Aug 2017 19:59:05 -0400")

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

tags 28051 + patch
quit

npostavs@users.sourceforge.net writes:

> I can reproduce this on Windows.  And on GNU/Linux after doing (setq
> python-shell-completion-native-enable nil).  Perhaps this is one of the
> "limitations" referred to in the comments of python.el:
>
>     ;; ...the "fallback" or "legacy" mechanism works by executing Python
>     ;; code in the background and enables auto-completion for shells
>     ;; that do not support receiving escape sequences (with some
>     ;; limitations, i.e. completion in blocks does not work).

I think the best we can do is disable completion with an error message
when the prompt is "...", see attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3155 bytes --]

From 20693abb64a342255a076645b758590373308a52 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 19 Aug 2017 11:45:07 -0400
Subject: [PATCH] Disable completion while entering python multiline statements

The "legacy" completion mechanism sends newlines to the running python
process to get the list of completions, which confuses things if the
user is in the middle of entering a multiline statement (Bug#28051).
It's better to disable completion in this case.
* lisp/progmodes/python.el (python-shell--block-prompt): New variable.
(python-shell-prompt-set-calculated-regexps): Set it.
(python-shell-completion-at-point): Bail out with error message if
current prompt is a block prompt.
---
 lisp/progmodes/python.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index b8f8ed2a06..897ee856a5 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2212,6 +2212,11 @@ python-shell--prompt-calculated-input-regexp
 Do not set this variable directly, instead use
 `python-shell-prompt-set-calculated-regexps'.")
 
+(defvar python-shell--block-prompt nil
+  "Input block prompt for inferior python shell.
+Do not set this variable directly, instead use
+`python-shell-prompt-set-calculated-regexps'.")
+
 (defvar python-shell--prompt-calculated-output-regexp nil
   "Calculated output prompt regexp for inferior python shell.
 Do not set this variable directly, instead use
@@ -2366,6 +2371,7 @@ python-shell-prompt-set-calculated-regexps
         (dolist (prompt (butlast detected-prompts))
           (setq prompt (regexp-quote prompt))
           (cl-pushnew prompt input-prompts :test #'string=))
+        (setq python-shell--block-prompt (nth 1 detected-prompts))
         (cl-pushnew (regexp-quote
                      (car (last detected-prompts)))
                     output-prompts :test #'string=))
@@ -2726,6 +2732,7 @@ inferior-python-mode
   (set (make-local-variable 'python-shell-interpreter-args)
        (or python-shell--interpreter-args python-shell-interpreter-args))
   (set (make-local-variable 'python-shell--prompt-calculated-input-regexp) nil)
+  (set (make-local-variable 'python-shell--block-prompt) nil)
   (set (make-local-variable 'python-shell--prompt-calculated-output-regexp) nil)
   (python-shell-prompt-set-calculated-regexps)
   (setq comint-prompt-regexp python-shell--prompt-calculated-input-regexp)
@@ -3632,7 +3639,9 @@ python-shell-completion-at-point
                        ;; Also, since pdb interaction is single-line
                        ;; based, this is enough.
                        (string-match-p python-shell-prompt-pdb-regexp prompt))
-                   #'python-shell-completion-get-completions)
+                   (if (equal python-shell--block-prompt prompt)
+                       (user-error "Cannot use standard completion in multiline statement")
+                     #'python-shell-completion-get-completions))
                   (t #'python-shell-completion-native-get-completions)))))
     (list start end
           (completion-table-dynamic
-- 
2.14.1


  reply	other threads:[~2017-08-21 12:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 17:24 bug#28051: 25.2; Multiline Statement Indentation Error in Inferior Python Mode evgeniy.sharapov
2017-08-11 18:19 ` bug#28051: " Evgeniy Sharapov
2017-08-12 17:50   ` Glenn Morris
2017-08-14 23:59     ` npostavs
2017-08-21 12:17       ` npostavs [this message]
2017-08-22  1:36         ` npostavs
2017-08-27 16:42           ` Dmitry Gutov
2017-08-27 18:28             ` npostavs
2017-08-19 14:45 ` bug#28051: 25.2; " npostavs
2017-08-25  2:50   ` Evgeniy Sharapov
2017-08-25 12:20     ` 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=87shglazdm.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=28051@debbugs.gnu.org \
    --cc=evgeniy.sharapov@gmail.com \
    --cc=rgm@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.