lang/web: fix comments not joining/filling correctly

Before, joining these two lines

  // hello
  // world

Results in

  // hello // world

And filling the following

  // Pretend this line is longer than 80 characters

Becomes

  // Pretend this lineis longer than
  80 characters
This commit is contained in:
Henrik Lissner 2020-11-08 20:02:16 -05:00
parent b96b6ed64e
commit 5c06edd90a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 14 additions and 1 deletions

View file

@ -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)))))