[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 ef7f3c6388 04/10: Fix use of treesit-ready-p in c/c++-ts-mode
From: |
Yuan Fu |
Subject: |
emacs-29 ef7f3c6388 04/10: Fix use of treesit-ready-p in c/c++-ts-mode |
Date: |
Sat, 7 Jan 2023 21:44:43 -0500 (EST) |
branch: emacs-29
commit ef7f3c6388be1299e3834f7c96889f0e17745c24
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix use of treesit-ready-p in c/c++-ts-mode
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode)
(c++-ts-mode): Put setup code in a when form.
---
lisp/progmodes/c-ts-mode.el | 52 +++++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 30 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index ae50c0ef99..d2280f1d38 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -805,22 +805,17 @@ This mode is independent from the classic cc-mode.el based
`c-basic-offset', don't affect this mode."
:group 'c
- (unless (treesit-ready-p 'c)
- (error "Tree-sitter for C isn't available"))
-
- (treesit-parser-create 'c)
-
- ;; Comments.
- (setq-local comment-start "/* ")
- (setq-local comment-end " */")
-
- (setq-local treesit-simple-indent-rules
- (c-ts-mode--set-indent-style 'c))
-
- ;; Font-lock.
- (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'c))
-
- (treesit-major-mode-setup))
+ (when (treesit-ready-p 'c)
+ (treesit-parser-create 'c)
+ ;; Comments.
+ (setq-local comment-start "/* ")
+ (setq-local comment-end " */")
+ ;; Indent.
+ (setq-local treesit-simple-indent-rules
+ (c-ts-mode--set-indent-style 'c))
+ ;; Font-lock.
+ (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'c))
+ (treesit-major-mode-setup)))
;;;###autoload
(define-derived-mode c++-ts-mode c-ts-base-mode "C++"
@@ -831,20 +826,17 @@ This mode is independent from the classic cc-mode.el based
`c-basic-offset', don't affect this mode."
:group 'c++
- (unless (treesit-ready-p 'cpp)
- (error "Tree-sitter for C++ isn't available"))
-
- (treesit-parser-create 'cpp)
- (setq-local syntax-propertize-function
- #'c-ts-mode--syntax-propertize)
-
- (setq-local treesit-simple-indent-rules
- (c-ts-mode--set-indent-style 'cpp))
-
- ;; Font-lock.
- (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'cpp))
-
- (treesit-major-mode-setup))
+ (when (treesit-ready-p 'cpp)
+ (treesit-parser-create 'cpp)
+ ;; Syntax.
+ (setq-local syntax-propertize-function
+ #'c-ts-mode--syntax-propertize)
+ ;; Indent.
+ (setq-local treesit-simple-indent-rules
+ (c-ts-mode--set-indent-style 'cpp))
+ ;; Font-lock.
+ (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings
'cpp))
+ (treesit-major-mode-setup)))
;; We could alternatively use parsers, but if this works well, I don't
;; see the need to change. This is copied verbatim from cc-guess.el.
- emacs-29 updated (ee3e8d3f92 -> e3d806b417), Yuan Fu, 2023/01/07
- emacs-29 16f1e47ca8 02/10: ; * lisp/align.el (align-c++-modes): Add c/c++-ts-mode., Yuan Fu, 2023/01/07
- emacs-29 8575043f56 05/10: Remove duplicate entries in c-ts-mode's Imenu, Yuan Fu, 2023/01/07
- emacs-29 73168793c0 06/10: Fix label indentation for Linux style in c-ts-mode (bug#60543), Yuan Fu, 2023/01/07
- emacs-29 800e15e3be 09/10: Fix string-interpolation feature of python-ts-mode (bug#60599), Yuan Fu, 2023/01/07
- emacs-29 508389ad2b 01/10: Add documentation for c/c++-ts-mode (bug#60443), Yuan Fu, 2023/01/07
- emacs-29 cc1de953d4 03/10: ; * lisp/progmodes/gud.el (gud-tooltip-modes): Add ts- modes., Yuan Fu, 2023/01/07
- emacs-29 38b63f4c3c 08/10: Add indentation rule for concatenated_string (bug#60572), Yuan Fu, 2023/01/07
- emacs-29 ef7f3c6388 04/10: Fix use of treesit-ready-p in c/c++-ts-mode,
Yuan Fu <=
- emacs-29 2cdd75a18f 07/10: Fix highlighting of variable-declarations in typescript-ts-mode, Yuan Fu, 2023/01/07
- emacs-29 e3d806b417 10/10: Fix string fontification on python-ts-mode (bug#60599), Yuan Fu, 2023/01/07