(setq-local comment-start-skip "/\\*+[ \t]*")
(setq-local comment-end "*/")
(setq-local comment-end-skip "[ \t]*\\*+/")
- (setq-local fill-paragraph-function 'css-fill-paragraph)
+ (setq-local fill-paragraph-function #'css-fill-paragraph)
+ (setq-local adaptive-fill-function #'css-adaptive-fill)
(setq-local add-log-current-defun-function #'css-current-defun-name)
(smie-setup css-smie-grammar #'css-smie-rules
:forward-token #'css-smie--forward-token
(defun css-fill-paragraph (&optional justify)
(save-excursion
+ ;; Fill succeeding comment when invoked right before a multi-line
+ ;; comment.
+ (when (save-excursion
+ (beginning-of-line)
+ (comment-search-forward (point-at-eol) t))
+ (goto-char (match-end 0)))
(let ((ppss (syntax-ppss))
(eol (line-end-position)))
(cond
(paragraph-separate
(if (and comment-continue
(string-match "[^ \t]" comment-continue))
- (concat "\\(?:[ \t]*" (regexp-quote comment-continue)
- "\\)?\\(?:" paragraph-separate "\\)")
+ (concat "\\(?:[ \t]*\\(?:"
+ (regexp-quote comment-continue) "\\|"
+ comment-start-skip "\\|"
+ comment-end-skip "\\)\\)?"
+ "\\(?:" paragraph-separate "\\)")
paragraph-separate))
(paragraph-start
(if (and comment-continue
;; Don't use the default filling code.
t)))))))
+(defun css-adaptive-fill ()
+ (when (looking-at "[ \t]*/\\*[ \t]*")
+ (let ((str (match-string 0)))
+ (and (string-match "/\\*" str)
+ (replace-match " *" t t str)))))
+
(defun css-current-defun-name ()
"Return the name of the CSS section at point, or nil."
(save-excursion
"Major mode to edit \"Sassy CSS\" files."
(setq-local comment-start "// ")
(setq-local comment-end "")
+ (setq-local comment-continue " *")
(setq-local comment-start-skip "/[*/]+[ \t]*")
(setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
(setq-local font-lock-defaults '(scss-font-lock-keywords nil t)))