]> code.delx.au - gnu-emacs/blob - lisp/textmodes/css-mode.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / textmodes / css-mode.el
1 ;;; css-mode.el --- Major mode to edit CSS files -*- lexical-binding: t -*-
2
3 ;; Copyright (C) 2006-2016 Free Software Foundation, Inc.
4
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6 ;; Maintainer: Simen Heggestøyl <simenheg@gmail.com>
7 ;; Keywords: hypermedia
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; Yet another CSS mode.
27
28 ;;; Todo:
29
30 ;; - electric ; and }
31 ;; - filling code with auto-fill-mode
32 ;; - attribute value completion
33 ;; - fix font-lock errors with multi-line selectors
34
35 ;;; Code:
36
37 (defgroup css nil
38 "Cascading Style Sheets (CSS) editing mode."
39 :group 'languages)
40
41 (defconst css-pseudo-class-ids
42 '("active" "checked" "disabled" "empty" "enabled" "first"
43 "first-child" "first-of-type" "focus" "hover" "indeterminate" "lang"
44 "last-child" "last-of-type" "left" "link" "not" "nth-child"
45 "nth-last-child" "nth-last-of-type" "nth-of-type" "only-child"
46 "only-of-type" "right" "root" "target" "visited")
47 "Identifiers for pseudo-classes.")
48
49 (defconst css-pseudo-element-ids
50 '("after" "before" "first-letter" "first-line")
51 "Identifiers for pseudo-elements.")
52
53 (defconst css-at-ids
54 '("charset" "font-face" "import" "media" "namespace" "page")
55 "Identifiers that appear in the form @foo.")
56
57 (defconst css-bang-ids
58 '("important")
59 "Identifiers that appear in the form !foo.")
60
61 (defconst scss-bang-ids
62 '("default" "global" "optional")
63 "Additional identifiers that appear in the form !foo in SCSS.")
64
65 (defconst css-descriptor-ids
66 '("ascent" "baseline" "bbox" "cap-height" "centerline" "definition-src"
67 "descent" "font-family" "font-size" "font-stretch" "font-style"
68 "font-variant" "font-weight" "mathline" "panose-1" "slope" "src" "stemh"
69 "stemv" "topline" "unicode-range" "units-per-em" "widths" "x-height")
70 "Identifiers for font descriptors.")
71
72 (defconst css-media-ids
73 '("all" "aural" "bitmap" "continuous" "grid" "paged" "static" "tactile"
74 "visual")
75 "Identifiers for types of media.")
76
77 (defconst css-property-ids
78 '(;; CSS 2.1 properties (http://www.w3.org/TR/CSS21/propidx.html).
79 ;;
80 ;; Properties duplicated by any of the CSS3 modules below have
81 ;; been removed.
82 "azimuth" "border-collapse" "border-spacing" "bottom"
83 "caption-side" "clear" "clip" "content" "counter-increment"
84 "counter-reset" "cue" "cue-after" "cue-before" "direction" "display"
85 "elevation" "empty-cells" "float" "height" "left" "line-height"
86 "list-style" "list-style-image" "list-style-position"
87 "list-style-type" "margin" "margin-bottom" "margin-left"
88 "margin-right" "margin-top" "max-height" "max-width" "min-height"
89 "min-width" "padding" "padding-bottom" "padding-left"
90 "padding-right" "padding-top" "page-break-after"
91 "page-break-before" "page-break-inside" "pause" "pause-after"
92 "pause-before" "pitch" "pitch-range" "play-during" "position"
93 "quotes" "richness" "right" "speak" "speak-header" "speak-numeral"
94 "speak-punctuation" "speech-rate" "stress" "table-layout" "top"
95 "unicode-bidi" "vertical-align" "visibility" "voice-family" "volume"
96 "width" "z-index"
97
98 ;; CSS Animations
99 ;; (http://www.w3.org/TR/css3-animations/#property-index)
100 "animation" "animation-delay" "animation-direction"
101 "animation-duration" "animation-fill-mode"
102 "animation-iteration-count" "animation-name"
103 "animation-play-state" "animation-timing-function"
104
105 ;; CSS Backgrounds and Borders Module Level 3
106 ;; (http://www.w3.org/TR/css3-background/#property-index)
107 "background" "background-attachment" "background-clip"
108 "background-color" "background-image" "background-origin"
109 "background-position" "background-repeat" "background-size"
110 "border" "border-bottom" "border-bottom-color"
111 "border-bottom-left-radius" "border-bottom-right-radius"
112 "border-bottom-style" "border-bottom-width" "border-color"
113 "border-image" "border-image-outset" "border-image-repeat"
114 "border-image-slice" "border-image-source" "border-image-width"
115 "border-left" "border-left-color" "border-left-style"
116 "border-left-width" "border-radius" "border-right"
117 "border-right-color" "border-right-style" "border-right-width"
118 "border-style" "border-top" "border-top-color"
119 "border-top-left-radius" "border-top-right-radius"
120 "border-top-style" "border-top-width" "border-width" "box-shadow"
121
122 ;; CSS Basic User Interface Module Level 3 (CSS3 UI)
123 ;; (http://www.w3.org/TR/css3-ui/#property-index)
124 "box-sizing" "caret-color" "cursor" "nav-down" "nav-left"
125 "nav-right" "nav-up" "outline" "outline-color" "outline-offset"
126 "outline-style" "outline-width" "resize" "text-overflow"
127
128 ;; CSS Color Module Level 3
129 ;; (http://www.w3.org/TR/css3-color/#property)
130 "color" "opacity"
131
132 ;; CSS Flexible Box Layout Module Level 1
133 ;; (http://www.w3.org/TR/css-flexbox-1/#property-index)
134 "align-content" "align-items" "align-self" "flex" "flex-basis"
135 "flex-direction" "flex-flow" "flex-grow" "flex-shrink" "flex-wrap"
136 "justify-content" "order"
137
138 ;; CSS Fonts Module Level 3
139 ;; (http://www.w3.org/TR/css3-fonts/#property-index)
140 "font" "font-family" "font-feature-settings" "font-kerning"
141 "font-language-override" "font-size" "font-size-adjust"
142 "font-stretch" "font-style" "font-synthesis" "font-variant"
143 "font-variant-alternates" "font-variant-caps"
144 "font-variant-east-asian" "font-variant-ligatures"
145 "font-variant-numeric" "font-variant-position" "font-weight"
146
147 ;; CSS Fragmentation Module Level 3
148 ;; (https://www.w3.org/TR/css-break-3/#property-index)
149 "box-decoration-break" "break-after" "break-before" "break-inside"
150 "orphans" "widows"
151
152 ;; CSS Overflow Module Level 3
153 ;; (http://www.w3.org/TR/css-overflow-3/#property-index)
154 "max-lines" "overflow" "overflow-x" "overflow-y"
155
156 ;; CSS Text Decoration Module Level 3
157 ;; (http://dev.w3.org/csswg/css-text-decor-3/#property-index)
158 "text-decoration" "text-decoration-color" "text-decoration-line"
159 "text-decoration-skip" "text-decoration-style" "text-emphasis"
160 "text-emphasis-color" "text-emphasis-position" "text-emphasis-style"
161 "text-shadow" "text-underline-position"
162
163 ;; CSS Text Module Level 3
164 ;; (http://www.w3.org/TR/css3-text/#property-index)
165 "hanging-punctuation" "hyphens" "letter-spacing" "line-break"
166 "overflow-wrap" "tab-size" "text-align" "text-align-last"
167 "text-indent" "text-justify" "text-transform" "white-space"
168 "word-break" "word-spacing" "word-wrap"
169
170 ;; CSS Transforms Module Level 1
171 ;; (http://www.w3.org/TR/css3-2d-transforms/#property-index)
172 "backface-visibility" "perspective" "perspective-origin"
173 "transform" "transform-origin" "transform-style"
174
175 ;; CSS Transitions
176 ;; (http://www.w3.org/TR/css3-transitions/#property-index)
177 "transition" "transition-delay" "transition-duration"
178 "transition-property" "transition-timing-function"
179
180 ;; Filter Effects Module Level 1
181 ;; (http://www.w3.org/TR/filter-effects/#property-index)
182 "color-interpolation-filters" "filter" "flood-color"
183 "flood-opacity" "lighting-color")
184 "Identifiers for properties.")
185
186 (defcustom css-electric-keys '(?\} ?\;) ;; '()
187 "Self inserting keys which should trigger re-indentation."
188 :version "22.2"
189 :type '(repeat character)
190 :options '((?\} ?\;))
191 :group 'css)
192
193 (defvar css-mode-syntax-table
194 (let ((st (make-syntax-table)))
195 ;; C-style comments.
196 (modify-syntax-entry ?/ ". 14" st)
197 (modify-syntax-entry ?* ". 23b" st)
198 ;; Strings.
199 (modify-syntax-entry ?\" "\"" st)
200 (modify-syntax-entry ?\' "\"" st)
201 ;; Blocks.
202 (modify-syntax-entry ?\{ "(}" st)
203 (modify-syntax-entry ?\} "){" st)
204 ;; Args in url(...) thingies and other "function calls".
205 (modify-syntax-entry ?\( "()" st)
206 (modify-syntax-entry ?\) ")(" st)
207 ;; To match attributes in selectors.
208 (modify-syntax-entry ?\[ "(]" st)
209 (modify-syntax-entry ?\] ")[" st)
210 ;; Special chars that sometimes come at the beginning of words.
211 (modify-syntax-entry ?@ "'" st)
212 ;; (modify-syntax-entry ?: "'" st)
213 (modify-syntax-entry ?# "'" st)
214 ;; Distinction between words and symbols.
215 (modify-syntax-entry ?- "_" st)
216 st))
217
218 (eval-and-compile
219 (defconst css--uri-re
220 (concat
221 "url\\((\\)[[:space:]]*\\(?:\\\\.\\|[^()[:space:]\n'\"]\\)+"
222 "[[:space:]]*\\()\\)")))
223
224 (defconst css-syntax-propertize-function
225 (syntax-propertize-rules
226 (css--uri-re (1 "|") (2 "|"))))
227
228 (defconst css-escapes-re
229 "\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)")
230 (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)"))
231 (defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" css-escapes-re "\\)"))
232 (defconst css-ident-re ;; (concat css-nmstart-re css-nmchar-re "*")
233 ;; Apparently, "at rules" names can start with a dash, e.g. @-moz-keyframes.
234 (concat css-nmchar-re "+"))
235 (defconst css-proprietary-nmstart-re ;; Vendor-specific properties.
236 (concat "[-_]" (regexp-opt '("ms" "moz" "o" "khtml" "webkit")) "-"))
237 (defconst css-name-re (concat css-nmchar-re "+"))
238
239 (defconst scss--hash-re "#\\(?:{[$-_[:alnum:]]+}\\|[[:alnum:]]+\\)")
240
241 (defface css-selector '((t :inherit font-lock-function-name-face))
242 "Face to use for selectors."
243 :group 'css)
244 (defface css-property '((t :inherit font-lock-variable-name-face))
245 "Face to use for properties."
246 :group 'css)
247 (defface css-proprietary-property '((t :inherit (css-property italic)))
248 "Face to use for vendor-specific properties.")
249
250 (defun css--font-lock-keywords (&optional sassy)
251 `((,(concat "!\\s-*"
252 (regexp-opt (append (if sassy scss-bang-ids)
253 css-bang-ids)))
254 (0 font-lock-builtin-face))
255 ;; Atrules keywords. IDs not in css-at-ids are valid (ignored).
256 ;; In fact the regexp should probably be
257 ;; (,(concat "\\(@" css-ident-re "\\)\\([ \t\n][^;{]*\\)[;{]")
258 ;; (1 font-lock-builtin-face))
259 ;; Since "An at-rule consists of everything up to and including the next
260 ;; semicolon (;) or the next block, whichever comes first."
261 (,(concat "@" css-ident-re) (0 font-lock-builtin-face))
262 ;; Variables.
263 (,(concat "--" css-ident-re) (0 font-lock-variable-name-face))
264 ;; Selectors.
265 ;; FIXME: attribute selectors don't work well because they may contain
266 ;; strings which have already been highlighted as f-l-string-face and
267 ;; thus prevent this highlighting from being applied (actually now that
268 ;; I use `keep' this should work better). But really the part of the
269 ;; selector between [...] should simply not be highlighted.
270 (,(concat
271 "^[ \t]*\\("
272 (if (not sassy)
273 ;; We don't allow / as first char, so as not to
274 ;; take a comment as the beginning of a selector.
275 "[^@/:{}() \t\n][^:{}()]+"
276 ;; Same as for non-sassy except we do want to allow { and }
277 ;; chars in selectors in the case of #{$foo}
278 ;; variable interpolation!
279 (concat "\\(?:" scss--hash-re
280 "\\|[^@/:{}() \t\n#]\\)"
281 "[^:{}()#]*\\(?:" scss--hash-re "[^:{}()#]*\\)*"))
282 ;; Even though pseudo-elements should be prefixed by ::, a
283 ;; single colon is accepted for backward compatibility.
284 "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
285 css-pseudo-element-ids) t)
286 "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
287 "\\(?:([^)]+)\\)?"
288 (if (not sassy)
289 "[^:{}()\n]*"
290 (concat "[^:{}()\n#]*\\(?:" scss--hash-re "[^:{}()\n#]*\\)*"))
291 "\\)*"
292 "\\)\\(?:\n[ \t]*\\)*{")
293 (1 'css-selector keep))
294 ;; In the above rule, we allow the open-brace to be on some subsequent
295 ;; line. This will only work if we properly mark the intervening text
296 ;; as being part of a multiline element (and even then, this only
297 ;; ensures proper refontification, but not proper discovery).
298 ("^[ \t]*{" (0 (save-excursion
299 (goto-char (match-beginning 0))
300 (skip-chars-backward " \n\t")
301 (put-text-property (point) (match-end 0)
302 'font-lock-multiline t)
303 ;; No face.
304 nil)))
305 ;; Properties. Again, we don't limit ourselves to css-property-ids.
306 (,(concat "\\(?:[{;]\\|^\\)[ \t]*\\("
307 "\\(?:\\(" css-proprietary-nmstart-re "\\)\\|"
308 css-nmstart-re "\\)" css-nmchar-re "*"
309 "\\)\\s-*:")
310 (1 (if (match-end 2) 'css-proprietary-property 'css-property)))
311 ;; Make sure the parens in a url(...) expression receive the
312 ;; default face. This is done because the parens may sometimes
313 ;; receive generic string delimiter syntax (see
314 ;; `css-syntax-propertize-function').
315 (,css--uri-re
316 (1 'default t) (2 'default t))))
317
318 (defvar css-font-lock-keywords (css--font-lock-keywords))
319
320 (defvar css-font-lock-defaults
321 '(css-font-lock-keywords nil t))
322
323 (defcustom css-indent-offset 4
324 "Basic size of one indentation step."
325 :version "22.2"
326 :type 'integer
327 :safe 'integerp)
328
329 (require 'smie)
330
331 (defconst css-smie-grammar
332 (smie-prec2->grammar
333 (smie-precs->prec2 '((assoc ";") (assoc ",") (left ":")))))
334
335 (defun css-smie--forward-token ()
336 (cond
337 ((and (eq (char-before) ?\})
338 (scss-smie--not-interpolation-p)
339 ;; FIXME: If the next char is not whitespace, what should we do?
340 (or (memq (char-after) '(?\s ?\t ?\n))
341 (looking-at comment-start-skip)))
342 (if (memq (char-after) '(?\s ?\t ?\n))
343 (forward-char 1) (forward-comment 1))
344 ";")
345 ((progn (forward-comment (point-max))
346 (looking-at "[;,:]"))
347 (forward-char 1) (match-string 0))
348 (t (smie-default-forward-token))))
349
350 (defun css-smie--backward-token ()
351 (let ((pos (point)))
352 (forward-comment (- (point)))
353 (cond
354 ;; FIXME: If the next char is not whitespace, what should we do?
355 ((and (eq (char-before) ?\}) (scss-smie--not-interpolation-p)
356 (> pos (point))) ";")
357 ((memq (char-before) '(?\; ?\, ?\:))
358 (forward-char -1) (string (char-after)))
359 (t (smie-default-backward-token)))))
360
361 (defun css-smie-rules (kind token)
362 (pcase (cons kind token)
363 (`(:elem . basic) css-indent-offset)
364 (`(:elem . arg) 0)
365 (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467).
366 (`(:before . "{")
367 (when (or (smie-rule-hanging-p) (smie-rule-bolp))
368 (smie-backward-sexp ";")
369 (smie-indent-virtual)))
370 (`(:before . ,(or "{" "("))
371 (if (smie-rule-hanging-p) (smie-rule-parent 0)))))
372
373 ;;; Completion
374
375 (defun css--complete-property ()
376 "Complete property at point."
377 (save-excursion
378 (let ((pos (point)))
379 (skip-chars-backward "-[:alnum:]")
380 (let ((start (point)))
381 (skip-chars-backward " \t\r\n")
382 (when (memq (char-before) '(?\{ ?\;))
383 (list start pos css-property-ids))))))
384
385 (defun css--complete-pseudo-element-or-class ()
386 "Complete pseudo-element or pseudo-class at point."
387 (save-excursion
388 (let ((pos (point)))
389 (skip-chars-backward "-[:alnum:]")
390 (when (eq (char-before) ?\:)
391 (list (point) pos
392 (if (eq (char-before (- (point) 1)) ?\:)
393 css-pseudo-element-ids
394 css-pseudo-class-ids))))))
395
396 (defun css--complete-at-rule ()
397 "Complete at-rule (statement beginning with `@') at point."
398 (save-excursion
399 (let ((pos (point)))
400 (skip-chars-backward "-[:alnum:]")
401 (when (eq (char-before) ?\@)
402 (list (point) pos css-at-ids)))))
403
404 (defun css-completion-at-point ()
405 "Complete current symbol at point.
406 Currently supports completion of CSS properties, pseudo-elements,
407 pseudo-classes, and at-rules."
408 (or (css--complete-property)
409 (css--complete-pseudo-element-or-class)
410 (css--complete-at-rule)))
411
412 ;;;###autoload
413 (define-derived-mode css-mode prog-mode "CSS"
414 "Major mode to edit Cascading Style Sheets."
415 (setq-local font-lock-defaults css-font-lock-defaults)
416 (setq-local comment-start "/*")
417 (setq-local comment-start-skip "/\\*+[ \t]*")
418 (setq-local comment-end "*/")
419 (setq-local comment-end-skip "[ \t]*\\*+/")
420 (setq-local syntax-propertize-function
421 css-syntax-propertize-function)
422 (setq-local fill-paragraph-function #'css-fill-paragraph)
423 (setq-local adaptive-fill-function #'css-adaptive-fill)
424 (setq-local add-log-current-defun-function #'css-current-defun-name)
425 (smie-setup css-smie-grammar #'css-smie-rules
426 :forward-token #'css-smie--forward-token
427 :backward-token #'css-smie--backward-token)
428 (setq-local electric-indent-chars
429 (append css-electric-keys electric-indent-chars))
430 (add-hook 'completion-at-point-functions
431 #'css-completion-at-point nil 'local))
432
433 (defvar comment-continue)
434
435 (defun css-fill-paragraph (&optional justify)
436 (save-excursion
437 ;; Fill succeeding comment when invoked right before a multi-line
438 ;; comment.
439 (when (save-excursion
440 (beginning-of-line)
441 (comment-search-forward (point-at-eol) t))
442 (goto-char (match-end 0)))
443 (let ((ppss (syntax-ppss))
444 (eol (line-end-position)))
445 (cond
446 ((and (nth 4 ppss)
447 (save-excursion
448 (goto-char (nth 8 ppss))
449 (forward-comment 1)
450 (prog1 (not (bolp))
451 (setq eol (point)))))
452 ;; Filling inside a comment whose comment-end marker is not \n.
453 ;; This code is meant to be generic, so that it works not only for
454 ;; css-mode but for all modes.
455 (save-restriction
456 (narrow-to-region (nth 8 ppss) eol)
457 (comment-normalize-vars) ;Will define comment-continue.
458 (let ((fill-paragraph-function nil)
459 (paragraph-separate
460 (if (and comment-continue
461 (string-match "[^ \t]" comment-continue))
462 (concat "\\(?:[ \t]*\\(?:"
463 (regexp-quote comment-continue) "\\|"
464 comment-start-skip "\\|"
465 comment-end-skip "\\)\\)?"
466 "\\(?:" paragraph-separate "\\)")
467 paragraph-separate))
468 (paragraph-start
469 (if (and comment-continue
470 (string-match "[^ \t]" comment-continue))
471 (concat "\\(?:[ \t]*" (regexp-quote comment-continue)
472 "\\)?\\(?:" paragraph-start "\\)")
473 paragraph-start)))
474 (fill-paragraph justify)
475 ;; Don't try filling again.
476 t)))
477
478 ((and (null (nth 8 ppss))
479 (or (nth 1 ppss)
480 (and (ignore-errors
481 (down-list 1)
482 (when (<= (point) eol)
483 (setq ppss (syntax-ppss)))))))
484 (goto-char (nth 1 ppss))
485 (let ((end (save-excursion
486 (ignore-errors (forward-sexp 1) (copy-marker (point) t)))))
487 (when end
488 (while (re-search-forward "[{;}]" end t)
489 (cond
490 ;; This is a false positive inside a string or comment.
491 ((nth 8 (syntax-ppss)) nil)
492 ;; This is a false positive when encountering an
493 ;; interpolated variable (bug#19751).
494 ((eq (char-before (- (point) 1)) ?#) nil)
495 ((eq (char-before) ?\})
496 (save-excursion
497 (forward-char -1)
498 (skip-chars-backward " \t")
499 (when (and (not (bolp))
500 (scss-smie--not-interpolation-p))
501 (newline))))
502 (t
503 (while
504 (progn
505 (setq eol (line-end-position))
506 (and (forward-comment 1)
507 (> (point) eol)
508 ;; A multi-line comment should be on its own line.
509 (save-excursion (forward-comment -1)
510 (when (< (point) eol)
511 (newline)
512 t)))))
513 (if (< (point) eol) (newline)))))
514 (goto-char (nth 1 ppss))
515 (indent-region (line-beginning-position 2) end)
516 ;; Don't use the default filling code.
517 t)))))))
518
519 (defun css-adaptive-fill ()
520 (when (looking-at "[ \t]*/\\*[ \t]*")
521 (let ((str (match-string 0)))
522 (and (string-match "/\\*" str)
523 (replace-match " *" t t str)))))
524
525 (defun css-current-defun-name ()
526 "Return the name of the CSS section at point, or nil."
527 (save-excursion
528 (let ((max (max (point-min) (- (point) 1600)))) ; approx 20 lines back
529 (when (search-backward "{" max t)
530 (skip-chars-backward " \t\r\n")
531 (beginning-of-line)
532 (if (looking-at "^[ \t]*\\([^{\r\n]*[^ {\t\r\n]\\)")
533 (match-string-no-properties 1))))))
534
535 ;;; SCSS mode
536
537 (defvar scss-mode-syntax-table
538 (let ((st (make-syntax-table css-mode-syntax-table)))
539 (modify-syntax-entry ?/ ". 124" st)
540 (modify-syntax-entry ?\n ">" st)
541 st))
542
543 (defvar scss-font-lock-keywords
544 (append `((,(concat "$" css-ident-re) (0 font-lock-variable-name-face)))
545 (css--font-lock-keywords 'sassy)
546 `((,(concat "@mixin[ \t]+\\(" css-ident-re "\\)[ \t]*(")
547 (1 font-lock-function-name-face)))))
548
549 (defun scss-smie--not-interpolation-p ()
550 (save-excursion
551 (forward-char -1)
552 (or (zerop (skip-chars-backward "-[:alnum:]"))
553 (not (looking-back "#{\\$" (- (point) 3))))))
554
555 ;;;###autoload (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
556 ;;;###autoload
557 (define-derived-mode scss-mode css-mode "SCSS"
558 "Major mode to edit \"Sassy CSS\" files."
559 (setq-local comment-start "// ")
560 (setq-local comment-end "")
561 (setq-local comment-continue " *")
562 (setq-local comment-start-skip "/[*/]+[ \t]*")
563 (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
564 (setq-local font-lock-defaults '(scss-font-lock-keywords nil t)))
565
566 (provide 'css-mode)
567 ;;; css-mode.el ends here