diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f9b645cc3df..4f57eda3cfc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -5029,11 +5029,6 @@ the if condition." | |||
| 5029 | (not (python-syntax-comment-or-string-p)) | 5029 | (not (python-syntax-comment-or-string-p)) |
| 5030 | python-skeleton-autoinsert))) | 5030 | python-skeleton-autoinsert))) |
| 5031 | 5031 | ||
| 5032 | (defun python--completion-predicate (_ buffer) | ||
| 5033 | (provided-mode-derived-p | ||
| 5034 | (buffer-local-value 'major-mode buffer) | ||
| 5035 | 'python-mode)) | ||
| 5036 | |||
| 5037 | (defmacro python-skeleton-define (name doc &rest skel) | 5032 | (defmacro python-skeleton-define (name doc &rest skel) |
| 5038 | "Define a `python-mode' skeleton using NAME DOC and SKEL. | 5033 | "Define a `python-mode' skeleton using NAME DOC and SKEL. |
| 5039 | The skeleton will be bound to python-skeleton-NAME and will | 5034 | The skeleton will be bound to python-skeleton-NAME and will |
| @@ -5042,7 +5037,7 @@ be added to `python-mode-skeleton-abbrev-table'." | |||
| 5042 | (let* ((name (symbol-name name)) | 5037 | (let* ((name (symbol-name name)) |
| 5043 | (function-name (intern (concat "python-skeleton-" name)))) | 5038 | (function-name (intern (concat "python-skeleton-" name)))) |
| 5044 | `(progn | 5039 | `(progn |
| 5045 | (put ',function-name 'completion-predicate #'python--completion-predicate) | 5040 | (function-put ',function-name 'command-modes '(python-base-mode)) |
| 5046 | (define-abbrev python-mode-skeleton-abbrev-table | 5041 | (define-abbrev python-mode-skeleton-abbrev-table |
| 5047 | ,name "" ',function-name :system t) | 5042 | ,name "" ',function-name :system t) |
| 5048 | (setq python-skeleton-available | 5043 | (setq python-skeleton-available |
| @@ -5069,7 +5064,7 @@ The skeleton will be bound to python-skeleton-NAME." | |||
| 5069 | `(< ,(format "%s:" name) \n \n | 5064 | `(< ,(format "%s:" name) \n \n |
| 5070 | > _ \n))) | 5065 | > _ \n))) |
| 5071 | `(progn | 5066 | `(progn |
| 5072 | (put ',function-name 'completion-predicate #'ignore) | 5067 | (function-put ',function-name 'completion-predicate #'ignore) |
| 5073 | (define-skeleton ,function-name | 5068 | (define-skeleton ,function-name |
| 5074 | ,(or doc | 5069 | ,(or doc |
| 5075 | (format "Auxiliary skeleton for %s statement." name)) | 5070 | (format "Auxiliary skeleton for %s statement." name)) |
| @@ -6817,7 +6812,7 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6817 | (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode)))) | 6812 | (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode)))) |
| 6818 | 6813 | ||
| 6819 | ;;; Completion predicates for M-x | 6814 | ;;; Completion predicates for M-x |
| 6820 | ;; Commands that only make sense when editing Python code | 6815 | ;; Commands that only make sense when editing Python code. |
| 6821 | (dolist (sym '(python-add-import | 6816 | (dolist (sym '(python-add-import |
| 6822 | python-check | 6817 | python-check |
| 6823 | python-fill-paragraph | 6818 | python-fill-paragraph |
| @@ -6851,12 +6846,7 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6851 | python-shell-send-defun | 6846 | python-shell-send-defun |
| 6852 | python-shell-send-statement | 6847 | python-shell-send-statement |
| 6853 | python-sort-imports)) | 6848 | python-sort-imports)) |
| 6854 | (put sym 'completion-predicate #'python--completion-predicate)) | 6849 | (function-put sym 'command-modes '(python-base-mode))) |
| 6855 | |||
| 6856 | (defun python-shell--completion-predicate (_ buffer) | ||
| 6857 | (provided-mode-derived-p | ||
| 6858 | (buffer-local-value 'major-mode buffer) | ||
| 6859 | 'python-mode 'inferior-python-mode)) | ||
| 6860 | 6850 | ||
| 6861 | ;; Commands that only make sense in the Python shell or when editing | 6851 | ;; Commands that only make sense in the Python shell or when editing |
| 6862 | ;; Python code. | 6852 | ;; Python code. |
| @@ -6871,8 +6861,8 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6871 | python-shell-font-lock-turn-off | 6861 | python-shell-font-lock-turn-off |
| 6872 | python-shell-font-lock-turn-on | 6862 | python-shell-font-lock-turn-on |
| 6873 | python-shell-package-enable | 6863 | python-shell-package-enable |
| 6874 | python-shell-completion-complete-or-indent )) | 6864 | python-shell-completion-complete-or-indent)) |
| 6875 | (put sym 'completion-predicate #'python-shell--completion-predicate)) | 6865 | (function-put sym 'command-modes '(python-base-mode inferior-python-mode))) |
| 6876 | 6866 | ||
| 6877 | (provide 'python) | 6867 | (provide 'python) |
| 6878 | 6868 | ||