<commit_before># Emacs Initialization and Setup

## A Primer And Example

### Introduction

Emacs is a great editor. Actually, it is the One True Editor, the
Platonic ideal of which all other editors are imperfect shadows.

#### say "hello"
#+begin_src emacs-lisp
  (message "loaded configure-emacs")
#+end_src

#+begin_src emacs-lisp
  (defun install-other-packages ()
    "Use `use-package' to install other desired packages."

    ;; GNU Hyperbole: The Everyday Hypertextual Information Manager
    (use-package "hyperbole"
      :ensure t ;; if it's not installed, install it
      :bind (([C-M-return] . assist-key)
	     ;;("\C-h h" #'hyperbole)
	     ))
    ;; \C-h h should be bound by package, but...

    ;; Manage and navigate projects in Emacs easily
    (use-package "projectile"
      :ensure t
      :config (projectile-mode))

    ;; projectile-speedbar requires sr-speedbar
    ;; which appears to be broken, dammit
    ;; (use-package "projectile-speedbar"
    ;;   :ensure t)

    (use-package "async"
      :ensure t)

    (use-package "org"
      :ensure t)

    (use-package "paradox"
      :ensure t)

    (use-package "shrink-whitespace"
      :ensure t)

    (use-package "undo-tree"
      :ensure t)

    (use-package "elpy"
      :ensure t)

    (use-package "jedi"
      :ensure t)

    (use-package "js2-mode"
      :ensure t)

    (use-package "web-mode"
      :ensure t)

    (use-package "web-beautify"
      :ensure t)

    (use-package "smartparens"
      :ensure t
      :config (lambda ()
		(defun turn-on-smartparens ()
		  (smartparens-mode +1)
		  ;; also emulate paredit's refusal to delete one delimiter in a pair
		  (smartparens-strict-mode +1)
		  ;; I find paredit bindings more convenient w/PC keyboards
		  (sp-use-paredit-bindings))
		(add-hook 'lisp-mode-hook 'turn-on-smartparens)))

    (use-package "flx-ido"
      :ensure t)

    (use-package "magit"
      :ensure t)

    (use-package "flycheck-pyflakes"
      :ensure t)

    (use-package "slime"
      :ensure t)

    (use-package "form-feed"
      :ensure t
      :config (lambda ()
		(defun form-feed-turn-on ()
		  (form-feed-mode 1))
		(add-hook 'emacs-lisp-mode-hook #'form-feed-turn-on)))

    )



  (define-key lisp-mode-shared-map (kbd "C-\\") 'completion-at-point)
  (define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)

  (install-other-packages)
#+end_src

** Use regex searches by default.
#+begin_src emacs-lisp
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
#+end_src


** Rgrep
Rgrep is infinitely useful in multi-file projects.

(see [[elisp:(describe-function 'rgrep)]])

#+begin_src emacs-lisp
  (define-key global-map "\C-x\C-r" 'rgrep)
#+end_src

** Load secret data

I have a small module to separate sensitive data into a hidden
fihle. Load that module and read the data to set global variable.

#+begin_src emacs-lisp
  (org-babel-load-file "secret-data.org" t)
#+end_src

** Set up org-babel supported languages

#+begin_src emacs-lisp
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((C . t)
     (clojure . t)
     (css . t)
     (emacs-lisp . t)
     (js . t)
     (lisp . t)
     (org . t)
     (python . t)
     (R . t)
     (ruby . t)
     (sass . t)
     (scheme . t)
     (sh . t)
     (sql . t)))
#+end_src

** Emacs Lisp
   :PROPERTIES:
   :CUSTOM_ID: emacs-lisp
   :END:

*** Cleanup function for .elc files
#+begin_src emacs-lisp
  (defun starter-kit-remove-elc-on-save ()
    "If you're saving an elisp file, likely the .elc is no longer valid."
    (make-local-variable 'after-save-hook)
    (add-hook 'after-save-hook
	      (lambda ()
		(if (file-exists-p (concat buffer-file-name "c"))
		    (delete-file (concat buffer-file-name "c"))))))
#+end_src

*** emacs-list-mode-hook
#+begin_src emacs-lisp
  (add-hook 'emacs-lisp-mode-hook (lambda () (eldoc-mode +1)))
  (add-hook 'emacs-lisp-mode-hook #'starter-kit-remove-elc-on-save)

  ;; (define-key emacs-lisp-mode-map (kbd "C-c v") #'eval-buffer)
  ;; for indentation, use spaces, not tabs
  (defun turn-off-indent-tabs ()
    (setq indent-tabs-mode nil))
  (add-hook 'emacs-lisp-mode-hook #'turn-off-indent-tabs)
#+end_src<commit_msg>pull in some functions from starter-kit-defuns<commit_after># Emacs Initialization and Setup

## A Primer And Example

### Introduction

Emacs is a great editor. Actually, it is the One True Editor, the
Platonic ideal of which all other editors are imperfect shadows.

#### say "hello"
#+begin_src emacs-lisp
  (message "loaded configure-emacs")
#+end_src

#+begin_src emacs-lisp
  (defun emess-install-other-packages ()
    "Use `use-package' to install other desired packages."

    ;; GNU Hyperbole: The Everyday Hypertextual Information Manager
    (use-package "hyperbole"
      :ensure t ;; if it's not installed, install it
      :bind (([C-M-return] . assist-key)
             (("C-h h") . #'hyperbole)
             ))
    ;; \C-h h should be bound by package, but...

    ;; Manage and navigate projects in Emacs easily
    (use-package "projectile"
      :ensure t
      :config (projectile-mode))

    ;; projectile-speedbar requires sr-speedbar
    ;; which appears to be broken, dammit
    ;; (use-package "projectile-speedbar"
    ;;   :ensure t)

    (use-package "async"
      :ensure t)

    (use-package "org"
      :ensure t)

    (use-package "paradox"
      :ensure t)

    (use-package "shrink-whitespace"
      :ensure t)

    (use-package "undo-tree"
      :ensure t)

    (use-package "elpy"
      :ensure t)

    (use-package "jedi"
      :ensure t)

    (use-package "js2-mode"
      :ensure t)

    (use-package "web-mode"
      :ensure t)

    (use-package "web-beautify"
      :ensure t)

    (use-package "smartparens"
      :ensure t
      :config (lambda ()
                (defun emess-turn-on-smartparens ()
                  (smartparens-mode +1)
                  ;; also emulate paredit's refusal to delete one delimiter in a pair
                  (smartparens-strict-mode +1)
                  ;; I find paredit bindings more convenient w/PC keyboards
                  (sp-use-paredit-bindings))
                (add-hook 'lisp-mode-hook 'emess-turn-on-smartparens)))

    (use-package "flx-ido"
      :ensure t)

    (use-package "magit"
      :ensure t)

    (use-package "flycheck-pyflakes"
      :ensure t)

    (use-package "slime"
      :ensure t)

    (use-package "form-feed"
      :ensure t
      :config (lambda ()
                (defun emess-form-feed-turn-on ()
                  (form-feed-mode 1))
                (add-hook 'emacs-lisp-mode-hook #'emess-form-feed-turn-on)))

    )

  (define-key lisp-mode-shared-map (kbd "C-\\") 'completion-at-point)
  (define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)

  (emess-install-other-packages)
#+end_src

** Use regex searches by default.
#+begin_src emacs-lisp
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
#+end_src

** Rgrep
Rgrep is infinitely useful in multi-file projects.

(see [[elisp:(describe-function 'rgrep)]])

#+begin_src emacs-lisp
  (define-key global-map "\C-x\C-r" 'rgrep)
#+end_src

** Load secret data

I have a small module to separate sensitive data into a hidden
fihle. Load that module and read the data to set global variable.

#+begin_src emacs-lisp
  (org-babel-load-file "secret-data.org" t)
#+end_src

** Set up org-babel supported languages

#+begin_src emacs-lisp
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((C . t)
     (clojure . t)
     (css . t)
     (emacs-lisp . t)
     (js . t)
     (lisp . t)
     (org . t)
     (python . t)
     (R . t)
     (ruby . t)
     (sass . t)
     (scheme . t)
     (sh . t)
     (sql . t)))
#+end_src

** Emacs Lisp
   :PROPERTIES:
   :CUSTOM_ID: emacs-lisp
   :END:

*** Cleanup function for .elc files
#+begin_src emacs-lisp
  (defun emess-remove-elc-on-save ()
    "If you're saving an elisp file, likely the .elc is no longer valid."
    (make-local-variable 'after-save-hook)
    (add-hook 'after-save-hook
	      (lambda ()
		(if (file-exists-p (concat buffer-file-name "c"))
		    (delete-file (concat buffer-file-name "c"))))))
#+end_src

*** emacs-list-mode-hook
#+begin_src emacs-lisp
  (add-hook 'emacs-lisp-mode-hook (lambda () (eldoc-mode +1)))
  (add-hook 'emacs-lisp-mode-hook #'emess-remove-elc-on-save)

  ;; (define-key emacs-lisp-mode-map (kbd "C-c v") #'eval-buffer)
  ;; for indentation, use spaces, not tabs
  (defun emess-turn-off-indent-tabs ()
    (setq indent-tabs-mode nil))
  (add-hook 'emacs-lisp-mode-hook #'emess-turn-off-indent-tabs)
#+end_src

** Configuration for each buffer

#+begin_src emacs-lisp
  (defun emess-local-column-number-mode ()
    (make-local-variable 'column-number-mode)
    (column-number-mode t))

  (defun emess-local-comment-auto-fill ()
    (set (make-local-variable 'comment-auto-fill-only-comments) t)
    (auto-fill-mode t))

  (add-hook 'emess-coding-hook #'emess-local-column-number-mode)
  (add-hook 'emess-coding-hook #'emess-local-comment-auto-fill)

  (defun emess-run-coding-hook ()
    "Enable things that are convenient across all coding buffers."
    (run-hooks 'emess-coding-hook))

#+end_src
{'fraction_non_alphanumeric': 0.14736730585867147, 'fraction_numerical': 0.0010594342621040365, 'mean_word_length': 2.6391673091750194, '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': '5960757', 'n_tokens_mistral': 3619, 'n_tokens_neox': 3451, 'n_words': 872}