Subject: Re: bug#77853: 30.1; python-inferior-mode: completion regression

From: Liu Hui <[email-masked]>
Date: Mon, 21 Apr 2025 12:58:27 +0800

On Sun, Apr 20, 2025 at 11:12 PM kobarity <[email-masked]> wrote:
>
> I agree with this patch, but it failed to apply to both master and
> emacs-30 branches.  Is this patch for the latest branch?

Sorry, I didn't test it. Please try the attached patch.
From bfd0a4abdbae0f2347b09a17fe52c01bc8a75632 Mon Sep 17 00:00:00 2001
From: Liu Hui <[email-masked]>
Date: Mon, 21 Apr 2025 12:46:55 +0800
Subject: [PATCH] Fix filename completion in Python shell (bug#77853)

comint-filename-completion may complete the filename at wrong
locations.  Users who want proper filename completion should use
specialized completion backends (e.g. Jedi).

* lisp/progmodes/python.el (inferior-python-mode): Remove
comint-filename-completion in comint-dynamic-complete-functions.
---
 lisp/progmodes/python.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e593ea93ff4..9422000207d 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3667,6 +3667,8 @@ inferior-python-mode
   (setq-local compilation-error-regexp-alist
               python-shell-compilation-regexp-alist)
   (setq-local scroll-conservatively 1)
+  (setq-local comint-dynamic-complete-functions
+              '(comint-c-a-p-replace-by-expanded-history))
   (add-hook 'completion-at-point-functions
             #'python-shell-completion-at-point nil 'local)
   (define-key inferior-python-mode-map "\t"
-- 
2.25.1