[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter 6b475da972: ; * lisp/progmodes/python.el (python--ba
From: |
Yuan Fu |
Subject: |
feature/tree-sitter 6b475da972: ; * lisp/progmodes/python.el (python--backend-toggle): Use cond. |
Date: |
Tue, 18 Oct 2022 17:07:05 -0400 (EDT) |
branch: feature/tree-sitter
commit 6b475da972d7e2ff7a2a3cafc1aea2a4937e64e9
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
; * lisp/progmodes/python.el (python--backend-toggle): Use cond.
---
lisp/progmodes/python.el | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 374bc02a78..834e8036a1 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -6378,18 +6378,21 @@ Add import for undefined name `%s' (empty to skip): "
(defun python--backend-toggle (backend warn)
"Toggle backend for `python-mode'.
BACKEND and WARN are explained in `treesit-mode-function'."
- (if (and (eq backend 'treesit) (treesit-ready-p warn 'python))
- (progn
- (setq-local font-lock-keywords-only t)
- (setq-local treesit-font-lock-feature-list
- '((basic) (moderate) (elaborate)))
- (setq-local treesit-font-lock-settings
- python--treesit-settings)
- (treesit-font-lock-enable)
- (setq-local imenu-create-index-function
- #'python-imenu-treesit-create-index)
- (add-hook 'which-func-functions
- #'python-info-treesit-current-defun nil t))
+ (cond
+ ;; Tree-sitter.
+ ((and (eq backend 'treesit) (treesit-ready-p warn 'python))
+ (setq-local font-lock-keywords-only t)
+ (setq-local treesit-font-lock-feature-list
+ '((basic) (moderate) (elaborate)))
+ (setq-local treesit-font-lock-settings
+ python--treesit-settings)
+ (treesit-font-lock-enable)
+ (setq-local imenu-create-index-function
+ #'python-imenu-treesit-create-index)
+ (add-hook 'which-func-functions
+ #'python-info-treesit-current-defun nil t))
+ ;; Elisp.
+ ((eq backend 'elisp)
(setq-local font-lock-defaults
`(,python-font-lock-keywords
nil nil nil nil
@@ -6399,7 +6402,7 @@ BACKEND and WARN are explained in
`treesit-mode-function'."
. python-font-lock-extend-region)))
(setq-local imenu-create-index-function
#'python-imenu-create-index)
- (add-hook 'which-func-functions #'python-info-current-defun nil t)))
+ (add-hook 'which-func-functions #'python-info-current-defun nil t))))
;;;###autoload
(define-derived-mode python-mode prog-mode "Python"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- feature/tree-sitter 6b475da972: ; * lisp/progmodes/python.el (python--backend-toggle): Use cond.,
Yuan Fu <=