<commit_before>class RainbowMode < Formula
  desc "Minor mode for highlighting color-strings"
  homepage "http://elpa.gnu.org/packages/rainbow-mode.html"
  url "http://elpa.gnu.org/packages/rainbow-mode-0.11.el"
  sha256 "72ed06fb4f2f3ab1d5e2a9aac10864bce1d45f1923e52ee9a8e6d8f2930e16a5"
  head "http://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/packages/rainbow-mode/rainbow-mode.el"

  def install
    version_string = build.stable? ? "-#{version}" : ""
    (share/"emacs/site-lisp/rainbow-mode").install "rainbow-mode#{version_string}.el" => "rainbow-mode.el"
  end

  def caveats; <<-EOS.undent
    Add hooks to activate rainbow-mode where desired, like so:

      (require 'rainbow-mode)
      (add-hook 'scss-mode-hook 'scss-rainbow-hook)
      (defun scss-rainbow-hook ()
        "Colorize color strings."
        (rainbow-mode 1))
    EOS
  end
end<commit_msg>rainbow mode: add test, and compile during install<commit_after>require File.expand_path("../../emacs", __FILE__)

class RainbowMode < Formula
  desc "Minor mode for highlighting color-strings"
  homepage "http://elpa.gnu.org/packages/rainbow-mode.html"
  url "http://elpa.gnu.org/packages/rainbow-mode-0.11.el"
  sha256 "72ed06fb4f2f3ab1d5e2a9aac10864bce1d45f1923e52ee9a8e6d8f2930e16a5"
  head "http://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/packages/rainbow-mode/rainbow-mode.el"

  depends_on :emacs => "22.1"

  def install
    mv "rainbow-mode-#{version}.el", "rainbow-mode.el" if build.stable?

    Emacs.compile "rainbow-mode.el"
    (share/"emacs/site-lisp/rainbow-mode").install "rainbow-mode.el",
                                                   "rainbow-mode.elc"
  end

  def caveats; <<-EOS.undent
    Add hooks to activate rainbow-mode where desired, like so:

    (require 'rainbow-mode)
    (add-hook 'scss-mode-hook 'scss-rainbow-hook)
    (defun scss-rainbow-hook ()
      "Colorize color strings."
      (rainbow-mode 1))
  EOS
  end

  test do
    (testpath/"test.el").write <<-EOS.undent
      (add-to-list 'load-path "#{HOMEBREW_PREFIX}/share/emacs/site-lisp")
      (load "rainbow-mode")
      (rainbow-mode 1)
      (print (minibuffer-prompt-width))
    EOS
    assert_equal "0", shell_output("emacs -batch -l #{testpath}/test.el").strip
  end
end
{'fraction_non_alphanumeric': 0.14209591474245115, 'fraction_numerical': 0.040408525754884544, 'mean_word_length': 3.172222222222222, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2229013', 'n_tokens_mistral': 928, 'n_tokens_neox': 847, 'n_words': 143}