                        ruby-font-lock-syntactic-keywords))
 
 (defun haml-handle-filter (filter-name limit fn)
-  "Call `fn' with `beg' and `end' params if a :filter-name block is found."
+  "If a FILTER-NAME filter is found within LIMIT, run FN on that filter.
+
+FN is passed a pair of points representing the beginning and end
+of the filtered text."
   (when (re-search-forward (haml-nested-regexp (concat ":" filter-name)) limit t)
     (funcall fn (+ 2 (match-beginning 2)) (match-end 2))))
 
 (defun haml-fontify-filter-region (filter-name limit &rest fontify-region-args)
-  "Find a filter block of type `filter-name' and call `haml-fontify-region'
-with the provided args."
+  "If a FILTER-NAME filter is found within LIMIT, fontify it.
+
+The fontification is done by passing FONTIFY-REGION-ARGS to
+`haml-fontify-region'."
   (haml-handle-filter filter-name limit
                       (lambda (beg end)
                         (apply 'haml-fontify-region

                                       fontify-region-args)))))

(defun haml-highlight-ruby-filter-block (limit)
  "Highlight a Ruby script expression inside ':ruby' filter block."
  (haml-handle-filter "ruby" limit 'haml-fontify-region-as-ruby))

(defun haml-highlight-css-filter-block (limit)
  "Highlight CSS inside ':css' filter block.

For this to work, 'css-mode.el' must be available, as is automatically
the case in Emacs 23."
  (if (boundp 'css-font-lock-keywords)
      (haml-fontify-filter-region "css" limit css-font-lock-keywords nil nil)))

(defun haml-highlight-js-filter-block (limit)
  "Highlight Javascript inside ':javascript' filter block.

For this to work, Karl Landström's 'javascript.el' must be available,
e.g. by installing it from ELPA."
  (if (boundp 'js-font-lock-keywords-3)
      (haml-fontify-filter-region "javascript"
                                  limit

(defconst haml-comment-re "^ *\\(?:-\\#\\|/\\)")

(defun haml-fontify-region (beg end keywords syntax-table syntactic-keywords)
  "Fontify a region between BEG and END using another mode's fontification.

KEYWORDS, SYNTAX-TABLE, and SYNTACTIC-KEYWORDS are the values of that mode's
`font-lock-keywords', `font-lock-syntax-table',
and `font-lock-syntactic-keywords', respectively."
  (save-excursion
    (save-match-data
      (let ((font-lock-keywords keywords)
