public
Description: My blog engine
Homepage: http://nex-3.com
Clone URL: git://github.com/nex3/nex3-s-blog-engine.git
Update to the latest Haml release.
nex3 (author)
Sun May 11 17:00:53 -0700 2008
commit  cd0b1fe8646bb00a0f628505fa6a891712e28b85
tree    0cbafc5795a27daefc8752c43734b820d90c43b6
parent  589aa4ce34bcd337652dd9d9cb035188ef428461
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-Copyright (c) 2006-2007 Hampton Catlin
0
+Copyright (c) 2006-2008 Hampton Catlin
0
 
0
 Permission is hereby granted, free of charge, to any person obtaining
0
 a copy of this software and associated documentation files (the
...
20
21
22
23
24
25
26
27
28
 
29
30
31
32
33
 
34
35
 
 
36
37
38
 
39
40
 
 
 
 
 
 
 
 
41
42
43
44
45
46
47
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 
 
 
89
90
91
 
 
92
93
 
94
 
95
96
97
 
 
 
 
 
 
 
 
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
100
 
101
 
 
 
102
 
103
104
105
106
107
108
109
110
111
112
 
 
 
 
 
 
 
 
113
114
115
116
117
 
 
 
 
118
119
120
121
122
123
124
125
126
127
128
129
 
 
 
 
 
130
131
132
133
134
135
136
137
138
139
140
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
 
144
145
 
146
147
 
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
 
 
 
 
 
171
 
 
 
 
 
 
 
 
 
 
 
172
...
20
21
22
 
 
 
 
 
 
23
24
25
 
 
 
26
27
 
28
29
30
 
 
31
32
 
33
34
35
36
37
38
39
40
41
 
 
 
 
 
 
42
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
45
46
47
 
 
48
49
50
51
52
53
54
55
 
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
86
87
88
89
90
91
92
93
 
 
 
 
 
 
 
 
 
94
95
96
97
98
99
100
101
102
 
 
 
 
103
104
105
106
107
 
 
 
 
 
 
 
 
 
 
 
108
109
110
111
112
113
 
 
 
 
 
 
 
 
 
 
 
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 
133
134
 
135
136
137
138
139
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
0
@@ -20,153 +20,139 @@ END
0
 
0
 desc temp_desc.chomp
0
 task :benchmark do
0
- require 'test/benchmark'
0
-
0
- puts "Running benchmarks #{ENV['TIMES']} times..." if ENV['TIMES']
0
- times = ENV['TIMES'].to_i if ENV['TIMES']
0
- Haml.benchmark(times || 100)
0
- puts '-'*51
0
+ sh "ruby test/benchmark.rb #{ENV['TIMES']}"
0
 end
0
 
0
-# Benchmarking gets screwed up if some other tasks have been
0
-# initialized.
0
-unless ARGV[0] == 'benchmark'
0
+# ----- Default: Testing ------
0
 
0
- # ----- Default: Testing ------
0
+desc 'Default: run unit tests.'
0
+task :default => :test
0
 
0
- desc 'Default: run unit tests.'
0
- task :default => :test
0
+require 'rake/testtask'
0
 
0
- require 'rake/testtask'
0
+Rake::TestTask.new do |t|
0
+ t.libs << 'lib'
0
+ t.pattern = 'test/**/*_test.rb'
0
+ t.verbose = true
0
+end
0
+Rake::Task[:test].send(:add_comment, <<END)
0
+To run with an alternate version of Rails, make test/rails a symlink to that version.
0
+END
0
 
0
- desc 'Test the Haml plugin'
0
- Rake::TestTask.new(:test) do |t|
0
- t.libs << 'lib'
0
- t.pattern = 'test/**/*_test.rb'
0
- t.verbose = true
0
- end
0
+# ----- Packaging -----
0
 
0
- # ----- Packaging -----
0
-
0
- require 'rake/gempackagetask'
0
-
0
- spec = Gem::Specification.new do |spec|
0
- spec.name = 'haml'
0
- spec.summary = "An elegant, structured XHTML/XML templating engine.\nComes with Sass, a similar CSS templating engine."
0
- spec.version = File.read('VERSION').strip
0
- spec.author = 'Hampton Catlin'
0
- spec.email = 'haml@googlegroups.com'
0
- spec.description = <<-END
0
- Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML
0
- that's designed to express the structure of XHTML or XML documents
0
- in a non-repetitive, elegant, easy way,
0
- using indentation rather than closing tags
0
- and allowing Ruby to be embedded with ease.
0
- It was originally envisioned as a plugin for Ruby on Rails,
0
- but it can function as a stand-alone templating engine.
0
- END
0
- #'
0
-
0
- readmes = FileList.new('*') do |list|
0
- list.exclude(/[a-z]/)
0
- list.exclude('TODO')
0
- end.to_a
0
- spec.executables = ['haml', 'html2haml', 'sass']
0
- spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
0
- spec.autorequire = ['haml', 'sass']
0
- spec.homepage = 'http://haml.hamptoncatlin.com/'
0
- spec.has_rdoc = true
0
- spec.extra_rdoc_files = readmes
0
- spec.rdoc_options += [
0
- '--title', 'Haml',
0
- '--main', 'README',
0
- '--exclude', 'lib/haml/buffer.rb',
0
- '--line-numbers',
0
- '--inline-source'
0
- ]
0
- spec.test_files = FileList['test/**/*_test.rb'].to_a
0
- end
0
+require 'rake/gempackagetask'
0
+require 'lib/haml'
0
+load 'haml.gemspec'
0
 
0
- Rake::GemPackageTask.new(spec) do |pkg|
0
- pkg.need_zip = true
0
+Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
0
+ if Rake.application.top_level_tasks.include?('release')
0
     pkg.need_tar_gz = true
0
     pkg.need_tar_bz2 = true
0
+ pkg.need_zip = true
0
   end
0
+end
0
 
0
- task :install => [:package] do
0
- sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
0
+desc "This is an internal task."
0
+task :revision_file do
0
+ if Haml.version[:rev] && !Rake.application.top_level_tasks.include?('release')
0
+ File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] }
0
+ elsif Rake.application.top_level_tasks.include?('release')
0
+ File.open('REVISION', 'w') { |f| f.puts "(release)" }
0
+ else
0
+ File.open('REVISION', 'w') { |f| f.puts "(unknown)" }
0
   end
0
+end
0
+Rake::Task[:package].prerequisites.insert(0, :revision_file)
0
+
0
+# We also need to get rid of this file after packaging.
0
+Rake::Task[:package].enhance { File.delete('REVISION') if File.exists?('REVISION') }
0
+
0
+task :install => [:package] do
0
+ sudo = RUBY_PLATFORM =~ /win32/ ? '' : 'sudo'
0
+ sh %{#{sudo} gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
0
+end
0
+
0
+task :release => [:package] do
0
+ name, version = ENV['NAME'], ENV['VERSION']
0
+ raise "Must supply NAME and VERSION for release task." unless name && version
0
+ sh %{rubyforge login}
0
+ sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
0
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
0
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
0
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
0
+end
0
 
0
- # ----- Documentation -----
0
+# ----- Documentation -----
0
 
0
+begin
0
+ require 'hanna/rdoctask'
0
+rescue LoadError
0
   require 'rake/rdoctask'
0
+end
0
 
0
- rdoc_task = Proc.new do |rdoc|
0
- rdoc.title = 'Haml/Sass'
0
- rdoc.options << '--line-numbers' << '--inline-source'
0
- rdoc.rdoc_files.include('README')
0
- rdoc.rdoc_files.include('lib/**/*.rb')
0
- rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
0
- rdoc.rdoc_files.exclude('lib/haml/util.rb')
0
- rdoc.rdoc_files.exclude('lib/sass/tree/*')
0
- end
0
+rdoc_task = Proc.new do |rdoc|
0
+ rdoc.title = 'Haml/Sass'
0
+ rdoc.options << '--line-numbers' << '--inline-source'
0
+ rdoc.rdoc_files.include('README.rdoc')
0
+ rdoc.rdoc_files.include('lib/**/*.rb')
0
+ rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
0
+ rdoc.rdoc_files.exclude('lib/sass/tree/*')
0
+end
0
 
0
- Rake::RDocTask.new do |rdoc|
0
- rdoc_task.call(rdoc)
0
- rdoc.rdoc_dir = 'rdoc'
0
- end
0
+Rake::RDocTask.new do |rdoc|
0
+ rdoc_task.call(rdoc)
0
+ rdoc.rdoc_dir = 'rdoc'
0
+end
0
 
0
- Rake::RDocTask.new(:rdoc_devel) do |rdoc|
0
- rdoc_task.call(rdoc)
0
- rdoc.rdoc_dir = 'rdoc_devel'
0
- rdoc.options << '--all'
0
- rdoc.rdoc_files.include('test/*.rb')
0
-
0
- # Get rid of exclusion rules
0
- rdoc.rdoc_files = Rake::FileList.new(*rdoc.rdoc_files.to_a)
0
- rdoc.rdoc_files.include('lib/haml/buffer.rb')
0
- rdoc.rdoc_files.include('lib/sass/tree/*')
0
- end
0
+Rake::RDocTask.new(:rdoc_devel) do |rdoc|
0
+ rdoc_task.call(rdoc)
0
+ rdoc.rdoc_dir = 'rdoc_devel'
0
+ rdoc.options << '--all'
0
+ rdoc.rdoc_files.include('test/*.rb')
0
 
0
- # ----- Coverage -----
0
-
0
- unless not_loaded.include? 'rcov/rcovtask'
0
- Rcov::RcovTask.new do |t|
0
- t.libs << "test"
0
- t.test_files = FileList['test/**/*_test.rb']
0
- t.rcov_opts << '-x' << '"^\/"'
0
- if ENV['NON_NATIVE']
0
- t.rcov_opts << "--no-rcovrt"
0
- end
0
- t.verbose = true
0
+ # Get rid of exclusion rules
0
+ rdoc.rdoc_files = Rake::FileList.new(*rdoc.rdoc_files.to_a)
0
+ rdoc.rdoc_files.include('lib/haml/buffer.rb')
0
+ rdoc.rdoc_files.include('lib/sass/tree/*')
0
+end
0
+
0
+# ----- Coverage -----
0
+
0
+unless not_loaded.include? 'rcov/rcovtask'
0
+ Rcov::RcovTask.new do |t|
0
+ t.test_files = FileList['test/**/*_test.rb']
0
+ t.rcov_opts << '-x' << '"^\/"'
0
+ if ENV['NON_NATIVE']
0
+ t.rcov_opts << "--no-rcovrt"
0
     end
0
+ t.verbose = true
0
   end
0
+end
0
 
0
- # ----- Profiling -----
0
+# ----- Profiling -----
0
 
0
- temp_desc = <<-END
0
+temp_desc = <<-END
0
   Run a profile of haml.
0
     ENGINE=str sets the engine to be profiled (Haml or Sass).
0
     TIMES=n sets the number of runs. Defaults to 100.
0
     FILE=n sets the file to profile. Defaults to 'standard'.
0
   END
0
- desc temp_desc.chomp
0
- task :profile do
0
- require 'test/profile'
0
-
0
- engine = ENV['ENGINE'] && ENV['ENGINE'].downcase == 'sass' ? Sass : Haml
0
-
0
- puts '-'*51, "Profiling #{engine}", '-'*51
0
-
0
- args = []
0
- args.push ENV['TIMES'].to_i if ENV['TIMES']
0
- args.push ENV['FILE'] if ENV['FILE']
0
-
0
- profiler = engine::Profiler.new
0
- res = profiler.profile(*args)
0
- puts res
0
-
0
- puts '-'*51
0
- end
0
+desc temp_desc.chomp
0
+task :profile do
0
+ require 'test/profile'
0
+
0
+ engine = ENV['ENGINE'] && ENV['ENGINE'].downcase == 'sass' ? Sass : Haml
0
 
0
+ puts '-'*51, "Profiling #{engine}", '-'*51
0
+
0
+ args = []
0
+ args.push ENV['TIMES'].to_i if ENV['TIMES']
0
+ args.push ENV['FILE'] if ENV['FILE']
0
+
0
+ profiler = engine::Profiler.new
0
+ res = profiler.profile(*args)
0
+ puts res
0
+
0
+ puts '-'*51
0
 end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
 
 
 
1
2
3
 
 
 
 
4
5
6
 
7
8
9
0
@@ -1,17 +1,9 @@
0
-Bugs:
0
- If an @imported document is changed, Sass should recompile the template
0
-
0
 Testing:
0
   Test html2haml and css2sass
0
 
0
-Documentation:
0
- Haml::Engine public method documentation could use work
0
- !! Document at-rules.
0
-
0
 Features:
0
   Sass should throw generic errors for undefined constants, not syntax errors
0
   Sass::Plugin should log errors
0
- There should be a way to represent options in-document
0
   There should be a way to make Haml tags not insert whitespace
0
   "%li, %a"?
0
   Sass::Engine load_paths option should be set by executable
...
1
2
3
4
5
...
7
8
9
10
 
11
12
13
 
 
14
15
16
 
 
17
18
19
...
22
23
24
25
 
26
27
28
29
30
 
31
32
33
34
35
36
 
 
 
 
 
37
38
39
40
41
 
 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140
141
...
146
147
148
149
150
151
152
153
154
155
156
 
 
 
 
 
 
 
 
 
 
157
158
159
 
160
161
162
163
164
165
166
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
169
170
 
 
 
 
 
 
171
172
173
174
175
176
177
178
179
 
 
180
181
182
183
184
185
186
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
189
190
...
205
206
207
 
 
 
 
 
 
 
 
 
 
208
209
210
211
 
 
 
 
 
 
212
213
214
 
 
 
 
215
216
217
218
219
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
1
 
2
3
4
...
6
7
8
 
9
10
11
 
12
13
14
15
16
17
18
19
20
21
...
24
25
26
 
27
28
29
30
31
 
32
33
34
35
 
 
 
36
37
38
39
40
41
42
43
 
 
44
45
46
47
48
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
101
102
103
 
 
 
 
 
 
 
 
104
105
106
107
108
109
110
111
112
113
114
115
 
116
117
118
119
120
 
 
 
 
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
 
 
 
 
 
229
230
231
 
 
 
 
 
 
 
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
 
 
299
300
301
302
303
304
305
 
 
306
307
308
309
310
311
 
 
 
 
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
 
 
 
 
 
 
329
 
 
 
 
 
 
 
0
@@ -1,5 +1,4 @@
0
 ;;; haml-mode.el -- Major mode for editing Haml files
0
-;;; Version 0.0.1
0
 ;;; Written by Nathan Weizenbaum
0
 
0
 ;;; Because Haml's indentation schema is similar
0
@@ -7,13 +6,16 @@
0
 ;;; functions are similar to those in yaml-mode and python-mode.
0
 
0
 ;;; To install, save this somewhere and add the following to your .emacs file:
0
-;;;
0
+;;;
0
 ;;; (add-to-list 'load-path "/path/to/haml-mode.el")
0
 ;;; (require 'haml-mode nil 't)
0
-;;;
0
+;;; (add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
0
+;;;
0
 
0
 ;;; Code:
0
 
0
+(eval-when-compile (require 'cl))
0
+
0
 ;; User definable variables
0
 
0
 (defgroup haml nil
0
@@ -22,120 +24,73 @@
0
   :prefix "haml-")
0
 
0
 (defcustom haml-mode-hook nil
0
- "*Hook run by `haml-mode'."
0
+ "Hook run when entering Haml mode."
0
   :type 'hook
0
   :group 'haml)
0
 
0
 (defcustom haml-indent-offset 2
0
- "*Amount of offset per level of indentation."
0
+ "Amount of offset per level of indentation."
0
   :type 'integer
0
   :group 'haml)
0
 
0
-(defcustom haml-backspace-function 'backward-delete-char-untabify
0
- "*Function called by `haml-electric-backspace' when deleting backwards."
0
- :type 'function
0
+(defcustom haml-backspace-backdents-nesting t
0
+ "Non-nil to have `haml-electric-backspace' re-indent all code
0
+nested beneath the backspaced line be re-indented along with the
0
+line itself."
0
+ :type 'boolean
0
   :group 'haml)
0
 
0
 (defface haml-tab-face
0
- '((((class color)) (:background "red" :foreground "red" :bold t))
0
- (t (:reverse-video t)))
0
+ '((((class color)) (:background "hotpink"))
0
+ (t (:reverse-video t)))
0
   "Face to use for highlighting tabs in Haml files."
0
   :group 'faces
0
   :group 'haml)
0
 
0
-;; Helper Functions
0
-
0
-(defun string-* (str n)
0
- "Concatenates a string with itself n times."
0
- (if (= n 0) ""
0
- (concat str (string-* str (- n 1)))))
0
-
0
-(defun find-if (f lst)
0
- "Returns the first element of a list for which a function returns a non-nil value, or nil if no such element is found."
0
- (while (not (or (null lst)
0
- (apply f (list (car lst)))))
0
- (setq lst (cdr lst)))
0
- (if (null lst) nil (car lst)))
0
-
0
-(defun hre (str)
0
- "Prepends a Haml-tab-matching regexp to str."
0
- (concat "^\\(" (string-* " " haml-indent-offset) "\\)*" str))
0
+(defvar haml-indent-function 'haml-indent-p
0
+ "This function should look at the current line and return true
0
+if the next line could be nested within this line.")
0
+
0
+(defvar haml-block-openers
0
+ `("^ *\\([%\\.#][^ \t]*\\)\\(\\[.*\\]\\)?\\({.*}\\)?\\(\\[.*\\]\\)?[ \t]*$"
0
+ "^ *[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$"
0
+ ,(concat "^ *-[ \t]*\\("
0
+ (regexp-opt '("else" "elsif" "rescue" "ensure" "when"))
0
+ "\\)")
0
+ "^ */\\(\\[.*\\]\\)?[ \t]*$"
0
+ "^ *-#"
0
+ "^ *:")
0
+ "A list of regexps that match lines of Haml that could have
0
+text nested beneath them.")
0
 
0
 ;; Font lock
0
 
0
-(defconst haml-font-lock-keywords-1
0
- (list
0
- ;; instruct
0
- '("^!!!.*" 0 font-lock-constant-face)
0
- ;; strings
0
- '("\\('[^']*'\\)" 1 font-lock-string-face append)
0
- '("\\(\"[^\"]*\"\\)" 1 font-lock-string-face append)
0
- ;; symbol
0
- '("&?:\\w+" 0 font-lock-constant-face append)
0
- ;; ruby varible
0
- '("@[a-z0-9_]+" 0 font-lock-variable-name-face append)
0
- ;; pipe
0
- '("| *$" 0 font-lock-string-face)
0
- ;; comment
0
- '("^[ \t]*\\(/.*\\)$" 1 font-lock-comment-face append)
0
- ;; id
0
- '("^ *\\(#[a-z0-9_]+\/?\\)" 1 font-lock-keyword-face)
0
- ;; class
0
- '("^ *\\(\\.[a-z0-9_]+\/?\\)" 1 font-lock-type-face)
0
- ;; tag
0
- '("^ *\\(%[a-z0-9_]+\/?\\)" 1 font-lock-function-name-face )
0
- ;; class after id
0
- '("^ *\\(#[a-z0-9_]+\/?\\)" (1 font-lock-keyword-face) ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
0
- ;; class after class
0
- '("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face) ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
0
- ;; id after class
0
- '("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face) ("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
0
- ;; class after tag
0
- '("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face) ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
0
- ;; id after tag
0
- '("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face) ("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
0
- ;; embeded ruby: beggin of line
0
- '("^ *\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
0
- ;; embeded ruby: after tag,class,id
0
- '("^ *[\\.#%a-z0-9_]+\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
0
- ;; embeded ruby: attributes
0
- '("^ *[\\.#%a-z0-9_]+\\({[^}]+}\\)" 1 font-lock-preprocessor-face prepend)
0
- ;; embeded ruby: square
0
- '("^ *[\\.#%a-z0-9_]+\\(\\[[^]]+\\]\\)" 1 font-lock-preprocessor-face prepend)))
0
-
0
-;; Constants
0
-
0
-(defconst haml-mode-version "0.0.1" "Version of `haml-mode.'")
0
-
0
-(defconst haml-blank-line-re "^[ \t]*$"
0
- "Regexp matching a line containing only whitespace.")
0
-
0
-; Base for Regexen matching a Haml tag.
0
-(setq haml-tag-re-base (hre "\\([%\\.#][^ \t]*\\)\\({.*}\\)?\\(\\[.*\\]\\)?"))
0
-
0
-(defconst haml-tag-nest-re (concat haml-tag-re-base "[ \t]*$")
0
- "Regexp matching a Haml tag that can have nested elements.")
0
-
0
-(defconst haml-tag-re (concat haml-tag-re-base "\\(.?\\)")
0
- "Regexp matching a Haml tag.")
0
-
0
-(defconst haml-block-re (hre "[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$")
0
- "Regexp matching a Ruby block in Haml.")
0
-
0
-(defconst haml-block-cont-re (hre (concat "-[ \t]*"
0
- (regexp-opt '("else" "elsif"
0
- "rescue" "ensure"
0
- "when"))))
0
- "Regexp matching a continued Ruby block in Haml.")
0
-
0
-(defconst haml-html-comment-re (hre "/\\(\\[.*\\]\\)?[ \t]*$")
0
- "Regexp matching a Haml HTML comment command.")
0
-
0
-(defconst haml-comment-re (hre "-#[ \t]$")
0
- "Regexp matching a Haml comment command.")
0
-
0
-(defconst haml-filter-re (hre ":")
0
- "Regexp matching a Haml filter command.")
0
+(defconst haml-font-lock-keywords
0
+ '(("^ *\\(\t\\)" 1 'haml-tab-face)
0
+ ("^!!!.*" 0 font-lock-constant-face)
0
+ ("\\('[^']*'\\)" 1 font-lock-string-face append)
0
+ ("\\(\"[^\"]*\"\\)" 1 font-lock-string-face append)
0
+ ("&?:\\w+" 0 font-lock-constant-face append)
0
+ ("@[a-z0-9_]+" 0 font-lock-variable-name-face append)
0
+ ("| *$" 0 font-lock-string-face)
0
+ ("^[ \t]*\\(/.*\\)$" 1 font-lock-comment-face append)
0
+ ("^ *\\(#[a-z0-9_]+\/?\\)" 1 font-lock-keyword-face)
0
+ ("^ *\\(\\.[a-z0-9_]+\/?\\)" 1 font-lock-type-face)
0
+ ("^ *\\(%[a-z0-9_]+\/?\\)" 1 font-lock-function-name-face)
0
+ ("^ *\\(#[a-z0-9_]+\/?\\)" (1 font-lock-keyword-face)
0
+ ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
0
+ ("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
0
+ ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
0
+ ("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
0
+ ("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
0
+ ("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
0
+ ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
0
+ ("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
0
+ ("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
0
+ ("^ *\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
0
+ ("^ *[\\.#%a-z0-9_]+\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
0
+ ("^ *[\\.#%a-z0-9_]+\\({[^}]+}\\)" 1 font-lock-preprocessor-face prepend)
0
+ ("^ *[\\.#%a-z0-9_]+\\(\\[[^]]+\\]\\)" 1 font-lock-preprocessor-face prepend)))
0
 
0
 ;; Mode setup
0
 
0
@@ -146,45 +101,169 @@
0
     table)
0
   "Syntax table in use in haml-mode buffers.")
0
 
0
-(defvar haml-mode-map ()
0
- "Keymap used in `haml-mode' buffers.")
0
-(if haml-mode-map
0
- nil
0
- (setq haml-mode-map (make-sparse-keymap))
0
- (define-key haml-mode-map [backspace] 'haml-electric-backspace)
0
- (define-key haml-mode-map "\C-?" 'haml-electric-backspace)
0
- (define-key haml-mode-map "\C-j" 'newline-and-indent))
0
+(defvar haml-mode-map
0
+ (let ((map (make-sparse-keymap)))
0
+ (define-key map [backspace] 'haml-electric-backspace)
0
+ (define-key map "\C-?" 'haml-electric-backspace)
0
+ (define-key map "\C-\M-f" 'haml-forward-sexp)
0
+ (define-key map "\C-\M-b" 'haml-backward-sexp)
0
+ (define-key map "\C-\M-u" 'haml-up-list)
0
+ (define-key map "\C-\M-d" 'haml-down-list)
0
+ (define-key map "\C-C\C-k" 'haml-kill-line-and-indent)
0
+ map))
0
 
0
 (define-derived-mode haml-mode fundamental-mode "Haml"
0
- "Simple mode to edit Haml.
0
+ "Major mode for editing Haml files.
0
 
0
 \\{haml-mode-map}"
0
   (set-syntax-table haml-mode-syntax-table)
0
   (set (make-local-variable 'indent-line-function) 'haml-indent-line)
0
- (set (make-local-variable 'font-lock-defaults)
0
- '((haml-font-lock-keywords-1)
0
- nil
0
- t)))
0
+ (set (make-local-variable 'indent-region-function) 'haml-indent-region)
0
+ (set (make-local-variable 'forward-sexp-function) 'haml-forward-sexp)
0
+ (setq font-lock-defaults '((haml-font-lock-keywords) nil t)))
0
+
0
+;; Navigation
0
+
0
+(defun haml-forward-through-whitespace (&optional backward)
0
+ "Move the point forward at least one line, until it reaches
0
+either the end of the buffer or a line with no whitespace.
0
+
0
+If `backward' is non-nil, move the point backward instead."
0
+ (let ((arg (if backward -1 1))
0
+ (endp (if backward 'bobp 'eobp)))
0
+ (loop do (forward-line arg)
0
+ while (and (not (funcall endp))
0
+ (looking-at "^[ \t]*$")))))
0
+
0
+(defun haml-at-indent-p ()
0
+ "Returns whether or not the point is at the first
0
+non-whitespace character in a line or whitespace preceding that
0
+character."
0
+ (let ((opoint (point)))
0
+ (save-excursion
0
+ (back-to-indentation)
0
+ (>= (point) opoint))))
0
+
0
+(defun haml-forward-sexp (&optional arg)
0
+ "Move forward across one nested expression.
0
+With `arg', do it that many times. Negative arg -N means move
0
+backward across N balanced expressions.
0
+
0
+A sexp in Haml is defined as a line of Haml code as well as any
0
+lines nested beneath it."
0
+ (interactive "p")
0
+ (or arg (setq arg 1))
0
+ (if (and (< arg 0) (not (haml-at-indent-p)))