[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 c154047c46a: Fix c-ts-mode--anchor-prev-sibling (bug#73661)
From: |
Yuan Fu |
Subject: |
emacs-30 c154047c46a: Fix c-ts-mode--anchor-prev-sibling (bug#73661) |
Date: |
Mon, 14 Oct 2024 23:23:34 -0400 (EDT) |
branch: emacs-30
commit c154047c46ae833a114e84d72e62269d12c3249d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix c-ts-mode--anchor-prev-sibling (bug#73661)
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--anchor-prev-sibling): Fix parentheses and use a
slightly more efficient function.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: Replace
the tab in the test code with spaces.
---
lisp/progmodes/c-ts-mode.el | 17 +++++++++--------
test/lisp/progmodes/c-ts-mode-resources/indent.erts | 2 +-
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 576d715510d..12003ff4727 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -321,16 +321,17 @@ characters of the current line."
((or "#elif" "#else")
(setq prev-sibling (treesit-node-prev-sibling
(treesit-node-parent prev-sibling) t)))
- ;; If the start of the previous sibling isn't at the
- ;; beginning of a line, something's probably not quite
- ;; right, go a step further. (E.g., comment after a
- ;; statement.) If the previous sibling is the first named
- ;; node then anchor to that, e.g. when returning an aggregate
- ;; and starting the items on the same line as {.
+ ;; If the start of the previous sibling isn't at the beginning
+ ;; of a line, something's probably not quite right, go a step
+ ;; further. (E.g., comment after a statement.) If the
+ ;; previous sibling is the first named node, then anchor to
+ ;; that, e.g. when returning an aggregate and starting the
+ ;; items on the same line as {.
(_ (goto-char (treesit-node-start prev-sibling))
(if (or (looking-back (rx bol (* whitespace))
- (line-beginning-position)))
- (null (treesit-node-prev-sibling prev-sibling t))
+ (line-beginning-position))
+ (treesit-node-eq (treesit-node-child parent 0 t)
+ prev-sibling))
(setq continue nil)
(setq prev-sibling
(treesit-node-prev-sibling prev-sibling)))))))
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index a13a74cf8b3..f97ceac61f5 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -214,7 +214,7 @@ Name: Return Compund Literal
struct pair { int fst, snd; };
struct pair
make_pair(int long_identifier_a[], int long_identifier_b[],
- int offset_a, int offset_b)
+ int offset_a, int offset_b)
{
int base_offset = 10;
return (struct pair) { long_identifier_a[base_offset + offset_b],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-30 c154047c46a: Fix c-ts-mode--anchor-prev-sibling (bug#73661),
Yuan Fu <=