diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 9d120ea4696..c919cbcd445 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -90,7 +90,7 @@ non-whitespace characters of the current line." (save-excursion (forward-line -1) (back-to-indentation) - (when (looking-at comment-start-skip) + (when (looking-at c-ts-common--comment-start-skip) (goto-char (match-end 0)) (if (looking-at (rx (* (or " " "\t")) eol)) ;; Only /* at the first line. @@ -274,6 +274,12 @@ This function should be called at BOL. Used by ;; `adaptive-fill-first-line-regexp' decide. (t nil))) +(defvar c-ts-common--comment-start-skip + (rx (or (seq "/" (+ "/")) + (seq "/" (+ "*"))) + (* (syntax whitespace))) + "`comment-start-skip' value for C and C++ tree-sitter modes.") + (defun c-ts-common-comment-setup () "Set up local variables for C-like comment. @@ -291,9 +297,7 @@ Set up: - `comment-multi-line'" (setq-local comment-start "// ") (setq-local comment-end "") - (setq-local comment-start-skip (rx (or (seq "/" (+ "/")) - (seq "/" (+ "*"))) - (* (syntax whitespace)))) + (setq-local comment-start-skip c-ts-common--comment-start-skip) (setq-local comment-end-skip (rx (* (syntax whitespace)) (group (or (syntax comment-end)