From: kobarity Date: Sun, 16 Oct 2022 09:15:22 +0000 (+0200) Subject: Disable completion when PDB is active in Python Shell buffer X-Git-Tag: emacs-29.0.90~1616^2~594 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=45aabe6edae8d841a8985853394baddad4a1949e;p=emacs.git Disable completion when PDB is active in Python Shell buffer * lisp/progmodes/python.el (python-shell-completion-at-point): Disable completion in Python buffer when PDB is active in Python Shell buffer. * test/lisp/progmodes/python-tests.el (python-shell-completion-pdb-1): New test (bug#58562). --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 0de76b0bde3..50f1e6752e4 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4102,7 +4102,10 @@ using that one instead of current buffer's process." (with-current-buffer (process-buffer process) (cond ((or (null prompt) (and is-shell-buffer - (< (point) (cdr prompt-boundaries)))) + (< (point) (cdr prompt-boundaries))) + (and (not is-shell-buffer) + (string-match-p + python-shell-prompt-pdb-regexp prompt))) #'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 9ad2d169308..97dc17ce293 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -4427,6 +4427,23 @@ import abc (insert "abc.") (should (completion-at-point))))) +(ert-deftest python-shell-completion-pdb-1 () + "Should not complete PDB commands in Python buffer." + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import pdb + +pdb.set_trace() +print('Hello') +" + (let ((inhibit-message t)) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "u") + (should-not (nth 2 (python-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