         (error "Nothing is nested beneath this line"))
       (setq arg (- arg 1))))
   (back-to-indentation))
+
+(defun haml-mark-sexp-but-not-next-line ()
+  "Marks the next Haml sexp, but puts the mark at the end of the
+last line of the sexp rather than the first non-whitespace
+character of the next line."
+  (mark-sexp)
+  (set-mark
+   (save-excursion
+     (goto-char (mark))
+     (forward-line -1)
+     (end-of-line)
+     (point))))
 
 ;; Indentation and electric keys
 

      (if (< (current-column) (current-indentation))
          (forward-to-indentation 0))))

(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 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."
  (interactive)
  (beginning-of-line)
  (haml-mark-sexp-but-not-next-line)
  (kill-line 1)
  (haml-reindent-region-by (* -1 haml-indent-offset)))

;; Setup/Activation

(provide 'haml-mode)
