           (bolp)
           (looking-at "^[ \t]+$"))
       (backward-delete-char arg)
-    (let ((ci (current-column)))
-      (beginning-of-line)
-      (if haml-backspace-backdents-nesting
-          (haml-mark-sexp-but-not-next-line)
-        (set-mark (save-excursion (end-of-line) (point))))
-      (haml-reindent-region-by (* (- arg) haml-indent-offset))
-      (back-to-indentation)
-      (pop-mark))))
+    (save-excursion
+      (let ((ci (current-column)))
+        (beginning-of-line)
+        (if haml-backspace-backdents-nesting
+            (haml-mark-sexp-but-not-next-line)
+          (set-mark (save-excursion (end-of-line) (point))))
+        (haml-reindent-region-by (* (- arg) haml-indent-offset))
+        (back-to-indentation)
+        (pop-mark)))))
 
 (defun haml-kill-line-and-indent ()
   "Kill the current line, and re-indent all lines nested beneath it."


;; Font lock

(defconst haml-font-lock-keywords
  '(("^ *\\(\t\\)"               1 'haml-tab-face)
    ("^!!!.*"                    0 font-lock-constant-face)
    ("\\('[^']*'\\)"             1 font-lock-string-face append)
    ("\\(\"[^\"]*\"\\)"          1 font-lock-string-face append)
    ("&?:\\w+"                   0 font-lock-constant-face append)
    ("@[a-z0-9_]+"               0 font-lock-variable-name-face append)
    ("| *$"                      0 font-lock-string-face)
    ("^[ \t]*\\(/.*\\)$"         1 font-lock-comment-face append)

    ("^ *[\\.#%a-z0-9_]+\\({[^}]+}\\)"      1 font-lock-preprocessor-face prepend)
    ("^ *[\\.#%a-z0-9_]+\\(\\[[^]]+\\]\\)"  1 font-lock-preprocessor-face prepend)))

(defconst haml-filter-re "^ *\\(:\\)\\w+")
(defconst haml-comment-re "^ *\\(-\\)\\#")

(defun* haml-extend-region ()
  "Extend the font-lock region to encompass filters and comments."
  (let ((old-beg font-lock-beg)
        (old-end font-lock-end))
    (save-excursion
      (goto-char font-lock-beg)
      (beginning-of-line)
      (unless (or (looking-at haml-filter-re)
                  (looking-at haml-comment-re))
        (return-from haml-extend-region))
      (setq font-lock-beg (point))
      (haml-forward-sexp)
      (beginning-of-line)
      (setq font-lock-end (max font-lock-end (point))))
    (or (/= old-beg font-lock-beg)
        (/= old-end font-lock-end))))


;; Mode setup

(defvar haml-mode-syntax-table
