[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 25a5575f16 7/8: Fix c-ts-mode block comment indentation (bug#60
From: |
Yuan Fu |
Subject: |
emacs-29 25a5575f16 7/8: Fix c-ts-mode block comment indentation (bug#60270) |
Date: |
Sun, 15 Jan 2023 04:17:45 -0500 (EST) |
branch: emacs-29
commit 25a5575f161c4f4f2ee42bf15cdefec0bbfc6b33
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix c-ts-mode block comment indentation (bug#60270)
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--comment-2nd-line-anchor): Handle another edge case.
---
lisp/progmodes/c-ts-mode.el | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 4ed34af52e..89a08a6fa9 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -294,14 +294,15 @@ PARENT should be a comment node."
(back-to-indentation)
(eq (point) (treesit-node-start parent)))))
-(defun c-ts-mode--comment-2nd-line-anchor (&rest _)
+(defun c-ts-mode--comment-2nd-line-anchor (_n _p bol &rest _)
"Return appropriate anchor for the second line of a comment.
If the first line is /* alone, return the position right after
the star; if the first line is /* followed by some text, return
the position right before the text minus 1.
-Use an offset of 1 with this anchor."
+Use an offset of 1 with this anchor. BOL is the beginning of
+non-whitespace characters of the current line."
(save-excursion
(forward-line -1)
(back-to-indentation)
@@ -310,8 +311,17 @@ Use an offset of 1 with this anchor."
(if (looking-at (rx (* (or " " "\t")) eol))
;; Only /* at the first line.
(progn (skip-chars-backward " \t")
- (point))
- ;; There is something after /* at the first line.
+ (if (save-excursion
+ (goto-char bol)
+ (looking-at (rx "*")))
+ ;; The common case. Checked by "Multiline Block
+ ;; Comments 4".
+ (point)
+ ;; The "Multiline Block Comments 2" test in
+ ;; c-ts-mode-resources/indent.erts checks this.
+ (1- (point))))
+ ;; There is something after /* at the first line. The
+ ;; "Multiline Block Comments 3" test checks this.
(1- (point))))))
;;; Font-lock
- 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 <=
- 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, 2023/01/15
- 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