From: Augusto Stoffel Date: Mon, 22 Aug 2022 16:16:50 +0000 (+0200) Subject: Fix completion-predicate of Python shell commands X-Git-Tag: emacs-29.0.90~1893^2~89 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd97cc8e0df0c0f6dd83726abd11570c08bfc897;p=emacs.git Fix completion-predicate of Python shell commands * lisp/progmodes/python.el: Change some completion predicates. (python-shell--completion-predicate): New completion predicate function. (Bug#57184) --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a545240805a..e1347754c4a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -5897,6 +5897,7 @@ REPORT-FN is Flymake's callback function." (add-hook 'flymake-diagnostic-functions #'python-flymake nil t)) ;;; Completion predicates for M-x +;; Commands that only make sense when editing Python code (dolist (sym '(python-check python-fill-paragraph python-indent-dedent-line @@ -5928,6 +5929,13 @@ REPORT-FN is Flymake's callback function." python-shell-send-statement)) (put sym 'completion-predicate #'python--completion-predicate)) +(defun python-shell--completion-predicate (_ buffer) + (provided-mode-derived-p + (buffer-local-value 'major-mode buffer) + 'python-mode 'inferior-python-mode)) + +;; Commands that only make sense in the Python shell or when editing +;; Python code. (dolist (sym '(python-describe-at-point python-eldoc-at-point python-shell-completion-native-toggle @@ -5940,7 +5948,7 @@ REPORT-FN is Flymake's callback function." python-shell-font-lock-turn-on python-shell-package-enable python-shell-completion-complete-or-indent )) - (put sym 'completion-predicate #'python--completion-predicate)) + (put sym 'completion-predicate #'python-shell--completion-predicate)) (provide 'python)