aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Fu2023-01-15 01:01:38 -0800
committerYuan Fu2023-01-15 01:11:38 -0800
commit25a5575f161c4f4f2ee42bf15cdefec0bbfc6b33 (patch)
treec7c1f2a9b2852fa56a3e661c30779f33152689b1
parent252b2c01af02d5229d9c542a43622171ecfd040d (diff)
downloademacs-25a5575f161c4f4f2ee42bf15cdefec0bbfc6b33.tar.gz
emacs-25a5575f161c4f4f2ee42bf15cdefec0bbfc6b33.zip
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.
-rw-r--r--lisp/progmodes/c-ts-mode.el18
1 files changed, 14 insertions, 4 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 4ed34af52e7..89a08a6fa9c 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."
294 (back-to-indentation) 294 (back-to-indentation)
295 (eq (point) (treesit-node-start parent))))) 295 (eq (point) (treesit-node-start parent)))))
296 296
297(defun c-ts-mode--comment-2nd-line-anchor (&rest _) 297(defun c-ts-mode--comment-2nd-line-anchor (_n _p bol &rest _)
298 "Return appropriate anchor for the second line of a comment. 298 "Return appropriate anchor for the second line of a comment.
299 299
300If the first line is /* alone, return the position right after 300If the first line is /* alone, return the position right after
301the star; if the first line is /* followed by some text, return 301the star; if the first line is /* followed by some text, return
302the position right before the text minus 1. 302the position right before the text minus 1.
303 303
304Use an offset of 1 with this anchor." 304Use an offset of 1 with this anchor. BOL is the beginning of
305non-whitespace characters of the current line."
305 (save-excursion 306 (save-excursion
306 (forward-line -1) 307 (forward-line -1)
307 (back-to-indentation) 308 (back-to-indentation)
@@ -310,8 +311,17 @@ Use an offset of 1 with this anchor."
310 (if (looking-at (rx (* (or " " "\t")) eol)) 311 (if (looking-at (rx (* (or " " "\t")) eol))
311 ;; Only /* at the first line. 312 ;; Only /* at the first line.
312 (progn (skip-chars-backward " \t") 313 (progn (skip-chars-backward " \t")
313 (point)) 314 (if (save-excursion
314 ;; There is something after /* at the first line. 315 (goto-char bol)
316 (looking-at (rx "*")))
317 ;; The common case. Checked by "Multiline Block
318 ;; Comments 4".
319 (point)
320 ;; The "Multiline Block Comments 2" test in
321 ;; c-ts-mode-resources/indent.erts checks this.
322 (1- (point))))
323 ;; There is something after /* at the first line. The
324 ;; "Multiline Block Comments 3" test checks this.
315 (1- (point)))))) 325 (1- (point))))))
316 326
317;;; Font-lock 327;;; Font-lock