nex3 / haml

HTML Abstraction Markup Language - A Markup Haiku

This URL has Read+Write access

haml / extra / haml-mode.el
f312b31e » technomancy 2009-01-14 Updated headers for haml-mo... 1 ;;; haml-mode.el --- Major mode for editing Haml 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: 1.0
8 ;; Keywords: markup, language
9
10 ;;; Commentary:
11
12 ;; Because Haml's indentation schema is similar
13 ;; to that of YAML and Python, many indentation-related
14 ;; functions are similar to those in yaml-mode and python-mode.
15
16 ;; To install, save this on your load path and add the following to
17 ;; your .emacs file:
18 ;;
19 ;; (require 'haml-mode)
23f8e7d4 » nex3 2007-03-15 Okay, let's fix the massive... 20
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 21 ;;; Code:
22
57d05a12 » nex3 2008-04-22 Add a custom indent-region ... 23 (eval-when-compile (require 'cl))
24
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 25 ;; User definable variables
26
27 (defgroup haml nil
28 "Support for the Haml template language."
29 :group 'languages
30 :prefix "haml-")
31
32 (defcustom haml-mode-hook nil
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 33 "Hook run when entering Haml mode."
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 34 :type 'hook
35 :group 'haml)
36
37 (defcustom haml-indent-offset 2
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 38 "Amount of offset per level of indentation."
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 39 :type 'integer
40 :group 'haml)
41
7b9c2d5f » nex3 2008-05-04 [Emacs] Have haml-electric-... 42 (defcustom haml-backspace-backdents-nesting t
43 "Non-nil to have `haml-electric-backspace' re-indent all code
44 nested beneath the backspaced line be re-indented along with the
45 line itself."
46 :type 'boolean
47 :group 'haml)
48
23f8e7d4 » nex3 2007-03-15 Okay, let's fix the massive... 49 (defface haml-tab-face
d08fc6ed » nex3 2008-04-22 Highlight invalid tabs in h... 50 '((((class color)) (:background "hotpink"))
51 (t (:reverse-video t)))
23f8e7d4 » nex3 2007-03-15 Okay, let's fix the massive... 52 "Face to use for highlighting tabs in Haml files."
53 :group 'faces
54 :group 'haml)
55
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 56 (defvar haml-indent-function 'haml-indent-p
57 "This function should look at the current line and return true
58 if the next line could be nested within this line.")
59
60 (defvar haml-block-openers
012ca0ff » nex3 2008-04-27 Allow object_refs to go bef... 61 `("^ *\\([%\\.#][^ \t]*\\)\\(\\[.*\\]\\)?\\({.*}\\)?\\(\\[.*\\]\\)?[ \t]*$"
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 62 "^ *[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$"
3e922fbd » nex3 2008-05-10 [Emacs] Make indentation wo... 63 ,(concat "^ *-[ \t]*\\("
4895df91 » nex3 2008-07-28 Add more Ruby block keyword... 64 (regexp-opt '("if" "unless" "while" "until" "else"
65 "begin" "elsif" "rescue" "ensure" "when"))
3e922fbd » nex3 2008-05-10 [Emacs] Make indentation wo... 66 "\\)")
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 67 "^ */\\(\\[.*\\]\\)?[ \t]*$"
68 "^ *-#"
69 "^ *:")
70 "A list of regexps that match lines of Haml that could have
71 text nested beneath them.")
13c868e0 » nex3 2008-04-22 Make sass-mode inherit from... 72
827aaa31 » nex3 2007-03-17 Some syntax highlighting fo... 73 ;; Font lock
2d39c8a3 » nex3 2007-04-02 More haml-mode font stuff. ... 74
13605b4a » nex3 2008-12-05 [Emacs] Better support for ... 75 (defun haml-nested-regexp (re)
76 (concat "^\\( *\\)" re "\n\\(?:\\(?:\\1 .*\\| *\\)\n\\)*"))
77
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 78 (defconst haml-font-lock-keywords
13605b4a » nex3 2008-12-05 [Emacs] Better support for ... 79 `((,(haml-nested-regexp "-#.*") 0 font-lock-comment-face)
80 (,(haml-nested-regexp ":\\w+") 0 font-lock-string-face)
81 ("^ *\\(\t\\)" 1 'haml-tab-face)
d08fc6ed » nex3 2008-04-22 Highlight invalid tabs in h... 82 ("^!!!.*" 0 font-lock-constant-face)
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 83 ("\\('[^']*'\\)" 1 font-lock-string-face append)
84 ("\\(\"[^\"]*\"\\)" 1 font-lock-string-face append)
85 ("@[a-z0-9_]+" 0 font-lock-variable-name-face append)
86 ("| *$" 0 font-lock-string-face)
87 ("^[ \t]*\\(/.*\\)$" 1 font-lock-comment-face append)
88 ("^ *\\(#[a-z0-9_]+\/?\\)" 1 font-lock-keyword-face)
89 ("^ *\\(\\.[a-z0-9_]+\/?\\)" 1 font-lock-type-face)
90 ("^ *\\(%[a-z0-9_]+\/?\\)" 1 font-lock-function-name-face)
91 ("^ *\\(#[a-z0-9_]+\/?\\)" (1 font-lock-keyword-face)
92 ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
93 ("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
94 ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
95 ("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
96 ("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
97 ("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
98 ("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
99 ("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
100 ("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
101 ("^ *\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
102 ("^ *[\\.#%a-z0-9_]+\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
103 ("^ *[\\.#%a-z0-9_]+\\({[^}]+}\\)" 1 font-lock-preprocessor-face prepend)
104 ("^ *[\\.#%a-z0-9_]+\\(\\[[^]]+\\]\\)" 1 font-lock-preprocessor-face prepend)))
827aaa31 » nex3 2007-03-17 Some syntax highlighting fo... 105
13605b4a » nex3 2008-12-05 [Emacs] Better support for ... 106 (defconst haml-filter-re "^ *\\(:\\)\\w+")
107 (defconst haml-comment-re "^ *\\(-\\)\\#")
108
109 (defun* haml-extend-region ()
110 "Extend the font-lock region to encompass filters and comments."
111 (let ((old-beg font-lock-beg)
112 (old-end font-lock-end))
113 (save-excursion
114 (goto-char font-lock-beg)
115 (beginning-of-line)
116 (unless (or (looking-at haml-filter-re)
117 (looking-at haml-comment-re))
118 (return-from haml-extend-region))
119 (setq font-lock-beg (point))
120 (haml-forward-sexp)
121 (beginning-of-line)
122 (setq font-lock-end (max font-lock-end (point))))
123 (or (/= old-beg font-lock-beg)
124 (/= old-end font-lock-end))))
125
126
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 127 ;; Mode setup
128
2d39c8a3 » nex3 2007-04-02 More haml-mode font stuff. ... 129 (defvar haml-mode-syntax-table
130 (let ((table (make-syntax-table)))
131 (modify-syntax-entry ?: "." table)
132 (modify-syntax-entry ?_ "w" table)
133 table)
79f3f71b » nex3 2007-03-23 Updated haml-mode, thanks t... 134 "Syntax table in use in haml-mode buffers.")
135
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 136 (defvar haml-mode-map
137 (let ((map (make-sparse-keymap)))
138 (define-key map [backspace] 'haml-electric-backspace)
139 (define-key map "\C-?" 'haml-electric-backspace)
36d69ad8 » nex3 2008-11-18 Don't clobber normal sexp f... 140 (define-key map "\C-c\C-f" 'haml-forward-sexp)
141 (define-key map "\C-c\C-b" 'haml-backward-sexp)
142 (define-key map "\C-c\C-u" 'haml-up-list)
143 (define-key map "\C-c\C-d" 'haml-down-list)
144 (define-key map "\C-c\C-k" 'haml-kill-line-and-indent)
13b699a8 » technomancy 2009-01-14 Added haml-output-buffer fu... 145 (define-key map "\C-c\C-r" 'haml-output-region)
146 (define-key map "\C-c\C-l" 'haml-output-buffer)
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 147 map))
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 148
fe46a65d » nex3 2008-11-27 Autoload emacs modes. 149 ;;;###autoload
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 150 (define-derived-mode haml-mode fundamental-mode "Haml"
4d973434 » nex3 2008-04-22 Clean up haml- and sass-mod... 151 "Major mode for editing Haml files.
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 152
153 \\{haml-mode-map}"
79f3f71b » nex3 2007-03-23 Updated haml-mode, thanks t... 154 (set-syntax-table haml-mode-syntax-table)
13605b4a » nex3 2008-12-05 [Emacs] Better support for ... 155 (add-to-list 'font-lock-extend-region-functions 'haml-extend-region)
156 (set (make-local-variable 'font-lock-multiline) t)
23f8e7d4 » nex3 2007-03-15 Okay, let's fix the massive... 157 (set (make-local-variable 'indent-line-function) 'haml-indent-line)
57d05a12 » nex3 2008-04-22 Add a custom indent-region ... 158 (set (make-local-variable 'indent-region-function) 'haml-indent-region)
13605b4a » nex3 2008-12-05 [Emacs] Better support for ... 159 (set (make-local-variable 'parse-sexp-lookup-properties) t)
0f39b4f2 » nex3 2008-12-11 [Emacs] Add support for com... 160 (setq comment-start "-#")
fe9e7db9 » nex3 2008-10-06 Make sure haml- and sass-mo... 161 (setq indent-tabs-mode nil)
f1ac8764 » nex3 2008-04-22 Minor formatting change in ... 162 (setq font-lock-defaults '((haml-font-lock-keywords) nil t)))
23f8e7d4 » nex3 2007-03-15 Okay, let's fix the massive... 163
f061b66c » nex3 2008-12-11 [Emacs] Add a function for ... 164 ;; Useful functions
165
166 (defun haml-comment-block ()
167 "Comment the current block of Haml code."
168 (interactive)
169 (save-excursion
170 (let ((indent (current-indentation)))
171 (back-to-indentation)
172 (insert "-#")
173 (newline)
174 (indent-to indent)
a961edb1 » nex3 2008-12-15 [Emacs] Add a function for ... 175 (beginning-of-line)
176 (haml-mark-sexp)
177 (haml-reindent-region-by haml-indent-offset))))
178
179 (defun haml-uncomment-block ()
180 "Uncomment the current block of Haml code."
181 (interactive)
182 (save-excursion
183 (beginning-of-line)
184 (while (not (looking-at haml-comment-re))
185 (haml-up-list)
186 (beginning-of-line))
187 (haml-mark-sexp)
188 (kill-line 1)
189 (haml-reindent-region-by (- haml-indent-offset))))
f061b66c » nex3 2008-12-11 [Emacs] Add a function for ... 190
ec90f8cf » febuiles 2008-12-30 Reindent code regions befor... 191 (defun haml-replace-region (start end)
1185a59a » nex3 2008-12-29 Minor grammar changes. 192 "Replaces the current block of Haml code with the HTML equivalent."
8a9e0bcb » febuiles 2008-12-29 Adding two new commands to ... 193 (interactive "r")
ec90f8cf » febuiles 2008-12-30 Reindent code regions befor... 194 (save-excursion
195 (goto-char end)
196 (setq end (point-marker))
197 (goto-char start)
198 (let ((ci (current-indentation)))
199 (while (re-search-forward "^ +" end t)
200 (replace-match (make-string (- (current-indentation) ci) ? ))))
201 (shell-command-on-region start end "haml" "haml-output" t)))
202
203 (defun haml-output-region (start end)
1185a59a » nex3 2008-12-29 Minor grammar changes. 204 "Displays the HTML output for the current block of Haml code."
8a9e0bcb » febuiles 2008-12-29 Adding two new commands to ... 205 (interactive "r")
ec90f8cf » febuiles 2008-12-30 Reindent code regions befor... 206 (kill-new (buffer-substring start end))
207 (with-temp-buffer
208 (yank)
209 (haml-indent-region (point-min) (point-max))
210 (shell-command-on-region (point-min) (point-max) "haml" "haml-output")))
8a9e0bcb » febuiles 2008-12-29 Adding two new commands to ... 211
13b699a8 » technomancy 2009-01-14 Added haml-output-buffer fu... 212 (defun haml-output-buffer ()
213 "Displays the HTML output for entire buffer."
214 (interactive)
215 (haml-output-region (point-min) (point-max)))
216
b4337e56 » nex3 2008-05-04 [Emacs] Add forward- and ba... 217 ;; Navigation
218
219 (defun haml-forward-through-whitespace (&optional backward)
220 "Move the point forward at least one line, until it reaches
221 either the end of the buffer or a line with no whitespace.
222
223 If `backward' is non-nil, move the point backward instead."
224 (let ((arg (if backward -1 1))
225 (endp (if backward 'bobp 'eobp)))
226 (loop do (forward-line arg)
227 while (and (not (funcall endp))
228 (looking-at "^[ \t]*$")))))
229
230 (defun haml-at-indent-p ()
231 "Returns whether or not the point is at the first
232 non-whitespace character in a line or whitespace preceding that
233 character."
234 (let ((opoint (point)))
235 (save-excursion
236 (back-to-indentation)
237 (>= (point) opoint))))
238
239 (defun haml-forward-sexp (&optional arg)
240 "Move forward across one nested expression.
241 With `arg', do it that many times. Negative arg -N means move
242 backward across N balanced expressions.
243
244 A sexp in Haml is defined as a line of Haml code as well as any
245 lines nested beneath it."
246 (interactive "p")
247 (or arg (setq arg 1))
248 (if (and (< arg 0) (not (haml-at-indent-p)))
249 (back-to-indentation)
250 (while (/= arg 0)
251 (let ((indent (current-indentation)))
252 (loop do (haml-forward-through-whitespace (< arg 0))
253 while (and (not (eobp))
254 (not (bobp))
255 (> (current-indentation) indent)))
256 (back-to-indentation)
a961edb1 » nex3 2008-12-15 [Emacs] Add a function for ... 257 (setq arg (+ arg (if (> arg 0) -1 1)))))))
b4337e56 » nex3 2008-05-04 [Emacs] Add forward- and ba... 258
259 (defun haml-backward-sexp (&optional arg)
260 "Move backward across one nested expression.
261 With ARG, do it that many times. Negative arg -N means move
262 forward across N balanced expressions.
263
264 A sexp in Haml is defined as a line of Haml code as well as any
265 lines nested beneath it."
266 (interactive "p")
267 (haml-forward-sexp (if arg (- arg) -1)))
268
ca796ea2 » nex3 2008-05-04 [Emacs] Add up-list and dow... 269 (defun haml-up-list (&optional arg)
270 "Move out of one level of nesting.
271 With ARG, do this that many times."
272 (interactive "p")
273 (or arg (setq arg 1))
274 (while (> arg 0)
275 (let ((indent (current-indentation)))
276 (loop do (haml-forward-through-whitespace t)
277 while (and (not (bobp))
278 (>= (current-indentation) indent)))
279 (setq arg (- arg 1))))
280 (back-to-indentation))
281
282 (defun haml-down-list (&optional arg)
283 "Move down one level of nesting.
284 With ARG, do this that many times."
285 (interactive "p")
286 (or arg (setq arg 1))
287 (while (> arg 0)
288 (let ((indent (current-indentation)))
289 (haml-forward-through-whitespace)
290 (when (<= (current-indentation) indent)
291 (haml-forward-through-whitespace t)
292 (back-to-indentation)
293 (error "Nothing is nested beneath this line"))
294 (setq arg (- arg 1))))
295 (back-to-indentation))
296
a961edb1 » nex3 2008-12-15 [Emacs] Add a function for ... 297 (defun haml-mark-sexp ()
298 "Marks the next Haml block."
299 (let ((forward-sexp-function 'haml-forward-sexp))
300 (mark-sexp)))
301
509165e3 » nex3 2008-05-04 [Emacs] Add a function to k... 302 (defun haml-mark-sexp-but-not-next-line ()
a961edb1 » nex3 2008-12-15 [Emacs] Add a function for ... 303 "Marks the next Haml block, but puts the mark at the end of the
509165e3 » nex3 2008-05-04 [Emacs] Add a function to k... 304 last line of the sexp rather than the first non-whitespace
305 character of the next line."
a961edb1 » nex3 2008-12-15 [Emacs] Add a function for ... 306 (haml-mark-sexp)
509165e3 » nex3 2008-05-04 [Emacs] Add a function to k... 307 (set-mark
308 (save-excursion
309 (goto-char (mark))
310 (forward-line -1)
311 (end-of-line)
312 (point))))
313
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 314 ;; Indentation and electric keys
315
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 316 (defun haml-indent-p ()
317 "Returns true if the current line can have lines nested beneath it."
318 (loop for opener in haml-block-openers
319 if (looking-at opener) return t
3e922fbd » nex3 2008-05-10 [Emacs] Make indentation wo... 320 finally return nil))
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 321
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 322 (defun haml-compute-indentation ()
323 "Calculate the maximum sensible indentation for the current line."
324 (save-excursion
325 (beginning-of-line)
5f09785d » nex3 2008-04-22 The indentation of the firs... 326 (if (bobp) 0
b4337e56 » nex3 2008-05-04 [Emacs] Add forward- and ba... 327 (haml-forward-through-whitespace t)
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 328 (+ (current-indentation)
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 329 (if (funcall haml-indent-function) haml-indent-offset
330 0)))))
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 331
57d05a12 » nex3 2008-04-22 Add a custom indent-region ... 332 (defun haml-indent-region (start end)
333 "Indent each nonblank line in the region.
334 This is done by indenting the first line based on
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 335 `haml-compute-indentation' and preserving the relative
240251c1 » nex3 2008-04-22 Repeating haml-indent-regio... 336 indentation of the rest of the region.
337
338 If this command is used multiple times in a row, it will cycle
339 between possible indentations."
57d05a12 » nex3 2008-04-22 Add a custom indent-region ... 340 (save-excursion
341 (goto-char end)
342 (setq end (point-marker))
343 (goto-char start)
344 (let (this-line-column current-column
240251c1 » nex3 2008-04-22 Repeating haml-indent-regio... 345 (next-line-column
346 (if (and (equal last-command this-command) (/= (current-indentation) 0))
347 (* (/ (- (current-indentation) 1) haml-indent-offset) haml-indent-offset)
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 348 (haml-compute-indentation))))
57d05a12 » nex3 2008-04-22 Add a custom indent-region ... 349 (while (< (point) end)
350 (setq this-line-column next-line-column
351 current-column (current-indentation))
352 ;; Delete whitespace chars at beginning of line
353 (delete-horizontal-space)
354 (unless (eolp)
355 (setq next-line-column (save-excursion
356 (loop do (forward-line 1)
357 while (and (not (eobp)) (looking-at "^[ \t]*$")))
358 (+ this-line-column
359 (- (current-indentation) current-column))))
360 ;; Don't indent an empty line
361 (unless (eolp) (indent-to this-line-column)))
362 (forward-line 1)))
363 (move-marker end nil)))
364
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 365 (defun haml-indent-line ()
366 "Indent the current line.
367 The first time this command is used, the line will be indented to the
368 maximum sensible indentation. Each immediately subsequent usage will
369 back-dent the line by `haml-indent-offset' spaces. On reaching column
370 0, it will cycle back to the maximum sensible indentation."
371 (interactive "*")
372 (let ((ci (current-indentation))
373 (cc (current-column))
839ad959 » nex3 2008-04-24 Further DRY up haml- and sa... 374 (need (haml-compute-indentation)))
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 375 (save-excursion
376 (beginning-of-line)
377 (delete-horizontal-space)
378 (if (and (equal last-command this-command) (/= ci 0))
379 (indent-to (* (/ (- ci 1) haml-indent-offset) haml-indent-offset))
380 (indent-to need)))
381 (if (< (current-column) (current-indentation))
382 (forward-to-indentation 0))))
383
509165e3 » nex3 2008-05-04 [Emacs] Add a function to k... 384 (defun haml-reindent-region-by (n)
385 "Add N spaces to the beginning of each line in the region.
386 If N is negative, will remove the spaces instead. Assumes all
387 lines in the region have indentation >= that of the first line."
388 (let ((ci (current-indentation)))
389 (save-excursion
390 (replace-regexp (concat "^" (make-string ci ? ))
391 (make-string (max 0 (+ ci n)) ? )
392 nil (point) (mark)))))
393
04cd0278 » nex3 2007-03-07 Added a handy backspace bin... 394 (defun haml-electric-backspace (arg)
395 "Delete characters or back-dent the current line.
7b9c2d5f » nex3 2008-05-04 [Emacs] Have haml-electric-... 396 If invoked following only whitespace on a line, will back-dent
397 the line and all nested lines to the immediately previous
398 multiple of `haml-indent-offset' spaces.
399
400 Set `haml-backspace-backdents-nesting' to nil to just back-dent
401 the current line."
04cd0278 » nex3 2007-03-07 Added a handy backspace bin... 402 (interactive "*p")
7b9c2d5f » nex3 2008-05-04 [Emacs] Have haml-electric-... 403 (if (or (/= (current-indentation) (current-column))
404 (bolp)
405 (looking-at "^[ \t]+$"))
fdb9ff88 » nex3 2008-04-22 Don't allow customization o... 406 (backward-delete-char arg)
36d69ad8 » nex3 2008-11-18 Don't clobber normal sexp f... 407 (save-excursion
408 (let ((ci (current-column)))
409 (beginning-of-line)
410 (if haml-backspace-backdents-nesting
411 (haml-mark-sexp-but-not-next-line)
412 (set-mark (save-excursion (end-of-line) (point))))
413 (haml-reindent-region-by (* (- arg) haml-indent-offset))
414 (back-to-indentation)
415 (pop-mark)))))
04cd0278 » nex3 2007-03-07 Added a handy backspace bin... 416
509165e3 » nex3 2008-05-04 [Emacs] Add a function to k... 417 (defun haml-kill-line-and-indent ()
418 "Kill the current line, and re-indent all lines nested beneath it."
419 (interactive)
420 (beginning-of-line)
421 (haml-mark-sexp-but-not-next-line)
422 (kill-line 1)
423 (haml-reindent-region-by (* -1 haml-indent-offset)))
424
13605b4a » nex3 2008-12-05 [Emacs] Better support for ... 425 (defun haml-indent-string ()
426 "Return the indentation string for `haml-indent-offset'."
427 (mapconcat 'identity (make-list haml-indent-offset " ") ""))
428
1880b877 » technomancy 2009-01-14 Add autoloads for auto-mode... 429 ;;;###autoload
430 (add-to-list 'auto-mode-alist '("\\.haml$" . haml-mode))
04cd0278 » nex3 2007-03-07 Added a handy backspace bin... 431
1880b877 » technomancy 2009-01-14 Add autoloads for auto-mode... 432 ;; Setup/Activation
e7555b40 » nex3 2007-03-07 Added a very basic haml-mod... 433 (provide 'haml-mode)
1880b877 » technomancy 2009-01-14 Add autoloads for auto-mode... 434 ;;; haml-mode.el ends here