       (if (< (current-column) (current-indentation))
           (forward-to-indentation 0))))
 
+(defun haml-reindent-region-by (n)
+  "Add N spaces to the beginning of each line in the region.
+If N is negative, will remove the spaces instead.  Assumes all
+lines in the region have indentation >= that of the first line."
+  (let ((ci (current-indentation)))
+    (save-excursion
+      (replace-regexp (concat "^" (make-string ci ? ))
+                      (make-string (max 0 (+ ci n)) ? )
+                      nil (point) (mark)))))
+
 (defun haml-electric-backspace (arg)
   "Delete characters or back-dent the current line.
 If invoked following only whitespace on a line, will back-dent

      (backward-delete-char arg)
    (let ((ci (current-column)))
      (beginning-of-line)
      (if (not haml-backspace-backdents-nesting)
          (set-mark (save-excursion (end-of-line) (point)))
        (mark-sexp)
        (set-mark
         (save-excursion
           (goto-char (mark))
           (beginning-of-line)
           (point))))
      (save-excursion
        (replace-regexp (concat "^" (make-string ci ? ))
                        (make-string (max 0 (- ci (* arg haml-indent-offset))) ? )
                        nil (point) (mark)))
      (back-to-indentation)
      (pop-mark))))

;; Setup/Activation

(provide 'haml-mode)

    (define-key map "\C-\M-b" 'haml-backward-sexp)
    (define-key map "\C-\M-u" 'haml-up-list)
    (define-key map "\C-\M-d" 'haml-down-list)
    (define-key map "\C-C\C-k" 'haml-kill-line-and-indent)
    map))

(define-derived-mode haml-mode fundamental-mode "Haml"
