diff --git a/modules/lang/web/+css.el b/modules/lang/web/+css.el index 414d92ae6..c386e7658 100644 --- a/modules/lang/web/+css.el +++ b/modules/lang/web/+css.el @@ -22,7 +22,9 @@ If set to `nil', disable all the above behaviors.") (setq-hook! 'css-mode-hook ;; Correctly continue /* and // comments on newline-and-indent - comment-line-break-function #'+css/comment-indent-new-line) + comment-line-break-function #'+css/comment-indent-new-line + ;; Fix `fill-paragraph' not conjoining line comments in CSS modes correctly. + adaptive-fill-function #'+css-adaptive-fill-fn) (after! (:any css-mode sass-mode) (set-docsets! '(css-mode scss-mode sass-mode) diff --git a/modules/lang/web/autoload/css.el b/modules/lang/web/autoload/css.el index d83e770e2..4d5279f1d 100644 --- a/modules/lang/web/autoload/css.el +++ b/modules/lang/web/autoload/css.el @@ -92,3 +92,14 @@ Meant for `comment-line-break-function' in `css-mode' and `scss-mode'." (save-excursion (just-one-space) (insert "\n" (make-string pre-indent indent-char))))))))) + +;;;###autoload +(defun +css-adaptive-fill-fn () + "An `adaptive-fill-function' that conjoins SCSS line comments correctly." + (when (looking-at "[ \t]*/[/*][ \t]*") + (let ((str (match-string 0))) + (when (string-match "/[/*]" str) + (replace-match (if (string= (match-string 0 str) "/*") + " *" + "//") + t t str)))))