Simplify python.el completion-predicate
* lisp/progmodes/python.el: (python-skeleton-define): Use command-modes as a shorthand for completion-predicate (bug#63552). (python--completion-predicate, python-shell--completion-predicate): Remove accordingly; no longer used. (python-define-auxiliary-skeleton): Prefer function-put over put.
This commit is contained in:
parent
f518543aa4
commit
d1404d3a11
1 changed files with 6 additions and 16 deletions
|
@ -5029,11 +5029,6 @@ the if condition."
|
|||
(not (python-syntax-comment-or-string-p))
|
||||
python-skeleton-autoinsert)))
|
||||
|
||||
(defun python--completion-predicate (_ buffer)
|
||||
(provided-mode-derived-p
|
||||
(buffer-local-value 'major-mode buffer)
|
||||
'python-base-mode))
|
||||
|
||||
(defmacro python-skeleton-define (name doc &rest skel)
|
||||
"Define a `python-mode' skeleton using NAME DOC and SKEL.
|
||||
The skeleton will be bound to python-skeleton-NAME and will
|
||||
|
@ -5042,7 +5037,7 @@ be added to `python-mode-skeleton-abbrev-table'."
|
|||
(let* ((name (symbol-name name))
|
||||
(function-name (intern (concat "python-skeleton-" name))))
|
||||
`(progn
|
||||
(put ',function-name 'completion-predicate #'python--completion-predicate)
|
||||
(function-put ',function-name 'command-modes '(python-base-mode))
|
||||
(define-abbrev python-mode-skeleton-abbrev-table
|
||||
,name "" ',function-name :system t)
|
||||
(setq python-skeleton-available
|
||||
|
@ -5069,7 +5064,7 @@ The skeleton will be bound to python-skeleton-NAME."
|
|||
`(< ,(format "%s:" name) \n \n
|
||||
> _ \n)))
|
||||
`(progn
|
||||
(put ',function-name 'completion-predicate #'ignore)
|
||||
(function-put ',function-name 'completion-predicate #'ignore)
|
||||
(define-skeleton ,function-name
|
||||
,(or doc
|
||||
(format "Auxiliary skeleton for %s statement." name))
|
||||
|
@ -6817,7 +6812,7 @@ implementations: `python-mode' and `python-ts-mode'."
|
|||
(add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode))))
|
||||
|
||||
;;; Completion predicates for M-x
|
||||
;; Commands that only make sense when editing Python code
|
||||
;; Commands that only make sense when editing Python code.
|
||||
(dolist (sym '(python-add-import
|
||||
python-check
|
||||
python-fill-paragraph
|
||||
|
@ -6851,12 +6846,7 @@ implementations: `python-mode' and `python-ts-mode'."
|
|||
python-shell-send-defun
|
||||
python-shell-send-statement
|
||||
python-sort-imports))
|
||||
(put sym 'completion-predicate #'python--completion-predicate))
|
||||
|
||||
(defun python-shell--completion-predicate (_ buffer)
|
||||
(provided-mode-derived-p
|
||||
(buffer-local-value 'major-mode buffer)
|
||||
'python-base-mode 'inferior-python-mode))
|
||||
(function-put sym 'command-modes '(python-base-mode)))
|
||||
|
||||
;; Commands that only make sense in the Python shell or when editing
|
||||
;; Python code.
|
||||
|
@ -6871,8 +6861,8 @@ implementations: `python-mode' and `python-ts-mode'."
|
|||
python-shell-font-lock-turn-off
|
||||
python-shell-font-lock-turn-on
|
||||
python-shell-package-enable
|
||||
python-shell-completion-complete-or-indent ))
|
||||
(put sym 'completion-predicate #'python-shell--completion-predicate))
|
||||
python-shell-completion-complete-or-indent))
|
||||
(function-put sym 'command-modes '(python-base-mode inferior-python-mode)))
|
||||
|
||||
(provide 'python)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue