summaryrefslogtreecommitdiff
path: root/lisp/textmodes/css-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/css-mode.el')
-rw-r--r--lisp/textmodes/css-mode.el109
1 files changed, 63 insertions, 46 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 1139fd1976e..a2a7774aba7 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -269,6 +269,10 @@
("resize" "none" "both" "horizontal" "vertical")
("text-overflow" "clip" "ellipsis" string)
+ ;; CSS Cascading and Inheritance Level 3
+ ;; (https://www.w3.org/TR/css-cascade-3/#property-index)
+ ("all")
+
;; CSS Color Module Level 3
;; (https://www.w3.org/TR/css3-color/#property)
("color" color)
@@ -304,27 +308,27 @@
;; CSS Box Alignment Module Level 3
;; (https://www.w3.org/TR/css-align-3/#property-index)
- ("align-content"
- baseline-position content-distribution overflow-position content-position)
- ("align-items"
- "normal" "stretch" baseline-position overflow-position self-position)
- ("align-self"
- "auto" "normal" "stretch"
- baseline-position overflow-position self-position)
- ("justify-content" "normal"
- content-distribution overflow-position content-position "left" "right")
- ("justify-items"
- "normal" "stretch" baseline-position overflow-position self-position
- "left" "right" "legacy")
- ("justify-self"
- "auto" "normal" "stretch" baseline-position overflow-position self-position
- "left" "right")
+ ("align-content" baseline-position content-distribution
+ overflow-position content-position)
+ ("align-items" "normal" "stretch" baseline-position
+ overflow-position self-position)
+ ("align-self" "auto" "normal" "stretch" baseline-position
+ overflow-position self-position)
+ ("column-gap" "normal" length-percentage)
+ ("gap" row-gap column-gap)
+ ("justify-content" "normal" content-distribution overflow-position
+ content-position "left" "right")
+ ("justify-items" "normal" "stretch" baseline-position
+ overflow-position self-position "left" "right" "legacy" "center")
+ ("justify-self" "auto" "normal" "stretch" baseline-position
+ overflow-position self-position "left" "right")
("place-content" align-content justify-content)
("place-items" align-items justify-items)
("place-self" justify-self align-self)
+ ("row-gap" "normal" length-percentage)
- ;; CSS Flexible Box Layout Module Level 2
- ;; (https://www.w3.org/TR/css-flexbox-2/#property-index)
+ ;; CSS Flexible Box Layout Module Level 1
+ ;; (https://www.w3.org/TR/css-flexbox-1/#property-index)
("flex" "none" flex-grow flex-shrink flex-basis)
("flex-basis" "auto" "content" width)
("flex-direction" "row" "row-reverse" "column" "column-reverse")
@@ -413,21 +417,20 @@
("mask-type" "luminance" "alpha")
("clip" "rect()" "auto")
- ;; CSS Multi-column Layout Module
+ ;; CSS Multi-column Layout Module Level 1
;; (https://www.w3.org/TR/css3-multicol/#property-index)
;; "break-after", "break-before", and "break-inside" are left out
;; below, because they're already included in CSS Fragmentation
;; Module Level 3.
- ("column-count" integer "auto")
- ("column-fill" "auto" "balance")
- ("column-gap" length "normal")
+ ("column-count" "auto" integer)
+ ("column-fill" "auto" "balance" "balance-all")
("column-rule" column-rule-width column-rule-style
- column-rule-color "transparent")
+ column-rule-color)
("column-rule-color" color)
- ("column-rule-style" border-style)
- ("column-rule-width" border-width)
+ ("column-rule-style" line-style)
+ ("column-rule-width" line-width)
("column-span" "none" "all")
- ("column-width" length "auto")
+ ("column-width" "auto" length)
("columns" column-width column-count)
;; CSS Overflow Module Level 3
@@ -925,6 +928,32 @@ cannot be completed sensibly: `custom-ident',
(defface css-proprietary-property '((t :inherit (css-property italic)))
"Face to use for vendor-specific properties.")
+(defun css--selector-regexp (sassy)
+ (concat
+ "\\(?:"
+ (if (not sassy)
+ "[-_%*#.>[:alnum:]]+"
+ ;; Same as for non-sassy except we do want to allow { and }
+ ;; chars in selectors in the case of #{$foo}
+ ;; variable interpolation!
+ (concat "\\(?:[-_%*#.>&+~[:alnum:]]*" scss--hash-re
+ "\\|[-_%*#.>&+~[:alnum:]]+\\)"))
+ ;; Even though pseudo-elements should be prefixed by ::, a
+ ;; single colon is accepted for backward compatibility.
+ "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
+ css-pseudo-element-ids)
+ t)
+ "\\|::" (regexp-opt css-pseudo-element-ids t) "\\)\\)?"
+ ;; Braces after selectors.
+ "\\(?:\\[[^]\n]+\\]\\)?"
+ ;; Parentheses after selectors.
+ "\\(?:([^)]+)\\)?"
+ ;; Main bit over. But perhaps just [target]?
+ "\\|\\[[^]\n]+\\]"
+ ;; :root, ::marker and the like.
+ "\\|::?[[:alnum:]]+\\(?:([^)]+)\\)?"
+ "\\)"))
+
(defun css--font-lock-keywords (&optional sassy)
`((,(concat "!\\s-*" (regexp-opt css--bang-ids))
(0 font-lock-builtin-face))
@@ -945,28 +974,16 @@ cannot be completed sensibly: `custom-ident',
;; selector between [...] should simply not be highlighted.
(,(concat
"^[ \t]*\\("
- (if (not sassy)
- ;; We don't allow / as first char, so as not to
- ;; take a comment as the beginning of a selector.
- "[^@/:{}() \t\n][^:{}()]*"
- ;; Same as for non-sassy except we do want to allow { and }
- ;; chars in selectors in the case of #{$foo}
- ;; variable interpolation!
- (concat "\\(?:" scss--hash-re
- "\\|[^@/:{}() \t\n#]\\)"
- "[^:{}()#]*\\(?:" scss--hash-re "[^:{}()#]*\\)*"))
- ;; Even though pseudo-elements should be prefixed by ::, a
- ;; single colon is accepted for backward compatibility.
- "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
- css-pseudo-element-ids)
- t)
- "\\|::" (regexp-opt css-pseudo-element-ids t) "\\)"
- "\\(?:([^)]+)\\)?"
- (if (not sassy)
- "[^:{}()\n]*"
- (concat "[^:{}()\n#]*\\(?:" scss--hash-re "[^:{}()\n#]*\\)*"))
+ ;; We have at least one selector.
+ (css--selector-regexp sassy)
+ ;; And then possibly more.
+ "\\(?:"
+ ;; Separators between selectors.
+ "[ \n\t,+~>]+"
+ (css--selector-regexp sassy)
"\\)*"
- "\\)\\(?:\n[ \t]*\\)*{")
+ ;; And then a brace.
+ "\\)[ \n\t]*{")
(1 'css-selector keep))
;; In the above rule, we allow the open-brace to be on some subsequent
;; line. This will only work if we properly mark the intervening text