"Return the mirror image of string S, without any trailing space."
(comment-string-strip (concat (nreverse (string-to-list s))) nil t))
+(defvar comment-setup-function nil
+ "Function to set up variables needed by commenting functions.")
+
;;;###autoload
(defun comment-normalize-vars (&optional noerror)
"Check and set up variables needed by other commenting functions.
variables, like `comment-start', to ensure that the commenting
functions work correctly. Lisp callers of any other `comment-*'
function should first call this function explicitly."
+ (when (functionp comment-setup-function)
+ (funcall comment-setup-function))
(unless (and (not comment-start) noerror)
(unless comment-start
(let ((cs (read-string "No comment syntax is defined. Use: ")))
(js-name js-name)
(css-name css-name))))
+(defvar-local mhtml-ts-mode--comment-current-lang nil)
+
+(defun mhtml-ts-mode--comment-setup ()
+ (let ((lang (treesit-language-at (point))))
+ (unless (eq mhtml-ts-mode--comment-current-lang lang)
+ (setq mhtml-ts-mode--comment-current-lang lang)
+ (pcase lang
+ ('html
+ (setq-local comment-start "<!-- ")
+ (setq-local comment-start-skip nil)
+ (setq-local comment-end " -->")
+ (setq-local comment-end-skip nil))
+ ('css
+ (setq-local comment-start "/*")
+ (setq-local comment-start-skip "/\\*+[ \t]*")
+ (setq-local comment-end "*/")
+ (setq-local comment-end-skip "[ \t]*\\*+/"))
+ ('javascript
+ (c-ts-common-comment-setup))))))
+
;;; Flymake integration
(defvar-local mhtml-ts-mode--flymake-process nil
;; just like it's done in the original mode.
;; Comment.
- ;; indenting settings for js-ts-mode.
- (c-ts-common-comment-setup)
(setq-local comment-multi-line t)
+ (setq-local comment-setup-function #'mhtml-ts-mode--comment-setup)
;; Font-lock.