From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#28051: Multiline Statement Indentation Error in Inferior Python Mode Date: Mon, 21 Aug 2017 08:17:41 -0400 Message-ID: <87shglazdm.fsf@users.sourceforge.net> References: <56pwp6ayq3x.fsf@nn-esharapov-04.i-did-not-set--mail-host-address--so-tickle-me> <5wshgwfzfe.fsf@fencepost.gnu.org> <87y3qlzoom.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1503317838 27747 195.159.176.226 (21 Aug 2017 12:17:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 21 Aug 2017 12:17:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: Evgeniy Sharapov , 28051@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 21 14:17:14 2017 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 1djldi-0006fr-Pd for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Aug 2017 14:17:06 +0200 Original-Received: from localhost ([::1]:39639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djldp-0003Ck-A4 for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Aug 2017 08:17:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djldj-0003B2-CZ for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 08:17:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djldg-00018n-18 for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 08:17:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1djldf-00018j-Sf for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 08:17:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1djldd-0003K4-Rs for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 08:17:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Aug 2017 12:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28051 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 28051-submit@debbugs.gnu.org id=B28051.150331777212712 (code B ref 28051); Mon, 21 Aug 2017 12:17:01 +0000 Original-Received: (at 28051) by debbugs.gnu.org; 21 Aug 2017 12:16:12 +0000 Original-Received: from localhost ([127.0.0.1]:47378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djlcp-0003It-KK for submit@debbugs.gnu.org; Mon, 21 Aug 2017 08:16:11 -0400 Original-Received: from mail-it0-f44.google.com ([209.85.214.44]:36001) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djlcn-0003Ic-TB; Mon, 21 Aug 2017 08:16:10 -0400 Original-Received: by mail-it0-f44.google.com with SMTP id 77so31021533itj.1; Mon, 21 Aug 2017 05:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=lw5+p9OskprVx8O+hpHeVG2pCanMgfs26+8W71tscXM=; b=LDixZsoHh733YmItC6RwSAl45ZtPrT0GCbc5N09rzrhVujDAhhf/SfobY4H/qK9fjA idmrAQzgSDawqdClnsju9ObozijI3Ct4W9g9J311VuiVtgsKnuBZrXKTYCjz+YRNv8vl DQHDucK0iQt0CVE1p3UvvN7WGv0sEIXTEe8Y9I/rz5WB54dJB/y0ZNPAA9136VuMXb1t OBOl80vEL1Kp1GPF/j+RRmbhaMbvUyZ43OgUVlHf465O5BbzR5NghjUJSKj+jBElUsfQ 6M/tzDUfvRQvM5mxLIwTnIzKA6ASEH3vfHGPyyn0HZSVsPOOEg8KNe7h5lhy7SJFFLeM g6eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=lw5+p9OskprVx8O+hpHeVG2pCanMgfs26+8W71tscXM=; b=J6RTOuzSLXtaDiJJJZm8TR6gA1wFa+/DVQ6ghj9aKkt69liefIZt25teZwnc29QRRZ DKBADb6OtukkszOVza+6mglqL4jmZSPH9TjP4kc7k6mqJz7QwmgbfbYPbKH4Lo27cJTb OkOalRZYBulej1VwIKPokN8BN9YyE988YBnV43I8R/5zr0XBOfhNgNloUVGaWeO+1WHy /qwyqGsP8kWc3yL7uVO23KT/ng9zdleouQgpK5JlQnQtVGq0rEvHY3jTTUH25JYc7l+V nfuKV2uFH6OcKRRiPvEiTmjwRKTzmA4yRcrgCjtC/vqzozV+ILZwYS9jZ/HmCMQ4YqcQ D4Cw== X-Gm-Message-State: AHYfb5hPqGVnXwnsiWJM68R7LwtcJfZ5EmLJglSctd3O03d8XBxMNf3P K1ZiIreZUXSlWSyJ X-Received: by 10.36.51.2 with SMTP id k2mr5891417itk.155.1503317764118; Mon, 21 Aug 2017 05:16:04 -0700 (PDT) Original-Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id g75sm77197ita.4.2017.08.21.05.16.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2017 05:16:02 -0700 (PDT) In-Reply-To: <87y3qlzoom.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Mon, 14 Aug 2017 19:59:05 -0400") 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:135987 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Disable-completion-while-entering-python-multiline-s.patch Content-Description: patch >From 20693abb64a342255a076645b758590373308a52 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-=--