(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-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
(let* ((name (symbol-name name))
(function-name (intern (concat "python-skeleton-" name))))
`(progn
+ (put ',function-name 'completion-predicate #'python--completion-predicate)
(define-abbrev python-mode-skeleton-abbrev-table
,name "" ',function-name :system t)
(setq python-skeleton-available
(setq skel
`(< ,(format "%s:" name) \n \n
> _ \n)))
- `(define-skeleton ,function-name
- ,(or doc
- (format "Auxiliary skeleton for %s statement." name))
- nil
- (unless (y-or-n-p ,msg)
- (signal 'quit t))
- ,@skel)))
+ `(progn
+ (put ',function-name 'completion-predicate #'ignore)
+ (define-skeleton ,function-name
+ ,(or doc
+ (format "Auxiliary skeleton for %s statement." name))
+ nil
+ (unless (y-or-n-p ,msg)
+ (signal 'quit t))
+ ,@skel))))
(python-define-auxiliary-skeleton else)
(add-hook 'flymake-diagnostic-functions #'python-flymake nil t))
+;;; Completion predicates for M-x
+(dolist (sym '(python-check
+ python-fill-paragraph
+ python-indent-dedent-line
+ python-indent-dedent-line-backspace
+ python-indent-guess-indent-offset
+ python-indent-shift-left
+ python-indent-shift-right
+ python-mark-defun
+ python-nav-backward-block
+ python-nav-backward-defun
+ python-nav-backward-sexp
+ python-nav-backward-sexp-safe
+ python-nav-backward-statement
+ python-nav-backward-up-list
+ python-nav-beginning-of-block
+ python-nav-beginning-of-statement
+ python-nav-end-of-block
+ python-nav-end-of-defun
+ python-nav-end-of-statement
+ python-nav-forward-block
+ python-nav-forward-defun
+ python-nav-forward-sexp
+ python-nav-forward-sexp-safe
+ python-nav-forward-statement
+ python-nav-if-name-main
+ python-nav-up-list
+ python-shell-send-buffer
+ python-shell-send-defun
+ python-shell-send-statement))
+ (put sym 'completion-predicate #'python--completion-predicate))
+
+(dolist (sym '(python-describe-at-point
+ python-eldoc-at-point
+ python-shell-completion-native-toggle
+ python-shell-completion-native-turn-off
+ python-shell-completion-native-turn-on
+ python-shell-completion-native-turn-on-maybe
+ python-shell-font-lock-cleanup-buffer
+ python-shell-font-lock-toggle
+ 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--completion-predicate))
+
(provide 'python)
;;; python.el ends here