<commit_before>;;; core-file-templates.el

(use-package autoinsert
  :defer t
  :init
  (setq auto-insert-query nil  ; Don't prompt before insertion
        auto-insert-alist '()) ; Tabula rasa
  :config
  (auto-insert-mode 1)

  (defun auto-insert-template (rule)
    (define-auto-insert
      (nth 0 rule)
      (vector `(lambda () (narf/auto-insert-snippet ,(nth 1 rule) ',(nth 2 rule) ,(nth 3 rule))))))

  (mapc 'auto-insert-template
        `(;; General
          ("/\\.gitignore$"                  "__"               gitignore-mode)
          ("/Dockerfile$"                    "__"               dockerfile-mode)
          ("/docker-compose.yml$"            "__"               yaml-mode)

          ;; Org-mode
          ("\\.org$"                         "__"               org-mode)
          ("/Work/.+\\.org$"                 "__project.org"    org-mode)
          ("/Invoices/.+\\.org$"             "__invoice.org"    org-mode)
          ("/Contacts/.+\\.org$"             "__contact.org"    org-mode)

          ;; C/C++
          ("/Makefile$"                      "__"               makefile-gmake-mode)
          ("/main\\.\\(cc\\|cpp\\)$"         "__main.cpp"       c++-mode)
          ("/win32_\\.\\(cc\\|cpp\\)$"       "__winmain.cpp"    c++-mode)
          ("\\.\\([Hh]\\|hpp\\)$"            "__.h"             c++-mode)
          ("\\.\\(cc\\|cpp\\)$"              "__.cpp"           c++-mode)
          ("\\.c$"                           "__.c"             c-mode)

          ;; Elisp
          ("-test\\.el$"                     "__"               emacs-ert-mode)
          ("\\.emacs\\.d/.+\\.el$"           "__initfile"       emacs-lisp-mode)
          ("\\.emacs\\.d/private/\\(snippets\\|templates\\)/.+$" "__" snippet-mode)

          ;; Go
          ("/main\\.go$"                     "__main.go"        go-mode t)
          ("\\.go$"                          "__.go"            go-mode)

          ;; HTML
          ("\\.html$"                        "__.html"          web-mode)

          ;; java
          ("/src/.+/.+\\.java$"              "__"               java-mode)
          ("/main\\.java$"                   "__main"           java-mode)
          ("/build\\.gradle$"                "__build.gradle"   android-mode)

          ;; Javascript
          ("\\.lbaction/.+/Info.plist$"                       "__Info.plst"  lb6-mode)
          ("\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "__default.js" lb6-mode)
          ("/package\\.json$"                "__package.json"   json-mode)
          ("\\.\\(json\\|jshintrc\\)$"       "__"               json-mode)

          ;; Lua
          ("/main\\.lua$"                    "__main.lua"       love-mode)
          ("/conf\\.lua$"                    "__conf.lua"       love-mode)<commit_msg>Register new header file templates with auto-insert<commit_after>;;; core-file-templates.el

(use-package autoinsert
  :defer t
  :init
  (setq auto-insert-query nil  ; Don't prompt before insertion
        auto-insert-alist '()) ; Tabula rasa
  :config
  (auto-insert-mode 1)

  (defun auto-insert-template (rule)
    (define-auto-insert
      (nth 0 rule)
      (vector `(lambda () (narf/auto-insert-snippet ,(nth 1 rule) ',(nth 2 rule) ,(nth 3 rule))))))

  (mapc 'auto-insert-template
        `(;; General
          ("/\\.gitignore$"                  "__"               gitignore-mode)
          ("/Dockerfile$"                    "__"               dockerfile-mode)
          ("/docker-compose.yml$"            "__"               yaml-mode)

          ;; Org-mode
          ("\\.org$"                         "__"               org-mode)
          ("/Work/.+\\.org$"                 "__project.org"    org-mode)
          ("/Invoices/.+\\.org$"             "__invoice.org"    org-mode)
          ("/Contacts/.+\\.org$"             "__contact.org"    org-mode)

          ;; C/C++
          ("/Makefile$"                      "__"               makefile-gmake-mode)
          ("/main\\.\\(cc\\|cpp\\)$"         "__main.cpp"       c++-mode)
          ("/win32_\\.\\(cc\\|cpp\\)$"       "__winmain.cpp"    c++-mode)
          ("\\.h\\(h\\|pp|xx\\)$"            "__hpp"            c++-mode)
          ("\\.\\(cc\\|cpp\\)$"              "__cpp"            c++-mode)
          ("\\.h$"                           "__h"              c-mode)
          ("\\.c$"                           "__c"              c-mode)

          ;; Elisp
          ("-test\\.el$"                     "__"               emacs-ert-mode)
          ("\\.emacs\\.d/.+\\.el$"           "__initfile"       emacs-lisp-mode)
          ("\\.emacs\\.d/private/\\(snippets\\|templates\\)/.+$" "__" snippet-mode)

          ;; Go
          ("/main\\.go$"                     "__main.go"        go-mode t)
          ("\\.go$"                          "__.go"            go-mode)

          ;; HTML
          ("\\.html$"                        "__.html"          web-mode)

          ;; java
          ("/src/.+/.+\\.java$"              "__"               java-mode)
          ("/main\\.java$"                   "__main"           java-mode)
          ("/build\\.gradle$"                "__build.gradle"   android-mode)

          ;; Javascript
          ("\\.lbaction/.+/Info.plist$"                       "__Info.plst"  lb6-mode)
          ("\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "__default.js" lb6-mode)
          ("/package\\.json$"                "__package.json"   json-mode)
          ("\\.\\(json\\|jshintrc\\)$"       "__"               json-mode)

          ;; Lua
          ("/main\\.lua$"                    "__main.lua"       love-mode)
          ("/conf\\.lua$"                    "__conf.lua"       love-mode)
{'fraction_non_alphanumeric': 0.1939457937346005, 'fraction_numerical': 0.0031678986272439284, 'mean_word_length': 0.9186360567184335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7431388', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1736, 'n_words': 260}