aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorYuan Fu2022-10-18 14:06:13 -0700
committerYuan Fu2022-10-18 14:06:13 -0700
commit6b475da972d7e2ff7a2a3cafc1aea2a4937e64e9 (patch)
treea6963d84adfacdded0fe8f61f3b2e3c95c3dd742 /lisp/progmodes/python.el
parentc4ad36cd2daab764649db451c4a3f1a35c5f519a (diff)
downloademacs-6b475da972d7e2ff7a2a3cafc1aea2a4937e64e9.tar.gz
emacs-6b475da972d7e2ff7a2a3cafc1aea2a4937e64e9.zip
; * lisp/progmodes/python.el (python--backend-toggle): Use cond.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el29
1 files changed, 16 insertions, 13 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 374bc02a78c..834e8036a1b 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -6378,18 +6378,21 @@ Add import for undefined name `%s' (empty to skip): "
6378(defun python--backend-toggle (backend warn) 6378(defun python--backend-toggle (backend warn)
6379 "Toggle backend for `python-mode'. 6379 "Toggle backend for `python-mode'.
6380BACKEND and WARN are explained in `treesit-mode-function'." 6380BACKEND and WARN are explained in `treesit-mode-function'."
6381 (if (and (eq backend 'treesit) (treesit-ready-p warn 'python)) 6381 (cond
6382 (progn 6382 ;; Tree-sitter.
6383 (setq-local font-lock-keywords-only t) 6383 ((and (eq backend 'treesit) (treesit-ready-p warn 'python))
6384 (setq-local treesit-font-lock-feature-list 6384 (setq-local font-lock-keywords-only t)
6385 '((basic) (moderate) (elaborate))) 6385 (setq-local treesit-font-lock-feature-list
6386 (setq-local treesit-font-lock-settings 6386 '((basic) (moderate) (elaborate)))
6387 python--treesit-settings) 6387 (setq-local treesit-font-lock-settings
6388 (treesit-font-lock-enable) 6388 python--treesit-settings)
6389 (setq-local imenu-create-index-function 6389 (treesit-font-lock-enable)
6390 #'python-imenu-treesit-create-index) 6390 (setq-local imenu-create-index-function
6391 (add-hook 'which-func-functions 6391 #'python-imenu-treesit-create-index)
6392 #'python-info-treesit-current-defun nil t)) 6392 (add-hook 'which-func-functions
6393 #'python-info-treesit-current-defun nil t))
6394 ;; Elisp.
6395 ((eq backend 'elisp)
6393 (setq-local font-lock-defaults 6396 (setq-local font-lock-defaults
6394 `(,python-font-lock-keywords 6397 `(,python-font-lock-keywords
6395 nil nil nil nil 6398 nil nil nil nil
@@ -6399,7 +6402,7 @@ BACKEND and WARN are explained in `treesit-mode-function'."
6399 . python-font-lock-extend-region))) 6402 . python-font-lock-extend-region)))
6400 (setq-local imenu-create-index-function 6403 (setq-local imenu-create-index-function
6401 #'python-imenu-create-index) 6404 #'python-imenu-create-index)
6402 (add-hook 'which-func-functions #'python-info-current-defun nil t))) 6405 (add-hook 'which-func-functions #'python-info-current-defun nil t))))
6403 6406
6404;;;###autoload 6407;;;###autoload
6405(define-derived-mode python-mode prog-mode "Python" 6408(define-derived-mode python-mode prog-mode "Python"