annotate lisp/textmodes/css-mode.el @ 110383:e1094870ea06

ftfont.c (ftfont_check_otf): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Fri, 17 Sep 2010 13:57:58 +0900
parents 8ceadb47c51e
children 77c2be84591c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; css-mode.el --- Major mode to edit CSS files
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105965
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Keywords: hypermedia
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
8 ;; This file is part of GNU Emacs.
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
9
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
13 ;; (at your option) any later version.
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92692
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;; Commentary:
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Yet another CSS mode.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;;; Todo:
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; - electric ; and }
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; - filling code with auto-fill-mode
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; - completion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; - fix font-lock errors with multi-line selectors
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;; Code:
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35
84579
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
36 (defgroup css nil
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
37 "Cascading Style Sheets (CSS) editing mode."
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
38 :group 'languages)
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
39
79187
e3d75658c018 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78825
diff changeset
40 (eval-when-compile (require 'cl))
e3d75658c018 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78825
diff changeset
41
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (defun css-extract-keyword-list (res)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (with-temp-buffer
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (url-insert-file-contents "http://www.w3.org/TR/REC-CSS2/css2.txt")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (goto-char (point-max))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 (search-backward "Appendix H. Index")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (forward-line)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (delete-region (point-min) (point))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (let ((result nil)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 keys)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (dolist (re res)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (goto-char (point-min))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 (setq keys nil)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (while (re-search-forward (cdr re) nil t)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (push (match-string 1) keys))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 (push (cons (car re) (sort keys 'string-lessp)) result))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (nreverse result))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (defun css-extract-parse-val-grammar (string env)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (let ((start 0)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (elems ())
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 name)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 (while (string-match
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (concat "\\(?:"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 (concat "<a [^>]+><span [^>]+>\\(?:"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 "&lt;\\([^&]+\\)&gt;\\|'\\([^']+\\)'"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 "\\)</span></a>")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "\\|" "\\(\\[\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 "\\|" "\\(]\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 "\\|" "\\(||\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 "\\|" "\\(|\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 "\\|" "\\([*+?]\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 "\\|" "\\({[^}]+}\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 "\\|" "\\(\\w+\\(?:-\\w+\\)*\\)"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 "\\)[ \t\n]*")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 string start)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 ;; (assert (eq start (match-beginning 0)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 (setq start (match-end 0))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (cond
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 ;; Reference to a type of value.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ((setq name (match-string-no-properties 1 string))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (push (intern name) elems))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 ;; Reference to another property's values.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 ((setq name (match-string-no-properties 2 string))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (setq elems (delete-dups (append (cdr (assoc name env)) elems))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ;; A literal
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ((setq name (match-string-no-properties 9 string))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (push name elems))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ;; We just ignore the rest. I.e. we ignore the structure because
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ;; it's too difficult to exploit anyway (it would allow us to only
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 ;; complete top/center/bottom after one of left/center/right and
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;; vice-versa).
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (t nil)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 elems))
101279
1d661f541768 * textmodes/css-mode.el (css-backward-sexp): Stop once
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
95
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 (defun css-extract-props-and-vals ()
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (with-temp-buffer
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (url-insert-file-contents "http://www.w3.org/TR/CSS21/propidx.html")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (goto-char (point-min))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (let ((props ()))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (while (re-search-forward "#propdef-\\([^\"]+\\)\"><span class=\"propinst-\\1 xref\">'\\1'</span></a>" nil t)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (let ((prop (match-string-no-properties 1)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (goto-char (match-end 0))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (search-forward "<td>")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (let ((vals-string (buffer-substring (point)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (progn
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (re-search-forward "[ \t\n]+|[ \t\n]+<a href=\"cascade.html#value-def-inherit\" class=\"noxref\"><span class=\"value-inst-inherit\">inherit</span></a>")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (match-beginning 0)))))
101279
1d661f541768 * textmodes/css-mode.el (css-backward-sexp): Stop once
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
111 ;;
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (push (cons prop (css-extract-parse-val-grammar vals-string props))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 props)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 props)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ;; Extraction was done with:
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 ;; (css-extract-keyword-list
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 ;; '((pseudo . "^ +\\* :\\([^ \n,]+\\)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 ;; (at . "^ +\\* @\\([^ \n,]+\\)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 ;; (descriptor . "^ +\\* '\\([^ '\n]+\\)' (descriptor)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 ;; (media . "^ +\\* '\\([^ '\n]+\\)' media group")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 ;; (property . "^ +\\* '\\([^ '\n]+\\)',")))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (defconst css-pseudo-ids
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 '("active" "after" "before" "first" "first-child" "first-letter" "first-line"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 "focus" "hover" "lang" "left" "link" "right" "visited")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 "Identifiers for pseudo-elements and pseudo-classes.")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (defconst css-at-ids
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 '("charset" "font-face" "import" "media" "page")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 "Identifiers that appear in the form @foo.")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 (defconst css-descriptor-ids
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 '("ascent" "baseline" "bbox" "cap-height" "centerline" "definition-src"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 "descent" "font-family" "font-size" "font-stretch" "font-style"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 "font-variant" "font-weight" "mathline" "panose-1" "slope" "src" "stemh"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 "stemv" "topline" "unicode-range" "units-per-em" "widths" "x-height")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 "Identifiers for font descriptors.")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (defconst css-media-ids
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 '("all" "aural" "bitmap" "continuous" "grid" "paged" "static" "tactile"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 "visual")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 "Identifiers for types of media.")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (defconst css-property-ids
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 '("azimuth" "background" "background-attachment" "background-color"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 "background-image" "background-position" "background-repeat" "block"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 "border" "border-bottom" "border-bottom-color" "border-bottom-style"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 "border-bottom-width" "border-collapse" "border-color" "border-left"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 "border-left-color" "border-left-style" "border-left-width" "border-right"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 "border-right-color" "border-right-style" "border-right-width"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 "border-spacing" "border-style" "border-top" "border-top-color"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 "border-top-style" "border-top-width" "border-width" "bottom"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 "caption-side" "clear" "clip" "color" "compact" "content"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 "counter-increment" "counter-reset" "cue" "cue-after" "cue-before"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 "cursor" "dashed" "direction" "display" "dotted" "double" "elevation"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 "empty-cells" "float" "font" "font-family" "font-size" "font-size-adjust"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 "font-stretch" "font-style" "font-variant" "font-weight" "groove" "height"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 "hidden" "inline" "inline-table" "inset" "left" "letter-spacing"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 "line-height" "list-item" "list-style" "list-style-image"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 "list-style-position" "list-style-type" "margin" "margin-bottom"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 "margin-left" "margin-right" "margin-top" "marker-offset" "marks"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 "max-height" "max-width" "min-height" "min-width" "orphans" "outline"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 "outline-color" "outline-style" "outline-width" "outset" "overflow"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 "padding" "padding-bottom" "padding-left" "padding-right" "padding-top"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 "page" "page-break-after" "page-break-before" "page-break-inside" "pause"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 "pause-after" "pause-before" "pitch" "pitch-range" "play-during" "position"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 "quotes" "richness" "ridge" "right" "run-in" "size" "solid" "speak"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 "speak-header" "speak-numeral" "speak-punctuation" "speech-rate" "stress"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 "table" "table-caption" "table-cell" "table-column" "table-column-group"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 "table-footer-group" "table-header-group" "table-layout" "table-row"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 "table-row-group" "text-align" "text-decoration" "text-indent"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 "text-shadow" "text-transform" "top" "unicode-bidi" "vertical-align"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 "visibility" "voice-family" "volume" "white-space" "widows" "width"
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 "word-spacing" "z-index")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 "Identifiers for properties.")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177
78825
6ba709e4adda (css-electric-keys): electrick->electric.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78225
diff changeset
178 (defcustom css-electric-keys '(?\} ?\;) ;; '()
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 "Self inserting keys which should trigger re-indentation."
80261
4af0bb174714 * textmodes/css-mode.el (css-indent-offset, css-electric-keys):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79719
diff changeset
180 :version "22.2"
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 :type '(repeat character)
84579
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
182 :options '((?\} ?\;))
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
183 :group 'css)
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (defvar css-mode-syntax-table
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (let ((st (make-syntax-table)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 ;; C-style comments.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (modify-syntax-entry ?/ ". 14" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (modify-syntax-entry ?* ". 23" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 ;; Strings.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (modify-syntax-entry ?\" "\"" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (modify-syntax-entry ?\' "\"" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 ;; Blocks.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (modify-syntax-entry ?\{ "(}" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (modify-syntax-entry ?\} "){" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 ;; Args in url(...) thingies and other "function calls".
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (modify-syntax-entry ?\( "()" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (modify-syntax-entry ?\) ")(" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 ;; To match attributes in selectors.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (modify-syntax-entry ?\[ "(]" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (modify-syntax-entry ?\] ")[" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 ;; Special chars that sometimes come at the beginning of words.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (modify-syntax-entry ?@ "'" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 ;; (modify-syntax-entry ?: "'" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (modify-syntax-entry ?# "'" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 ;; Distinction between words and symbols.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (modify-syntax-entry ?- "_" st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 st))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (defconst css-escapes-re
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 "\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)"))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" css-escapes-re "\\)"))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (defconst css-ident-re (concat css-nmstart-re css-nmchar-re "*"))
108306
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
215 (defconst css-proprietary-nmstart-re ;; Vendor-specific properties.
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
216 "[-_]\\(?:ms\\|moz\\|o\\|webkit\\|khtml\\)-")
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (defconst css-name-re (concat css-nmchar-re "+"))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (defface css-selector '((t :inherit font-lock-function-name-face))
84579
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
220 "Face to use for selectors."
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
221 :group 'css)
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (defface css-property '((t :inherit font-lock-variable-name-face))
84579
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
223 "Face to use for properties."
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
224 :group 'css)
108306
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
225 (defface css-proprietary-property '((t :inherit (css-property italic)))
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
226 "Face to use for vendor-specific properties.")
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (defvar css-font-lock-keywords
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 `(("!\\s-*important" . font-lock-builtin-face)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 ;; Atrules keywords. IDs not in css-at-ids are valid (ignored).
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 ;; In fact the regexp should probably be
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 ;; (,(concat "\\(@" css-ident-re "\\)\\([ \t\n][^;{]*\\)[;{]")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 ;; (1 font-lock-builtin-face))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 ;; Since "An at-rule consists of everything up to and including the next
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 ;; semicolon (;) or the next block, whichever comes first."
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (,(concat "@" css-ident-re) . font-lock-builtin-face)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 ;; Selectors.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;; FIXME: attribute selectors don't work well because they may contain
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;; strings which have already been highlighted as f-l-string-face and
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;; thus prevent this highlighting from being applied (actually now that
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;; I use `append' this should work better). But really the part of hte
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 ;; selector between [...] should simply not be highlighted.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (,(concat "^\\([ \t]*[^@:{\n][^:{\n]+\\(?::" (regexp-opt css-pseudo-ids t)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 "\\(?:([^)]+)\\)?[^:{\n]*\\)*\\)\\(?:\n[ \t]*\\)*{")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (1 'css-selector append))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 ;; In the above rule, we allow the open-brace to be on some subsequent
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 ;; line. This will only work if we properly mark the intervening text
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 ;; as being part of a multiline element (and even then, this only
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; ensures proper refontification, but not proper discovery).
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 ("^[ \t]*{" (0 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (goto-char (match-beginning 0))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (skip-chars-backward " \n\t")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (put-text-property (point) (match-end 0)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 'font-lock-multiline t)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 ;; No face.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 nil)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ;; Properties. Again, we don't limit ourselves to css-property-ids.
108306
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
258 (,(concat "\\(?:[{;]\\|^\\)[ \t]*\\("
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
259 "\\(?:\\(" css-proprietary-nmstart-re "\\)\\|"
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
260 css-nmstart-re "\\)" css-nmchar-re "*"
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
261 "\\)\\s-*:")
8ceadb47c51e Highlight vendor specific properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
262 (1 (if (match-end 2) 'css-proprietary-property 'css-property)))))
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (defvar css-font-lock-defaults
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 '(css-font-lock-keywords nil t))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266
105965
3f64b8380468 * textmodes/ispell.el (ispell-skip-region-alist):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 101279
diff changeset
267 ;;;###autoload (add-to-list 'auto-mode-alist (cons (purecopy "\\.css\\'") 'css-mode))
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 ;;;###autoload
86820
3565c4272a41 (prog-mode): Remove.
Glenn Morris <rgm@gnu.org>
parents: 85688
diff changeset
269 (define-derived-mode css-mode fundamental-mode "CSS"
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 "Major mode to edit Cascading Style Sheets."
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (set (make-local-variable 'font-lock-defaults) css-font-lock-defaults)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (set (make-local-variable 'comment-start) "/*")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (set (make-local-variable 'comment-start-skip) "/\\*+[ \t]*")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (set (make-local-variable 'comment-end) "*/")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (set (make-local-variable 'comment-end-skip) "[ \t]*\\*+/")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 (set (make-local-variable 'forward-sexp-function) 'css-forward-sexp)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (set (make-local-variable 'parse-sexp-ignore-comments) t)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (set (make-local-variable 'indent-line-function) 'css-indent-line)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (set (make-local-variable 'fill-paragraph-function)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 'css-fill-paragraph)
78825
6ba709e4adda (css-electric-keys): electrick->electric.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78225
diff changeset
281 (when css-electric-keys
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (let ((fc (make-char-table 'auto-fill-chars)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (set-char-table-parent fc auto-fill-chars)
78825
6ba709e4adda (css-electric-keys): electrick->electric.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78225
diff changeset
284 (dolist (c css-electric-keys)
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (aset fc c 'indent-according-to-mode))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (set (make-local-variable 'auto-fill-chars) fc))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287
79187
e3d75658c018 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78825
diff changeset
288 (defvar comment-continue)
e3d75658c018 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78825
diff changeset
289
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (defun css-fill-paragraph (&optional justify)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (let ((ppss (syntax-ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (eol (line-end-position)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (cond
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 ((and (nth 4 ppss)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (goto-char (nth 8 ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 (forward-comment 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (prog1 (not (bolp))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (setq eol (point)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 ;; Filling inside a comment whose comment-end marker is not \n.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 ;; This code is meant to be generic, so that it works not only for
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 ;; css-mode but for all modes.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (save-restriction
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (narrow-to-region (nth 8 ppss) eol)
79187
e3d75658c018 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78825
diff changeset
306 (comment-normalize-vars) ;Will define comment-continue.
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (let ((fill-paragraph-function nil)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (paragraph-separate
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (if (and comment-continue
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (string-match "[^ \t]" comment-continue))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (concat "\\(?:[ \t]*" (regexp-quote comment-continue)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 "\\)?\\(?:" paragraph-separate "\\)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 paragraph-separate))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (paragraph-start
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (if (and comment-continue
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (string-match "[^ \t]" comment-continue))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (concat "\\(?:[ \t]*" (regexp-quote comment-continue)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 "\\)?\\(?:" paragraph-start "\\)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 paragraph-start)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (fill-paragraph justify)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 ;; Don't try filling again.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 t)))
101279
1d661f541768 * textmodes/css-mode.el (css-backward-sexp): Stop once
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
323
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 ((and (null (nth 8 ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (or (nth 1 ppss)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (and (ignore-errors
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (down-list 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (when (<= (point) eol)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (setq ppss (syntax-ppss)))))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (goto-char (nth 1 ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (let ((end (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (ignore-errors (forward-sexp 1) (copy-marker (point) t)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (when end
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (while (re-search-forward "[{;}]" end t)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (cond
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 ;; This is a false positive inside a string or comment.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 ((nth 8 (syntax-ppss)) nil)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 ((eq (char-before) ?\})
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (forward-char -1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (skip-chars-backward " \t")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (unless (bolp) (newline))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (t
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 (while
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (progn
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (setq eol (line-end-position))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (and (forward-comment 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (> (point) eol)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 ;; A multi-line comment should be on its own line.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (save-excursion (forward-comment -1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (when (< (point) eol)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (newline)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 t)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (if (< (point) eol) (newline)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (goto-char (nth 1 ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (indent-region (line-beginning-position 2) end)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 ;; Don't use the default filling code.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 t)))))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 ;;; Navigation and indentation.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (defconst css-navigation-syntax-table
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (let ((st (make-syntax-table css-mode-syntax-table)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (map-char-table (lambda (c v)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 ;; Turn punctuation (code = 1) into symbol (code = 1).
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (if (eq (car-safe v) 1)
81288
a8ba55c33235 (css-navigation-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 77923
diff changeset
367 (set-char-table-range st c (cons 3 (cdr v)))))
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 st)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 st))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (defun css-backward-sexp (n)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (let ((forward-sexp-function nil))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (if (< n 0) (css-forward-sexp (- n))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (while (> n 0)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (setq n (1- n))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (forward-comment (- (point-max)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (if (not (eq (char-before) ?\;))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (backward-sexp 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (while (progn (backward-sexp 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (forward-comment (- (point-max)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 ;; FIXME: We should also skip punctuation.
101279
1d661f541768 * textmodes/css-mode.el (css-backward-sexp): Stop once
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
383 (not (or (bobp) (memq (char-before) '(?\; ?\{))))))))))))
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (defun css-forward-sexp (n)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (let ((forward-sexp-function nil))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (if (< n 0) (css-backward-sexp (- n))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (while (> n 0)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (setq n (1- n))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (forward-comment (point-max))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (if (not (eq (char-after) ?\;))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (forward-sexp 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (while (progn (forward-sexp 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (forward-comment (point-max))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 ;; FIXME: We should also skip punctuation.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (not (memq (char-after) '(?\; ?\})))))))))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (defun css-indent-calculate-virtual ()
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (if (or (save-excursion (skip-chars-backward " \t") (bolp))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (if (looking-at "\\s(")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (forward-char 1) (skip-chars-forward " \t")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (not (or (eolp) (looking-at comment-start-skip))))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (current-column)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (css-indent-calculate)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (defcustom css-indent-offset 4
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 "Basic size of one indentation step."
80261
4af0bb174714 * textmodes/css-mode.el (css-indent-offset, css-electric-keys):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79719
diff changeset
410 :version "22.2"
84579
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
411 :type 'integer
ef7b976de171 (css): New custom group.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
412 :group 'css)
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (defun css-indent-calculate ()
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (let ((ppss (syntax-ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 pos)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (with-syntax-table css-navigation-syntax-table
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (cond
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; Inside a string.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ((nth 3 ppss) 'noindent)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 ;; Inside a comment.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ((nth 4 ppss)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (setq pos (point))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (forward-line -1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (skip-chars-forward " \t")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 (if (>= (nth 8 ppss) (point))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 (progn
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (goto-char (nth 8 ppss))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 (if (eq (char-after pos) ?*)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (forward-char 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (if (not (looking-at comment-start-skip))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (error "Internal css-mode error")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (goto-char (match-end 0))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (current-column))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 (if (and (eq (char-after pos) ?*) (eq (char-after) ?*))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (current-column)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 ;; 'noindent
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (current-column)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 )))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 ;; In normal code.
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (t
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (or
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (when (looking-at "\\s)")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (forward-char 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (backward-sexp 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (css-indent-calculate-virtual))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (when (looking-at comment-start-skip)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (forward-comment (point-max))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (css-indent-calculate))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (when (save-excursion (forward-comment (- (point-max)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (setq pos (point))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (eq (char-syntax (preceding-char)) ?\())
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 (goto-char (1- pos))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (if (not (looking-at "\\s([ \t]*"))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (error "Internal css-mode error")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (if (or (memq (char-after (match-end 0)) '(?\n nil))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (save-excursion (goto-char (match-end 0))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (looking-at comment-start-skip)))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (+ (css-indent-calculate-virtual) css-indent-offset)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (progn (goto-char (match-end 0)) (current-column)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (progn
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (css-backward-sexp 1)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (if (looking-at "\\s(")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (css-indent-calculate)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 (css-indent-calculate-virtual))))))))))
101279
1d661f541768 * textmodes/css-mode.el (css-backward-sexp): Stop once
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
467
77923
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (defun css-indent-line ()
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 "Indent current line according to CSS indentation rules."
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (interactive)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (let* ((savep (point))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (forward-sexp-function nil)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 (indent (condition-case nil
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (save-excursion
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (forward-line 0)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 (skip-chars-forward " \t")
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 (if (>= (point) savep) (setq savep nil))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (css-indent-calculate))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 (error nil))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 (if (not (numberp indent)) 'noindent
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 (if savep
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 (save-excursion (indent-line-to indent))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 (indent-line-to indent)))))
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (provide 'css-mode)
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 ;; arch-tag: b4d8b8e2-b130-4e74-b3aa-cd8f1ab659d0
7cbee079e548 New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 ;;; css-mode.el ends here