<commit_before>;;; haml-mode.el -- Major mode for editing Haml files
;;; Version 0.0.1
;;; Written by <NAME>

;;; Because Haml's indentation schema is similar
;;; to that of YAML and Python, many indentation-related
;;; functions are similar to those in yaml-mode and python-mode.

;;; To install, save this somewhere and add the following to your .emacs file:
;;; 
;;; (add-to-list 'load-path "/path/to/haml-mode.el")
;;; (require 'haml-mode nil 't)
;;; 

;;; Code:

;; User definable variables

(defgroup haml nil
  "Support for the Haml template language."
  :group 'languages
  :prefix "haml-")

(defcustom haml-mode-hook nil
  "*Hook run by `haml-mode'."
  :type 'hook
  :group 'haml)

(defcustom haml-indent-offset 2
  "*Amount of offset per level of indentation."
  :type 'integer
  :group 'haml)

(defcustom haml-backspace-function 'backward-delete-char-untabify
  "*Function called by `haml-electric-backspace' when deleting backwards."
  :type 'function
  :group 'haml)

(defface haml-tab-face
   '((((class color)) (:background "red" :foreground "red" :bold t))
     (t (:reverse-video t)))
  "Face to use for highlighting tabs in Haml files."
  :group 'faces
  :group 'haml)

;; Helper Functions

(defun string-* (str n)
  "Concatenates a string with itself n times."
  (if (= n 0) ""
    (concat str (string-* str (- n 1)))))

(defun find-if (f lst)
  "Returns the first element of a list for which a function returns a non-nil value, or nil if no such element is found."
  (while (not (or (null lst)
                  (apply f (list (car lst)))))
    (setq lst (cdr lst)))
  (if (null lst) nil (car lst)))

(defun hre (str)
  "Prepends a Haml-tab-matching regexp to str."
  (concat "^\\(" (string-* " " haml-indent-offset) "\\)*" str))

;; Font lock
(defconst haml-font-lock-keywords-1
  (list
   '("%\\w+"        . font-lock-function-name-face)
   '("#\\w+"        . font-lock-keyword-face)
   '("= .*"         . font-lock-string-face)
   '("[ \t]*- .*"   . font-lock-string-face)
   '("!!!"          . font-lock-constant-face)))

;; Constants

(defconst haml-mode-version "0.0.1" "Version of `haml-mode.'")

(defconst haml-blank-line-re "^[ \t]*$"
  "Regexp matching a line containing only whitespace.")

; Base for Regexen matching a Haml tag.
(setq haml-tag-re-base (hre "\\([%\\.#][^ \t]*\\)\\({.*}\\)?\\(\\[.*\\]\\)?"))

(defconst haml-tag-nest-re (concat haml-tag-re-base "[ \t]*$")
  "Regexp matching a Haml tag that can have nested elements.")

(defconst haml-tag-re (concat haml-tag-re-base "\\(.?\\)")
  "Regexp matching a Haml tag.")

(defconst haml-block-re (hre "[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$")
  "Regexp matching a Ruby block in Haml.")

(defconst haml-block-cont-re (hre (concat "-[ \t]*"
                                          (regexp-opt '("else" "elsif"
                                                        "rescue" "ensure"
                                                        "when"))))
  "Regexp matching a continued Ruby block in Haml.")<commit_msg>Some tweaking of haml-mode Regexps.<commit_after>;;; haml-mode.el -- Major mode for editing Haml files
;;; Version 0.0.1
;;; Written by <NAME>

;;; Because Haml's indentation schema is similar
;;; to that of YAML and Python, many indentation-related
;;; functions are similar to those in yaml-mode and python-mode.

;;; To install, save this somewhere and add the following to your .emacs file:
;;; 
;;; (add-to-list 'load-path "/path/to/haml-mode.el")
;;; (require 'haml-mode nil 't)
;;; 

;;; Code:

;; User definable variables

(defgroup haml nil
  "Support for the Haml template language."
  :group 'languages
  :prefix "haml-")

(defcustom haml-mode-hook nil
  "*Hook run by `haml-mode'."
  :type 'hook
  :group 'haml)

(defcustom haml-indent-offset 2
  "*Amount of offset per level of indentation."
  :type 'integer
  :group 'haml)

(defcustom haml-backspace-function 'backward-delete-char-untabify
  "*Function called by `haml-electric-backspace' when deleting backwards."
  :type 'function
  :group 'haml)

(defface haml-tab-face
   '((((class color)) (:background "red" :foreground "red" :bold t))
     (t (:reverse-video t)))
  "Face to use for highlighting tabs in Haml files."
  :group 'faces
  :group 'haml)

;; Helper Functions

(defun string-* (str n)
  "Concatenates a string with itself n times."
  (if (= n 0) ""
    (concat str (string-* str (- n 1)))))

(defun find-if (f lst)
  "Returns the first element of a list for which a function returns a non-nil value, or nil if no such element is found."
  (while (not (or (null lst)
                  (apply f (list (car lst)))))
    (setq lst (cdr lst)))
  (if (null lst) nil (car lst)))

(defun hre (str)
  "Prepends a Haml-tab-matching regexp to str."
  (concat "^\\(" (string-* " " haml-indent-offset) "\\)*" str))

;; Font lock
(defconst haml-font-lock-keywords-1
  (list
   '("^ *%\\w+"        . font-lock-function-name-face)
   '("#\\w+"        . font-lock-keyword-face)
   '("\\.\\w+"        . font-lock-keyword-face)
   '("^ *=.*"         . font-lock-string-face)
   '("^ *-.*"   . font-lock-string-face)
   '("^!!!.*"          . font-lock-constant-face)))

;; Constants

(defconst haml-mode-version "0.0.1" "Version of `haml-mode.'")

(defconst haml-blank-line-re "^[ \t]*$"
  "Regexp matching a line containing only whitespace.")

; Base for Regexen matching a Haml tag.
(setq haml-tag-re-base (hre "\\([%\\.#][^ \t]*\\)\\({.*}\\)?\\(\\[.*\\]\\)?"))

(defconst haml-tag-nest-re (concat haml-tag-re-base "[ \t]*$")
  "Regexp matching a Haml tag that can have nested elements.")

(defconst haml-tag-re (concat haml-tag-re-base "\\(.?\\)")
  "Regexp matching a Haml tag.")

(defconst haml-block-re (hre "[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$")
  "Regexp matching a Ruby block in Haml.")

(defconst haml-block-cont-re (hre (concat "-[ \t]*"
                                          (regexp-opt '("else" "elsif"
                                                        "rescue" "ensure"
                                                        "when"))))
  "Regexp matching a continued Ruby block in Haml.")
{'fraction_non_alphanumeric': 0.1815485996705107, 'fraction_numerical': 0.0032948929159802307, 'mean_word_length': 2.564885496183206, 'pattern_counts': {'":': 0, '<': 5, '<?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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7513309', 'n_tokens_mistral': 2171, 'n_tokens_neox': 2121, 'n_words': 638}