From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.bugs Subject: bug#58441: 29.0.50; Python completion fails when point in shell buffer is before the last prompt Date: Wed, 12 Oct 2022 00:00:57 +0900 Message-ID: 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" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14373"; mail-complaints-to="usenet@ciao.gmane.io" 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) To: 58441@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 11 17:05:44 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiGpD-0003Xr-Ns for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Oct 2022 17:05:43 +0200 Original-Received: from localhost ([::1]:33848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiGpC-0005GE-0B for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Oct 2022 11:05:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiGle-0003f0-ML for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 11:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiGle-0007MD-DF for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 11:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oiGle-00086C-7a for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 11:02:02 -0400 X-Loop: help-debbugs@gnu.org 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-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166550047831064 (code B ref -1); Tue, 11 Oct 2022 15:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Oct 2022 15:01:18 +0000 Original-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 Original-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 Original-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 Original-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 Original-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) Original-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) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245118 Archived-At: --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--