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:
parent
b96b6ed64e
commit
5c06edd90a
2 changed files with 14 additions and 1 deletions
|
@ -22,7 +22,9 @@ If set to `nil', disable all the above behaviors.")
|
||||||
|
|
||||||
(setq-hook! 'css-mode-hook
|
(setq-hook! 'css-mode-hook
|
||||||
;; Correctly continue /* and // comments on newline-and-indent
|
;; 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)
|
(after! (:any css-mode sass-mode)
|
||||||
(set-docsets! '(css-mode scss-mode sass-mode)
|
(set-docsets! '(css-mode scss-mode sass-mode)
|
||||||
|
|
|
@ -92,3 +92,14 @@ Meant for `comment-line-break-function' in `css-mode' and `scss-mode'."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(just-one-space)
|
(just-one-space)
|
||||||
(insert "\n" (make-string pre-indent indent-char)))))))))
|
(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)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue