<commit_before>;;; lang/org/+babel.el -*- lexical-binding: t; -*-

(add-hook 'org-load-hook #'+org|init-babel)

(defvar +org-babel-languages
  '(calc
    css
    emacs-lisp
    haskell
    js
    latex
    ledger
    lilypond
    lisp
    matlab
    plantuml
    python
    restclient ; ob-restclient
    ruby
    rust       ; ob-rust
    shell
    sqlite
    sql-mode   ; ob-sql-mode
    translate) ; ob-translate
  "A list of org-babel languages to load.")


(defun +org|init-babel ()
  (setq org-src-fontify-natively t      ; make code pretty
        org-src-preserve-indentation t  ; use native major-mode indentation
        org-src-tab-acts-natively t
        org-src-window-setup 'current-window
        org-confirm-babel-evaluate nil) ; you don't need my permission

  (org-babel-do-load-languages
   'org-babel-load-languages
   (cl-loop for sym in +org-babel-languages
            collect (cons sym t)))

  ;; I prefer C-c C-c for confirming over the default C-c '<commit_msg>lang/org: lazy-load babel libraries<commit_after>;;; lang/org/+babel.el -*- lexical-binding: t; -*-

(add-hook 'org-load-hook #'+org|init-babel)

(defun +org|init-babel ()
  (setq org-src-fontify-natively t      ; make code pretty
        org-src-preserve-indentation t  ; use native major-mode indentation
        org-src-tab-acts-natively t
        org-src-window-setup 'current-window
        org-confirm-babel-evaluate nil) ; you don't need my permission

  (defun +org*babel-execute-src-block (orig-fn &rest args)
    "Load babel libraries as needed when babel blocks are executed."
    (let* ((language (org-element-property :language (org-element-at-point)))
           (lang-sym (intern language)))
      (unless (cdr (assoc lang-sym org-babel-load-languages))
        (require (intern (format "ob-%s" language)))
        (add-to-list 'org-babel-load-languages (cons lang-sym t)))
      (apply orig-fn args)))
  (advice-add #'org-babel-execute-src-block :around #'+org*babel-execute-src-block)

  ;; I prefer C-c C-c for confirming over the default C-c '
{'fraction_non_alphanumeric': 0.12939453125, 'fraction_numerical': 0.0, 'mean_word_length': 2.6265486725663716, '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': '4708580', 'n_tokens_mistral': 717, 'n_tokens_neox': 678, 'n_words': 175}