Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 7333 Bytes
1 | ;;; sass-mode.el --- Major mode for editing Sass files |
2 | |
3 | ;; Copyright (c) 2007, 2008 Nathan Weizenbaum |
4 | |
5 | ;; Author: Nathan Weizenbaum |
6 | ;; URL: http://github.com/nex3/haml/tree/master |
7 | ;; Version: 2.2.21 |
8 | ;; Created: 2007-03-15 |
9 | ;; By: Nathan Weizenbaum |
10 | ;; Keywords: markup, language, css |
11 | ;; Package-Requires: ((haml-mode "2.2.21")) |
12 | |
13 | ;;; Commentary: |
14 | |
15 | ;; Because Sass's indentation schema is similar |
16 | ;; to that of YAML and Python, many indentation-related |
17 | ;; functions are similar to those in yaml-mode and python-mode. |
18 | |
19 | ;; To install, save this on your load path and add the following to |
20 | ;; your .emacs file: |
21 | ;; |
22 | ;; (require 'sass-mode) |
23 | |
24 | ;;; Code: |
25 | |
26 | (require 'haml-mode) |
27 | |
28 | ;; User definable variables |
29 | |
30 | (defgroup sass nil |
31 | "Support for the Sass template language." |
32 | :group 'languages |
33 | :prefix "sass-") |
34 | |
35 | (defcustom sass-mode-hook nil |
36 | "Hook run when entering Sass mode." |
37 | :type 'hook |
38 | :group 'sass) |
39 | |
40 | (defcustom sass-indent-offset 2 |
41 | "Amount of offset per level of indentation." |
42 | :type 'integer |
43 | :group 'sass) |
44 | |
45 | (defvar sass-non-block-openers |
46 | '("^ *:[^ \t]+[ \t]+[^ \t]" |
47 | "^ *[^ \t:]+[ \t]*[=:][ \t]*[^ \t]") |
48 | "A list of regexps that match lines of Sass that don't open blocks. |
49 | That is, a Sass line that can't have text nested beneath it |
50 | should be matched by a regexp in this list.") |
51 | |
52 | ;; Font lock |
53 | |
54 | (defconst sass-selector-font-lock-keywords |
55 | '(;; Attribute selectors (e.g. p[foo=bar]) |
56 | ("\\[\\([^]=]+\\)" (1 font-lock-variable-name-face) |
57 | ("[~|$^*]?=\\([^]=]+\\)" nil nil (1 font-lock-string-face))) |
58 | ("&" 0 font-lock-constant-face) |
59 | ("\\.\\w+" 0 font-lock-type-face) |
60 | ("#\\w+" 0 font-lock-keyword-face) |
61 | ;; Pseudo-selectors, optionally with arguments (e.g. :first, :nth-child(12)) |
62 | ("\\(::?\\w+\\)" (1 font-lock-function-name-face) |
63 | ("(\\([^)]+\\))" nil nil (1 font-lock-string-face))))) |
64 | |
65 | (defconst sass-script-font-lock-keywords |
66 | `(("\"\\([^\"\\\\]\\|\\\\.\\)*\"" 0 font-lock-string-face) |
67 | ("!\\(\\w\\|_\\)+" 0 font-lock-variable-name-face) |
68 | ("#[0-9a-fA-F]\\{0,6\\}" 0 font-lock-preprocessor-face) |
69 | (,(regexp-opt |
70 | '("true" "false" "black" "silver" "gray" "white" "maroon" "red" |
71 | "purple" "fuchsia" "green" "lime" "olive" "yellow" "navy" |
72 | "blue" "teal" "aqua")) |
73 | 0 font-lock-constant-face) |
74 | (,(regexp-opt '("and" "or" "not")) 0 font-lock-keyword-face))) |
75 | |
76 | (defconst sass-syntax-table |
77 | (let ((st (make-syntax-table))) |
78 | (modify-syntax-entry ?- "w" st) |
79 | (modify-syntax-entry ?_ "w" st) |
80 | st)) |
81 | |
82 | (defconst sass-script-syntax-table |
83 | (let ((st (make-syntax-table sass-syntax-table))) |
84 | (modify-syntax-entry ?- "." st) |
85 | st)) |
86 | |
87 | (defconst sass-font-lock-keywords |
88 | '((sass-highlight-line 1 nil nil t))) |
89 | |
90 | (defconst sass-line-keywords |
91 | '(("@\\(\\w+\\)" 0 font-lock-keyword-face sass-highlight-directive) |
92 | ("/[/*].*" 0 font-lock-comment-face) |
93 | ("[=+]\\w+" 0 font-lock-function-name-face sass-highlight-script-after-match) |
94 | ("!\\w+" 0 font-lock-variable-name-face sass-highlight-script-after-match) |
95 | (":\\w+" 0 font-lock-variable-name-face) |
96 | ("\\w+\s*:" 0 font-lock-variable-name-face) |
97 | ("\\(\\w+\\)\s*=" 1 font-lock-variable-name-face sass-highlight-script-after-match) |
98 | ("\\(:\\w+\\)\s*=" 1 font-lock-variable-name-face sass-highlight-script-after-match) |
99 | (".*" sass-highlight-selector)) |
100 | "A list of full-line Sass syntax to highlight, used by `sass-highlight-line'. |
101 | |
102 | Each item is either of the form (REGEXP SUBEXP FACE), (REGEXP FN), |
103 | or (REGEXP SUBEXP FACE FN). Each REGEXP is run successively on the |
104 | beginning of non-whitespace on the current line until one matches. |
105 | If it has SUBEXP and FACE, then SUBEXP is highlighted using FACE. |
106 | If it has FN, FN is run.") |
107 | |
108 | (defun sass-highlight-line (limit) |
109 | "Highlight a single line using some Sass single-line syntax. |
110 | This syntax is taken from `sass-line-keywords'. |
111 | LIMIT is the limit of the search." |
112 | (save-match-data |
113 | (when (re-search-forward "^ *\\(.+\\)$" limit t) |
114 | (goto-char (match-beginning 1)) |
115 | (dolist (keyword sass-line-keywords) |
116 | (destructuring-bind (keyword subexp-or-fn &optional face fn) keyword |
117 | (when (looking-at keyword) |
118 | (if (integerp subexp-or-fn) |
119 | (put-text-property (match-beginning subexp-or-fn) |
120 | (match-end subexp-or-fn) |
121 | 'face face) |
122 | (setq fn subexp-or-fn)) |
123 | (when fn (funcall fn)) |
124 | (end-of-line) |
125 | (return t))))))) |
126 | |
127 | (defun sass-highlight-selector () |
128 | "Highlight a CSS selector starting at `point' and ending at `end-of-line'." |
129 | (let ((font-lock-keywords sass-selector-font-lock-keywords) |
130 | font-lock-multiline) |
131 | (font-lock-fontify-region |
132 | (point) (progn (end-of-line) (point)))) |
133 | t) |
134 | |
135 | (defun sass-highlight-script (beg end) |
136 | "Highlight a section of SassScript between BEG and END." |
137 | (save-match-data |
138 | (with-syntax-table sass-script-syntax-table |
139 | (let ((font-lock-keywords sass-script-font-lock-keywords) |
140 | font-lock-syntax-table |
141 | font-lock-extend-region-functions) |
142 | (font-lock-fontify-region beg end))))) |
143 | |
144 | (defun sass-highlight-script-after-match () |
145 | "Highlight a section of SassScript after the last match." |
146 | (end-of-line) |
147 | (sass-highlight-script (match-end 0) (point))) |
148 | |
149 | (defun sass-highlight-directive () |
150 | "Highlight a Sass directive." |
151 | (goto-char (match-end 0)) |
152 | (block nil |
153 | (case (intern (match-string 1)) |
154 | (for |
155 | (unless (looking-at " +!\\w+") (return)) |
156 | (put-text-property (match-beginning 0) (match-end 0) |
157 | 'face font-lock-variable-name-face) |
158 | (goto-char (match-end 0)) |
159 | (unless (looking-at " +from") (return)) |
160 | (put-text-property (match-beginning 0) (match-end 0) |
161 | 'face font-lock-keyword-face) |
162 | (goto-char (match-end 0)) |
163 | (when (looking-at " +\\(.+?\\) +\\(to\\|through\\)") |
164 | (sass-highlight-script (match-beginning 1) (match-end 1)) |
165 | (put-text-property (match-beginning 2) (match-end 2) |
166 | 'face font-lock-keyword-face)) |
167 | (sass-highlight-script-after-match)) |
168 | |
169 | (else |
170 | (unless (looking-at " +if") (return)) |
171 | (put-text-property (match-beginning 0) (match-end 0) |
172 | 'face font-lock-keyword-face) |
173 | (sass-highlight-script-after-match)) |
174 | |
175 | ((if while debug) (sass-highlight-script-after-match))))) |
176 | |
177 | ;; Constants |
178 | |
179 | ;; Mode setup |
180 | |
181 | ;;;###autoload |
182 | (define-derived-mode sass-mode haml-mode "Sass" |
183 | "Major mode for editing Sass files." |
184 | (set-syntax-table sass-syntax-table) |
185 | (setq font-lock-extend-region-functions |
186 | '(font-lock-extend-region-wholelines font-lock-extend-region-multiline)) |
187 | (setq font-lock-multiline nil) |
188 | (setq comment-start "/*") |
189 | (set (make-local-variable 'haml-indent-function) 'sass-indent-p) |
190 | (set (make-local-variable 'haml-indent-offset) sass-indent-offset) |
191 | (setq font-lock-defaults '(sass-font-lock-keywords t t))) |
192 | |
193 | ;; Indentation |
194 | |
195 | (defun sass-indent-p () |
196 | "Return non-nil if the current line can have lines nested beneath it." |
197 | (loop for opener in sass-non-block-openers |
198 | unless (looking-at opener) return t |
199 | return nil)) |
200 | |
201 | ;;;###autoload |
202 | (add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode)) |
203 | |
204 | ;; Setup/Activation |
205 | (provide 'sass-mode) |
206 | ;;; sass-mode.el ends here |