[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 252b2c01af 6/8: Fix c-ts-mode label indent
From: |
Yuan Fu |
Subject: |
emacs-29 252b2c01af 6/8: Fix c-ts-mode label indent |
Date: |
Sun, 15 Jan 2023 04:17:44 -0500 (EST) |
branch: emacs-29
commit 252b2c01af02d5229d9c542a43622171ecfd040d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix c-ts-mode label indent
Fix indentation of the statement right under a label.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Fix.
(c-ts-mode--top-level-label-matcher): Fix.
---
lisp/progmodes/c-ts-mode.el | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index cc1f183fd7..4ed34af52e 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -129,8 +129,12 @@ MODE is either `c' or `cpp'."
c-ts-mode--comment-2nd-line-anchor
1)
((parent-is "comment") prev-adaptive-prefix 0)
+
+ ;; Labels.
((node-is "labeled_statement") parent-bol 0)
- ((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
+ ((parent-is "labeled_statement")
+ point-min c-ts-mode--statement-offset)
+
((match "preproc_ifdef" "compound_statement") point-min 0)
((match "#endif" "preproc_ifdef") point-min 0)
((match "preproc_if" "compound_statement") point-min 0)
@@ -216,10 +220,10 @@ NODE should be a labeled_statement."
(let ((func (treesit-parent-until
node (lambda (n)
(equal (treesit-node-type n)
- "function_definition")))))
+ "compound_statement")))))
(and (equal (treesit-node-type node)
"labeled_statement")
- (not (treesit-node-top-level func "function_definition")))))
+ (not (treesit-node-top-level func "compound_statement")))))
(defvar c-ts-mode-indent-block-type-regexp
(rx (or "compound_statement"
- emacs-29 updated (b365a7cc32 -> 3fa10f6e54), Yuan Fu, 2023/01/15
- emacs-29 25a5575f16 7/8: Fix c-ts-mode block comment indentation (bug#60270), Yuan Fu, 2023/01/15
- emacs-29 3fa10f6e54 8/8: ; Add more c-ts-mode indent and filling tests, Yuan Fu, 2023/01/15
- emacs-29 252b2c01af 6/8: Fix c-ts-mode label indent,
Yuan Fu <=
- emacs-29 f02998939c 1/8: ; Fix c-ts-mode filling, Yuan Fu, 2023/01/15
- emacs-29 d13a329acf 3/8: ; Minor change in c-ts-mode--indent-styles, Yuan Fu, 2023/01/15
- emacs-29 c78e19d99c 4/8: Allow offset in tree-sitter indent rules to be functions, Yuan Fu, 2023/01/15
- emacs-29 189d976dba 5/8: Fix statement indent for c-ts-mode (bug#59686) (bug#60280), Yuan Fu, 2023/01/15
- emacs-29 d428d51066 2/8: Support filling line comments in c-ts-mode, Yuan Fu, 2023/01/15