From unknown Sun Aug 17 10:17:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#58441: 29.0.50; Python completion fails when point in shell buffer is before the last prompt Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Oct 2022 15:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58441 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 58441@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166550047831064 (code B ref -1); Tue, 11 Oct 2022 15:02:02 +0000 Received: (at submit) by debbugs.gnu.org; 11 Oct 2022 15:01:18 +0000 Received: from localhost ([127.0.0.1]:54612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiGkv-00084x-Fg for submit@debbugs.gnu.org; Tue, 11 Oct 2022 11:01:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:42216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiGkt-00084q-UG for submit@debbugs.gnu.org; Tue, 11 Oct 2022 11:01:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiGko-0002uu-NX for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 11:01:13 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:36449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiGkk-0007BW-EO for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 11:01:10 -0400 Received: by mail-pj1-x102b.google.com with SMTP id d7-20020a17090a2a4700b0020d268b1f02so6860389pjg.1 for ; Tue, 11 Oct 2022 08:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:subject:to:from:message-id:date:from:to:cc :subject:date:message-id:reply-to; bh=wionp8D4J+CFEX/J4JGM+zcad3Y27ND5YtmBKSAAlz4=; b=EARUVUDKigeDuYnGXdTcFZubISZkN5svvjWXL1d4OMx69sm2iLt13ld1yIbmTiXC+i luzyx+oZ2eQJj6JHSCEviSjTN51BaDlYNHde6WoVHpUntFoQu1xTfWyzH57KJNg+wCMQ hyMLXTeyo6Lj1GkDuYXXidkZk5XTd5G61LKIBRopZ4/aIFWTmu2MVhntDGQP/7Rbmz8P prd21Ksc3faSaj+TIAvSNk2ZP9Yn3V0FaD/q9FImpt+bMZILsE5FfV1YETMHxIrHCghP blcKCQxz0sPruglvmDQForUPTR7tjqJ+DMrToc2oaysKHHmAF+ZqasSMqnWCMZlxtm6o HuRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:subject:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wionp8D4J+CFEX/J4JGM+zcad3Y27ND5YtmBKSAAlz4=; b=zuX8wdfY/SCH/FT9uNmIpzM2c6uau08Ouyrv2lX5jQy308FqJ0fvYufKI+FCUF0uys DwQQoQgHDIVeH8YBEpn85ECHmIMaWcniHC8zu5M4vzdfVSrmtVqVAkPmJMRFSsDsvQhp jb0nmWRWD4/kMVskL5kYcsK7B+od2hC65NTjk8GMV/ckAKnt2/VQQb0b0r6Qz1ga9hnU c5x6/CsDO9idlTbA8KnhwfP4bkNoPQiTS0J7NuhAbvMvuqmUZvFcVSDGtT9xvW11FAA0 N4aXrvrTX6YCYj4ud/NgCPG8NXffjSut6miHj105eEbDtotRoh2pWmzUav2iorXXyMuW 7FHw== X-Gm-Message-State: ACrzQf00+9+C0mOC3DUfPXmM5cgiPrQwWVWjGvUJAGhbGLz5pJX/Xvz7 UkquDxPp4IGmuOQoo5XslSgv1D+PSg0= X-Google-Smtp-Source: AMsMyM7nu+GIq8XtZcChC/Inb7r8NZ9tdYzoAv8aqsnP09qRhmWS/wU3c1C7yC5yxusEpILQKAAZmg== X-Received: by 2002:a17:902:e5c3:b0:176:d1b9:ee33 with SMTP id u3-20020a170902e5c300b00176d1b9ee33mr24574634plf.122.1665500462098; Tue, 11 Oct 2022 08:01:02 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id b83-20020a621b56000000b0056389e00a83sm3292007pfb.63.2022.10.11.08.00.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:01:00 -0700 (PDT) Date: Wed, 12 Oct 2022 00:00:57 +0900 Message-ID: From: kobarity User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Wed_Oct_12_00:00:57_2022-1" Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=kobarity@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --Multipart_Wed_Oct_12_00:00:57_2022-1 Content-Type: text/plain; charset=US-ASCII Hi, Completion in Python mode buffer fails when the point in Python shell buffer is before the last prompt: 1. emacs -Q 2. Open the following Python file. #+begin_src python import sys #+end_src 3. C-u -1 M-x eldoc-mode (Disable ElDoc mode. This step can be skipped if the fix for #58389 is applied.) 4. C-c C-p (M-x run-python) 5. M-< (M-x beginning-of-buffer) 6. C-x o (Back to the Python mode buffer) 7. C-c C-c (M-x python-shell-send-buffer) 8. C-n (M-x next-line) 9. Type "sys." 10. C-M-i (M-x completion-at-point) 11. "No match" is shown in the minibuffer. In `python-shell-completion-at-point', current point in the shell buffer is checked if it is after the last prompt. However, I think there is no reason to do this check when `python-shell-completion-at-point' is used to complete in Python mode buffer (not Inferior Python Shell buffer). Attached is a patch to fix this issue. Best Regards, -- In GNU Emacs 29.0.50 (build 5, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2022-10-09 built on ubuntu Repository revision: 9d47364634f96b2f2651a7f3942f8f87b920f02d Repository branch: master System Description: Ubuntu 22.04.1 LTS Configured using: 'configure --without-libgmp' Configured features: ACL CAIRO FREETYPE GIF GLIB GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Python Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-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 line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils vc-hg vc-git diff-mode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view easy-mmode pcvs-util vc vc-dispatcher python json subr-x map project comint ansi-osc ring cl-loaddefs cl-lib ansi-color term/screen term/xterm xterm byte-opt gv bytecomp byte-compile cconv rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine 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 composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 66777 6812) (symbols 48 8205 0) (strings 32 23919 1966) (string-bytes 1 693986) (vectors 16 13443) (vector-slots 8 155457 9079) (floats 8 30 347) (intervals 56 208 0) (buffers 1000 11)) --Multipart_Wed_Oct_12_00:00:57_2022-1 Content-Type: application/octet-stream; type=patch; name="0001-Fix-Python-completion-when-point-in-shell-buffer-is-.patch" Content-Disposition: attachment; filename="0001-Fix-Python-completion-when-point-in-shell-buffer-is-.patch" Content-Transfer-Encoding: 7bit >From d0dc88913d3b6feda2f098cc5aa2bb99993c03a8 Mon Sep 17 00:00:00 2001 From: kobarity Date: Tue, 11 Oct 2022 23:51:02 +0900 Subject: [PATCH] Fix Python completion when point in shell buffer is before the last prompt * lisp/progmodes/python.el (python-shell-completion-at-point): Limit prompt boundaries check to shell buffer. * test/lisp/progmodes/python-tests.el (python-shell-completion-2): (python-shell-completion-native-2): New tests. --- lisp/progmodes/python.el | 6 ++++-- test/lisp/progmodes/python-tests.el | 33 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 680b57fc3e..0de76b0bde 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4069,7 +4069,8 @@ python-shell-completion-at-point Optional argument PROCESS forces completions to be retrieved using that one instead of current buffer's process." (setq process (or process (get-buffer-process (current-buffer)))) - (let* ((line-start (if (derived-mode-p 'inferior-python-mode) + (let* ((is-shell-buffer (derived-mode-p 'inferior-python-mode)) + (line-start (if is-shell-buffer ;; Working on a shell buffer: use prompt end. (cdr (python-util-comint-last-prompt)) (line-beginning-position))) @@ -4100,7 +4101,8 @@ python-shell-completion-at-point (completion-fn (with-current-buffer (process-buffer process) (cond ((or (null prompt) - (< (point) (cdr prompt-boundaries))) + (and is-shell-buffer + (< (point) (cdr prompt-boundaries)))) #'ignore) ((or (not python-shell-completion-native-enable) ;; Even if native completion is enabled, for diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 60ff9bb613..9ad2d16930 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -4411,6 +4411,22 @@ python-shell-completion-1 (insert "A") (should (completion-at-point))))) +(ert-deftest python-shell-completion-2 () + "Should work regardless of the point in the Shell buffer." + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (python-shell-with-shell-buffer + (goto-char (point-min))) + (goto-char (point-max)) + (insert "abc.") + (should (completion-at-point))))) + (ert-deftest python-shell-completion-native-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell @@ -4427,6 +4443,23 @@ python-shell-completion-native-1 (insert "A") (should (completion-at-point))))) +(ert-deftest python-shell-completion-native-2 () + "Should work regardless of the point in the Shell buffer." + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (python-shell-with-shell-buffer + (goto-char (point-min))) + (goto-char (point-max)) + (insert "abc.") + (should (completion-at-point))))) + (ert-deftest python-shell-completion-native-with-ffap-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell -- 2.34.1 --Multipart_Wed_Oct_12_00:00:57_2022-1-- From unknown Sun Aug 17 10:17:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#58441: 29.0.50; Python completion fails when point in shell buffer is before the last prompt Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Oct 2022 11:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58441 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: kobarity Cc: 58441@debbugs.gnu.org Received: via spool by 58441-submit@debbugs.gnu.org id=B58441.166557329532370 (code B ref 58441); Wed, 12 Oct 2022 11:15:02 +0000 Received: (at 58441) by debbugs.gnu.org; 12 Oct 2022 11:14:55 +0000 Received: from localhost ([127.0.0.1]:55873 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiZhP-0008Q2-At for submit@debbugs.gnu.org; Wed, 12 Oct 2022 07:14:55 -0400 Received: from quimby.gnus.org ([95.216.78.240]:50298) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiZhO-0008Po-Eg for 58441@debbugs.gnu.org; Wed, 12 Oct 2022 07:14:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bSrKC8YEtxy7SOzUDeiwTicd8GnG4QiLYyYzaqv208I=; b=XpLPcIp/uBFKemiRU08kzwbiwb 6y3yg8lqEIyY9lZEMwHKzBpsPFjT9zwSHg1usEytIss/8y/pVWjRD6sSr7yRDB4OeqMAS2kUpoIg4 S64CLgOG8EJnUSLCJBk/6ZIx+o1kXXhThPlJbbxQ8c5BPSKnlIfk2OizQEZ+IOCQ+hgk=; Received: from [84.212.220.105] (helo=downe) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiZhG-00064q-DG; Wed, 12 Oct 2022 13:14:48 +0200 From: Lars Ingebrigtsen In-Reply-To: (kobarity@gmail.com's message of "Wed, 12 Oct 2022 00:00:57 +0900") References: X-Now-Playing: Nobukazu Takemura's _Music for the exhibition "Einheit"_: "(untitled)" Date: Wed, 12 Oct 2022 13:14:45 +0200 Message-ID: <87leplcmze.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: kobarity writes: > Attached is a patch to fix this issue. Thanks; pushed to Emacs 29. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) kobarity writes: > Attached is a patch to fix this issue. Thanks; pushed to Emacs 29. From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 12 07:14:59 2022 Received: (at control) by debbugs.gnu.org; 12 Oct 2022 11:14:59 +0000 Received: from localhost ([127.0.0.1]:55876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiZhT-0008QM-Jw for submit@debbugs.gnu.org; Wed, 12 Oct 2022 07:14:59 -0400 Received: from quimby.gnus.org ([95.216.78.240]:50312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiZhS-0008Pu-N9 for control@debbugs.gnu.org; Wed, 12 Oct 2022 07:14:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=R+Fn4ayaHF0WoEJHPQrcGxyw42US43oU//pSaWmlxrA=; b=Xa1cIWy0BqYm5XtTp5bqbfKNyX NkUDyQYGBInld61qO6jfM+gRkHrmC4fw96xteHJBvG2WA3kBjvdAcTf3A8NHXL1tuJ0mtAWMYYGo5 kV5gitjumJg7mTP2QJ3tP8jeOqPDhxW8wplI7r4bpDJOcm2U5NgXOg+RNL+2r4QIC+/A=; Received: from [84.212.220.105] (helo=downe) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiZhK-00064y-Qs for control@debbugs.gnu.org; Wed, 12 Oct 2022 13:14:52 +0200 Date: Wed, 12 Oct 2022 13:14:50 +0200 Message-Id: <87k055cmz9.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #58441 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 58441 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 58441 29.1 quit