summaryrefslogtreecommitdiff
path: root/.config/emacs/modules
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2026-04-03 02:10:14 +0200
committerThomas Voss <mail@thomasvoss.com> 2026-04-03 02:10:14 +0200
commit8491e264f352447bd731f37edd1f0fe0b59c0194 (patch)
treeb3e075c046d6a389492fba89e3424107513462f8 /.config/emacs/modules
parentdaeeecee613987bd821b4e15d03b2cb925cd88b0 (diff)
emacs: Introduce the new cleaned-up configuration
Diffstat (limited to '.config/emacs/modules')
-rw-r--r--.config/emacs/modules/mm-abbrev.el46
-rw-r--r--.config/emacs/modules/mm-buffer-menu.el15
-rw-r--r--.config/emacs/modules/mm-calc.el12
-rw-r--r--.config/emacs/modules/mm-completion.el170
-rw-r--r--.config/emacs/modules/mm-darwin.el30
-rw-r--r--.config/emacs/modules/mm-dired.el34
-rw-r--r--.config/emacs/modules/mm-documentation.el46
-rw-r--r--.config/emacs/modules/mm-editing.el369
-rw-r--r--.config/emacs/modules/mm-humanwave.el257
-rw-r--r--.config/emacs/modules/mm-keybindings.el185
-rw-r--r--.config/emacs/modules/mm-projects.el48
-rw-r--r--.config/emacs/modules/mm-search.el26
-rw-r--r--.config/emacs/modules/mm-tetris.el19
-rw-r--r--.config/emacs/modules/mm-theme.el232
-rw-r--r--.config/emacs/modules/mm-treesit.el261
-rw-r--r--.config/emacs/modules/mm-window.el79
16 files changed, 1829 insertions, 0 deletions
diff --git a/.config/emacs/modules/mm-abbrev.el b/.config/emacs/modules/mm-abbrev.el
new file mode 100644
index 0000000..2154589
--- /dev/null
+++ b/.config/emacs/modules/mm-abbrev.el
@@ -0,0 +1,46 @@
+;;; mm-abbrev.el --- Emacs abbreviations and templates -*- lexical-binding: t; -*-
+
+;;; Helpers
+
+(defmacro mm-abbrev-define-abbreviations (table &rest definitions)
+ "Define abbrevations for an abbreviation TABLE.
+Expand abbrev DEFINITIONS for the given TABLE. DEFINITIONS are a
+sequence of either string pairs mapping an abbreviation to its
+expansion, or a string and symbol pair mapping an abbreviation to a
+function.
+
+After adding all abbreviations to TABLE, this macro marks TABLE as
+case-sensitive to avoid unexpected abbreviation expansions."
+ (declare (indent 1))
+ (unless (cl-evenp (length definitions))
+ (user-error "expected an even number of elements in DEFINITIONS"))
+ `(progn
+ ,@(cl-loop for (abbrev expansion) in (seq-partition definitions 2)
+ if (stringp expansion)
+ collect (list #'define-abbrev table abbrev expansion)
+ else
+ collect (list #'define-abbrev table abbrev "" expansion))
+ (abbrev-table-put ,table :case-fixed t)))
+
+
+;;; Abbreviation Configuration
+
+(use-package abbrev
+ :hook prog-mode
+ :custom
+ (abbrev-file-name (expand-file-name "abbev-defs" mm-data-directory))
+ (save-abbrevs 'silently))
+
+
+;;; Abbreviation Definitions
+
+(use-package python
+ :if mm-humanwave-p
+ :config
+ (mm-abbrev-define-abbreviations python-ts-mode-abbrev-table
+ "empb" "with emphasize.Block():"
+ "empf" "@emphasize.func"
+ "empi" "from shared.system import emphasize"
+ "empt" "emphasize.this"))
+
+(provide 'mm-abbrev)
diff --git a/.config/emacs/modules/mm-buffer-menu.el b/.config/emacs/modules/mm-buffer-menu.el
new file mode 100644
index 0000000..d962447
--- /dev/null
+++ b/.config/emacs/modules/mm-buffer-menu.el
@@ -0,0 +1,15 @@
+;;; mm-buffer-menu.el --- Buffer Menu configuration -*- lexical-binding: t; -*-
+
+(defun mm-buffer-menu-delete-all ()
+ "Mark all buffers for deletion."
+ (interactive nil Buffer-menu-mode)
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (Buffer-menu-delete))))
+
+(use-package buff-menu
+ :bind ( :map Buffer-menu-mode-map
+ ("D" . mm-buffer-menu-delete-all)))
+
+(provide 'mm-buffer-menu)
diff --git a/.config/emacs/modules/mm-calc.el b/.config/emacs/modules/mm-calc.el
new file mode 100644
index 0000000..6c5291a
--- /dev/null
+++ b/.config/emacs/modules/mm-calc.el
@@ -0,0 +1,12 @@
+;;; mm-calc.el --- Emacs configurations for ‘calc-mode’ -*- lexical-binding: t; -*-
+
+(use-package calc
+ :init
+ (setopt
+ calc-display-trail nil
+ calc-group-digits t
+ ;; Optimize for Europeans
+ calc-point-char ","
+ calc-group-char "."))
+
+(provide 'mm-calc)
diff --git a/.config/emacs/modules/mm-completion.el b/.config/emacs/modules/mm-completion.el
new file mode 100644
index 0000000..f84259e
--- /dev/null
+++ b/.config/emacs/modules/mm-completion.el
@@ -0,0 +1,170 @@
+;;; mm-completion.el --- Configuration for Emacs completion -*- lexical-binding: t; -*-
+
+;;; Vertical Completions
+
+(use-package icomplete
+ :hook (after-init . icomplete-vertical-mode)
+ :bind ( :map icomplete-minibuffer-map
+ ("TAB" . #'icomplete-force-complete)
+ ("RET" . #'icomplete-force-complete-and-exit))
+ :config
+ (setq icomplete-scroll t) ; Not ‘defcustom’
+ :custom
+ (icomplete-show-matches-on-no-input t)
+ (icomplete-compute-delay 0))
+
+
+;;; Annotate Completions
+
+;; PKG-EXTERN
+(use-package marginalia
+ :ensure t
+ :hook after-init
+ :custom
+ (marginalia-field-width 50)
+ (marginalia-max-relative-age 0))
+
+
+;;; Minibuffer Completion Styles
+
+(use-package minibuffer
+ :bind ( :map minibuffer-local-completion-map
+ ("SPC" . nil)
+ ("?" . nil))
+ :custom
+ (completion-styles '(basic substring))
+ (completion-category-defaults nil) ; Avoid needing to override things
+ (completion-category-overrides
+ '((file (styles . (basic partial-completion)))
+ (bookmark (styles . (basic substring)))
+ (library (styles . (basic substring)))
+ (imenu (styles . (basic substring)))
+ (consult-location (styles . (basic substring)))
+ (kill-ring (styles . (basic substring)))))
+ (completion-ignore-case t)
+ (read-buffer-completion-ignore-case t)
+ (read-file-name-completion-ignore-case t))
+
+
+;;; Disable Minibuffer Recursion Level
+
+(use-package mb-depth
+ :hook (after-init . minibuffer-depth-indicate-mode)
+ :custom
+ (enable-recursive-minibuffers t))
+
+
+;;; Don’t Show Defaults After Typing
+
+;; Usually if a minibuffer prompt has a default value you can access by
+;; hitting RET, the prompt will remain even if you begin typing (meaning
+;; the default will no longer take effect on RET). Enabling this mode
+;; disables that behaviour.
+
+(use-package minibuf-eldef
+ :hook (after-init . minibuffer-electric-default-mode)
+ :custom
+ (minibuffer-default-prompt-format " [%s]"))
+
+
+;;; Hide Shadowed Filepaths
+
+(use-package rfn-eshadow
+ :hook (after-init . file-name-shadow-mode)
+ :custom
+ (file-name-shadow-properties '(invisible t intangilble t)))
+
+
+;;; Save Minibuffer History
+
+(use-package savehist-mode
+ :hook (after-init . savehist-mode)
+ :custom
+ (history-length 200)
+ (history-delete-duplicates t)
+ :config
+ (add-to-list 'savehist-additional-variables 'kill-ring))
+
+
+;;; Enhanced Replacements for Builtins
+
+;; TODO: Investigate other commands
+;; PKG-EXTERN
+(use-package consult
+ :ensure t
+ :hook (completion-list-mode . consult-preview-at-point-mode)
+ :bind ( ([remap switch-to-buffer] . consult-buffer)
+ ([remap imenu] . consult-imenu)
+ ([remap goto-line] . consult-goto-line)
+ ("M-F" . consult-focus-lines)
+ :map project-prefix-map
+ ("b" . consult-project-buffer)
+ :map consult-narrow-map
+ ("?" . consult-narrow-help))
+ :custom
+ (consult-async-min-input 1)
+ (consult-async-split-style nil)
+ (consult-async-input-debounce .2)
+ (consult-async-input-throttle 0)
+ (consult-find-args
+ (string-join
+ (mapcar #'shell-quote-argument
+ '("find" "." "-not" "("
+ "-path" "*/.git/*" "-prune"
+ "-path" "*/vendor" "-prune"
+ "-path" "*/node_modules" "-prune"
+ ")"))
+ " ")))
+
+
+;;; Dynamic Abbreviations
+
+(use-package dabbrev
+ :commands (dabbrev-completion dabbrev-expand)
+ :custom
+ (dabbrev-upcase-means-case-search t))
+
+
+;;; Finding Things
+
+(use-package find-func
+ :custom
+ (find-library-include-other-files nil))
+
+
+;;; Completion at Point Functions
+
+(defun mm-completions--cape-file-not-dot-path-p (cand)
+ (declare (ftype (function (string) boolean))
+ (pure t) (side-effect-free t))
+ (not (or (string= cand "./")
+ (string= cand "../"))))
+
+;; PKG-EXTERN
+(use-package cape
+ :ensure t
+ :init
+ (add-hook 'completion-at-point-functions
+ (cape-capf-predicate
+ #'cape-file
+ #'mm-completions--cape-file-not-dot-path-p))
+ (add-hook 'completion-at-point-functions
+ (cape-capf-prefix-length #'cape-dabbrev 3)))
+
+
+;;; Completion at Point Live Completions
+
+(use-package completion-preview
+ :hook (after-init . global-completion-preview-mode)
+ :custom
+ (completion-preview-minimum-symbol-length 1))
+
+(use-package completion-preview
+ :after multiple-cursors
+ :config
+ (add-hook 'multiple-cursors-mode-hook
+ (defun mm-completion-set-toggle-previews-on-multiple-cursors ()
+ (global-completion-preview-mode
+ (when multiple-cursors-mode -1)))))
+
+(provide 'mm-completion)
diff --git a/.config/emacs/modules/mm-darwin.el b/.config/emacs/modules/mm-darwin.el
new file mode 100644
index 0000000..6284a8f
--- /dev/null
+++ b/.config/emacs/modules/mm-darwin.el
@@ -0,0 +1,30 @@
+;;; mm-darwin.el --- MacOS Configuration -*- lexical-binding: t; -*-
+
+(unless (featurep 'ns)
+ (error "'NS not available. Something has gone horribly wrong."))
+
+
+;;; Launch Emacs Properly
+
+(defun mm-darwin--ns-raise-emacs ()
+ (ns-do-applescript "tell application \"Emacs\" to activate"))
+
+(add-hook
+ 'after-make-frame-functions
+ (defun mm-darwin--ns-raise-emacs-with-frame (frame)
+ (when (display-graphic-p)
+ (with-selected-frame frame
+ (mm-darwin--ns-raise-emacs)))))
+
+(when (display-graphic-p)
+ (mm-darwin--ns-raise-emacs))
+
+
+;;; Set Modifier Keys
+
+(setopt mac-option-key-is-meta nil
+ mac-command-key-is-meta t)
+(setopt mac-option-modifier 'none
+ mac-command-modifier 'meta)
+
+(provide 'mm-darwin)
diff --git a/.config/emacs/modules/mm-dired.el b/.config/emacs/modules/mm-dired.el
new file mode 100644
index 0000000..d231511
--- /dev/null
+++ b/.config/emacs/modules/mm-dired.el
@@ -0,0 +1,34 @@
+;;; mm-dired.el --- Configure the directory editor -*- lexical-binding: t; -*-
+
+(defun mm-dired-use-current-directory (function &rest args)
+ "Run FUNCTION with ARGS in the current dired directory."
+ (let ((default-directory (dired-current-directory)))
+ (apply function args)))
+
+(use-package dired
+ :hook ((dired-mode . dired-omit-mode)
+ (dired-mode . dired-hide-details-mode))
+ :bind ( :map dired-mode-map
+ ("C-c C-w" . wdired-change-to-wdired-mode)
+ ("f" . dired-x-find-file))
+ :config
+ (advice-add #'dired-x-read-filename-at-point
+ :around #'mm-dired-use-current-directory)
+ :custom
+ (dired-auto-revert-buffer #'dired-directory-changed-p)
+ (dired-dwim-target t)
+ (dired-free-space nil)
+ (dired-recursive-copies 'always)
+ (dired-recursive-deletes 'always)
+ (dired-hide-details-preserved-columns '(1))
+ (dired-listing-switches
+ (combine-and-quote-strings
+ '("-AFGhlv" "--group-directories-first" "--time-style=+%d %b %Y %T"))))
+
+(use-package dired-aux
+ :custom
+ (dired-create-destination-dirs 'ask)
+ (dired-create-destination-dirs-on-trailing-dirsep t)
+ (dired-isearch-filenames 'dwim))
+
+(provide 'mm-dired)
diff --git a/.config/emacs/modules/mm-documentation.el b/.config/emacs/modules/mm-documentation.el
new file mode 100644
index 0000000..51a671f
--- /dev/null
+++ b/.config/emacs/modules/mm-documentation.el
@@ -0,0 +1,46 @@
+;;; mm-documentation.el --- Configuration related to documentation -*- lexical-binding: t; -*-
+
+;;; Enhance Describe Commands
+
+;; PKG-EXTERN
+(use-package helpful
+ :ensure t
+ :bind (([remap describe-command] . helpful-command)
+ ([remap describe-function] . helpful-callable)
+ ([remap describe-key] . helpful-key)
+ ([remap describe-symbol] . helpful-symbol)
+ ([remap describe-variable] . helpful-variable)
+ :map emacs-lisp-mode-map
+ ("C-h C-p" . helpful-at-point)))
+
+
+;;; Open Manpage for Symbol
+
+(defun mm-documentation-man-at-point ()
+ "Open a UNIX manual page for the symbol at point."
+ (interactive nil c-mode c++-mode c-ts-mode c++-ts-mode)
+ (if-let ((symbol
+ (pcase major-mode
+ ((or 'c-mode 'c++-mode)
+ (thing-at-point 'symbol :no-properties))
+ ((or 'c-ts-mode 'c++-ts-mode)
+ (when-let ((node (treesit-thing-at-point "identifier" 'nested)))
+ (treesit-node-text node :no-properties))))))
+ (man symbol)
+ (message "There is no symbol at point.")))
+
+
+;;; Browse RFC Pages
+
+;; PKG-EXTERN
+(use-package rfc-mode
+ :ensure t
+ :custom
+ (rfc-mode-directory (expand-file-name "rfc" (xdg-user-dir "DOCUMENTS")))
+ :config
+ (unless (featurep 'consult)
+ (keymap-set rfc-mode-map "g" #'imenu))
+ (with-eval-after-load 'consult
+ (keymap-set rfc-mode-map "g" #'consult-imenu)))
+
+(provide 'mm-documentation)
diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el
new file mode 100644
index 0000000..5281743
--- /dev/null
+++ b/.config/emacs/modules/mm-editing.el
@@ -0,0 +1,369 @@
+;;; mm-editing.el --- Text editing configuation -*- lexical-binding: t; -*-
+
+;;; Delete Region When Typing
+
+(use-package delsel
+ :hook (after-init . delete-selection-mode))
+
+
+;;; Capitalize ‘ß’ into ‘ẞ’
+
+;; https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-11/msg00030.html
+(set-case-syntax-pair ?ẞ ?ß (standard-case-table))
+(put-char-code-property ?ß 'special-uppercase nil)
+
+
+;;; Force Spaces For Alignment
+
+(defun mm-editing-force-space-indentation (function &rest arguments)
+ "Call FUNCTION with ARGUMENTS in an environment in which
+`indent-tabs-mode' is nil."
+ (let (indent-tabs-mode)
+ (apply function arguments)))
+
+(dolist (command #'(align-region
+ c-backslash-region
+ comment-dwim
+ makefile-backslash-region
+ sh-backslash-region))
+ (advice-add command :around #'mm-editing-force-space-indentation))
+
+
+;;; Indentation Settings
+
+(setq-default
+ tab-width 4
+ indent-tabs-mode (not mm-humanwave-p))
+
+(defvar mm-editing-indentation-settings-alist
+ '((awk-ts-mode . (:extras awk-ts-mode-indent-level))
+ (c-mode . (:extras c-basic-offset))
+ (c-ts-mode . (:extras c-ts-mode-indent-offset))
+ (css-mode . (:extras css-indent-offset))
+ (elixir-ts-mode . (:width 2 :extras elixir-ts-indent-offset))
+ (emacs-lisp-mode . (:width 8 :spaces t)) ; GNU code uses 8-column tabs
+ (go-mod-ts-mode . (:extras go-ts-mode-indent-offset))
+ (go-ts-mode . (:extras go-ts-mode-indent-offset))
+ (gsp-ts-mode . (:width 2 :extras gsp-ts-mode-indent-rules))
+ (helpful-mode . (:width 8)) ; GNU code uses 8-column tabs
+ (json-ts-mode . (:extras json-ts-mode-indent-offset))
+ (latex-mode . (:width 2))
+ (lisp-data-mode . (:spaces t))
+ (lisp-interaction-mode . (:spaces t))
+ (lisp-mode . (:spaces t))
+ (mhtml-mode . (:extras sgml-basic-offset))
+ (org-mode . (:width 8 :spaces t))
+ (python-mode . (:extras python-indent-offset))
+ (python-ts-mode . (:extras python-indent-offset))
+ (sgml-mode . (:extras sgml-basic-offset))
+ (sh-mode . (:extras sh-basic-offset))
+ (sql-mode . (:extras sqlind-basic-offset))
+ (tex-mode . (:width 2))
+ (typescript-ts-mode . (:extras typescript-ts-mode-indent-offset))
+ (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level))
+ (vue-ts-mode . (:extras (typescript-ts-mode-indent-offset
+ vue-ts-mode-indent-offset))))
+ "Alist of indentation settings.
+Each pair in this alist is of the form (MODE . SETTINGS) where MODE
+specifies the mode for which the given SETTINGS should apply.
+
+SETTINGS is a plist of one-or-more of the following keys:
+
+ `:spaces' -- If nil force tabs for indentation, if non-nil for spaces
+ for indentation. If this key is not provided then the
+ value of `indent-tabs-mode' is used.
+ `:width' -- Specifies a non-negative number to be used as the tab
+ width and indentation offset. If this key is not
+ provided then the default value of `tab-width' is used.
+ `:extras' -- A list of mode-specific variables which control
+ indentation settings that need to be set for
+ configurations to properly be applied.")
+
+(defun mm-editing-set-indentation-settings ()
+ "Set indentation settings for the current major mode.
+The indentation settings are set based on the configured values in
+`mm-editing-indentation-settings-alist'."
+ (let* ((plist (alist-get major-mode mm-editing-indentation-settings-alist))
+ (spaces (plist-member plist :spaces))
+ (width (plist-member plist :width))
+ (extras (plist-member plist :extras)))
+ ;; Some modes like ‘python-mode’ explicitly set ‘tab-width’ and
+ ;; ‘indent-tabs-mode’ so we must override them explicitly.
+ (setq-local indent-tabs-mode (if spaces (not (cadr spaces))
+ (default-value 'indent-tabs-mode))
+ tab-width (or (cadr width) (default-value 'tab-width)))
+ (when extras
+ (setq extras (cadr extras))
+ (when (symbolp extras)
+ (setq extras (list extras)))
+ (dolist (extra extras)
+ (set extra tab-width)))))
+
+(add-hook 'after-change-major-mode-hook #'mm-editing-set-indentation-settings)
+
+(defun mm-editing-set-tabsize ()
+ "Set the tabsize for the current buffer.
+If the current buffer’s major mode requires setting additional variables,
+those should be listed in `mm-editing-indentation-settings-alist'."
+ (declare (interactive-only t))
+ (interactive)
+ (let* ((prompt-default (default-value 'tab-width))
+ (prompt (format-prompt "Tabsize" prompt-default))
+ (tabsize (mm-as-number (read-string prompt nil nil prompt-default))))
+ (setq-local tab-width tabsize)
+ (when-let* ((plist (alist-get major-mode mm-editing-indentation-settings))
+ (extras (plist-get plist :extras)))
+ (dolist (extra (if (symbolp extras)
+ (list extras)
+ extras))
+ (set (make-local-variable extra) tabsize)))))
+
+(use-package sh-mode
+ :custom
+ (sh-indent-for-case-label 0)
+ (sh-indent-for-case-alt #'+))
+
+
+;;; Code Commenting
+
+(defvar mm-editing-comment-settings-alist
+ '(((c-mode c++-mode) . ("/* " " " " */"))
+ ;; rustfmt doesn’t play nice, so we need the ‘*’ comment
+ ;; continuation
+ (rust-mode . ("/* " " * " " */")))
+ "TODO")
+
+(defun mm-newcomment-rust-config ()
+ (setq-local comment-quote-nested nil))
+
+(use-package newcomment
+ :custom
+ (comment-style 'multi-line)
+ :config
+ (dolist (record mm-editing-comment-settings-alist)
+ (let* ((modes (car record))
+ (modes (if (listp modes) modes (list modes)))
+ (config (cdr record))
+ (set-comment-settings
+ (lambda ()
+ (setq-local comment-start (nth 0 config)
+ comment-continue (nth 1 config)
+ comment-end (nth 2 config)))))
+ (dolist (mode modes)
+ (let ((ts-mode (mm-mode-to-ts-mode mode)))
+ (when (fboundp mode)
+ (add-hook (mm-mode-to-hook mode) set-comment-settings))
+ (when (fboundp ts-mode)
+ (add-hook (mm-mode-to-hook ts-mode) set-comment-settings)))))))
+
+
+;;; Multiple Cursors
+
+;; PKG-INTERN
+(use-package multiple-cursors-extensions
+ :after multiple-cursors
+ :bind (("C-M-@" . #'mce-add-cursor-to-next-word)
+ ("C-M-o" . #'mce-add-cursor-to-next-symbol)
+ :map search-map
+ ("$" . #'mce-mark-all-in-region)
+ ("M-$" . #'mce-mark-all-in-region-regexp))
+ :commands (mce-add-cursor-to-next-symbol
+ mce-add-cursor-to-next-word
+ mce-mark-all-in-region
+ mce-mark-all-in-region-regexp
+ mce-sort-regions
+ mce-transpose-cursor-regions))
+
+;; PKG-EXTERN
+(use-package multiple-cursors
+ :ensure t
+ :demand t
+ :bind (("C->" . #'mc/mark-next-like-this)
+ ("C-<" . #'mc/mark-previous-like-this)
+ ("C-M-<" . #'mc/mark-all-like-this-dwim)
+ ("C-M->" . #'mc/edit-lines))
+ :commands ( mm-editing-mark-all-in-region mm-editing-mark-all-in-region-regexp
+ mm-add-cursor-to-next-thing mm-transpose-cursor-regions)
+ :init
+ (with-eval-after-load 'multiple-cursors-core
+ (keymap-unset mc/keymap "<return>" :remove)))
+
+
+;;; Increment Numbers
+
+;; PKG-INTERN
+(use-package increment
+ :bind (("C-c C-a" . #'increment-number-at-point)
+ ("C-c C-x" . #'decrement-number-at-point))
+ :commands (increment-number-at-point decrement-number-at-point))
+
+
+;;; Move Line or Region
+
+(defun mm-editing-move-text-indent (&rest _)
+ (let ((deactivate deactivate-mark))
+ (if (region-active-p)
+ (indent-region (region-beginning) (region-end))
+ (indent-region (line-beginning-position) (line-end-position)))
+ (setq deactivate-mark deactivate)))
+
+;; PKG-EXTERN
+(use-package move-text
+ :ensure t
+ :bind (("M-n" . move-text-down)
+ ("M-p" . move-text-up))
+ :config
+ (dolist (command #'(move-text-up move-text-down))
+ (advice-add command :after #'mm-editing-move-text-indent)))
+
+
+;;; Surround With Delimeters
+
+(defun mm-editing-surround-with-spaces (char)
+ "Surrounds region or current symbol with a pair defined by CHAR.
+This is the same as `surround-insert' except it pads the contents of the
+surround with spaces."
+ (interactive
+ (list (char-to-string (read-char "Character: "))))
+ (let* ((pair (surround--make-pair char))
+ (left (car pair))
+ (right (cdr pair))
+ (bounds (surround--infer-bounds t)))
+ (save-excursion
+ (goto-char (cdr bounds))
+ (insert " " right)
+ (goto-char (car bounds))
+ (insert left " "))
+ (when (eq (car bounds) (point))
+ (forward-char))))
+
+;; TODO: Implement this manually
+;; PKG-EXTERN
+(use-package surround
+ :ensure t
+ :bind-keymap ("M-'" . surround-keymap)
+ :bind (:map surround-keymap
+ ("S" . #'mm-editing-surround-with-spaces))
+ :config
+ (dolist (pair '(("‘" . "’")
+ ("“" . "”")
+ ("»" . "«")
+ ("⟮" . "⟯")))
+ (push pair surround-pairs))
+ (make-variable-buffer-local 'surround-pairs)
+ (add-hook 'emacs-lisp-mode-hook
+ (defun mm-editing-add-elisp-quotes-pair ()
+ (push '("`" . "'") surround-pairs))))
+
+
+;;; Insert Webpage Contents
+
+(defun mm-editing-insert-from-url (url)
+ "Insert the contents of URL at point."
+ (interactive
+ (progn
+ (barf-if-buffer-read-only)
+ (let ((url-at-point (thing-at-point 'url)))
+ (list (read-string
+ (format-prompt "URL" url-at-point)
+ nil nil url-at-point)))))
+ (call-process "curl" nil '(t nil) nil url))
+
+
+;;; Emmet Mode
+
+(defun mm-editing-emmet-dwim (arg)
+ "Do-What-I-Mean Emmet expansion.
+If the region is active then the region will be surrounded by an emmet
+expansion read from the minibuffer. Otherwise the emmet expression
+before point is expanded. When provided a prefix argument the behaviour
+is as described by `emmet-expand-line'."
+ (interactive "*P")
+ (if (region-active-p)
+ (call-interactively #'emmet-wrap-with-markup)
+ (emmet-expand-line arg)))
+
+;; PKG-EXTERN
+(use-package emmet-mode
+ :ensure t
+ :bind ("C-," . mm-editing-emmet-dwim)
+ :custom
+ (emmet-self-closing-tag-style ""))
+
+(defun mm-editing-set-closing-tag-style ()
+ (setq-local emmet-self-closing-tag-style " /"))
+
+(use-package emmet-mode
+ :hook (vue-ts-mode . mm-editing-set-closing-tag-style)
+ :after vue-ts-mode)
+
+
+;;; JQ Manipulation in JSON Mode
+
+;; PKG-INTERN
+(use-package jq
+ :commands (jq-filter-region jq-live))
+
+
+;;; Number Formatting
+
+;; PKG-INTERN
+(use-package number-format-mode
+ :commands ( number-format-buffer number-format-region
+ number-unformat-buffer number-unformat-region
+ number-format-mode))
+
+
+;;; Additional Major Modes
+
+(use-package awk-ts-mode :ensure t) ; PKG-EXTERN
+(use-package cmake-mode :ensure t) ; PKG-EXTERN
+(use-package git-modes :ensure t) ; PKG-EXTERN
+(use-package kdl-mode :ensure t) ; PKG-EXTERN
+(use-package po-mode :ensure t) ; PKG-EXTERN
+(use-package sed-mode :ensure t) ; PKG-EXTERN
+
+;; PKG-EXTERN
+(use-package csv-mode
+ :ensure t
+ :custom
+ (csv-align-style 'auto)
+ (csv-align-padding 2))
+
+(use-package csv-mode
+ :hook (csv-mode . number-format-mode)
+ :after number-format-mode)
+
+;; PKG-INTERN
+(use-package xcompose-mode
+ :vc ( :url "https://git.thomasvoss.com/xcompose-mode"
+ :branch "master"
+ :rev :newest
+ :vc-backend Git)
+ :ensure t)
+
+
+;;; Mode-Specific Configurations
+
+(use-package make-mode
+ :custom
+ (makefile-backslash-column 80))
+
+(use-package python-mode
+ :custom
+ (python-indent-def-block-scale 1)
+ (python-indent-guess-indent-offset-verbose nil))
+
+
+;;; Add Missing Extensions
+
+(dolist (pattern '("\\.tmac\\'" "\\.mom\\'"))
+ (add-to-list 'auto-mode-alist (cons pattern #'nroff-mode)))
+
+
+;;; Subword Navigation
+
+(use-package subword
+ :hook prog-mode)
+
+(provide 'mm-editing)
diff --git a/.config/emacs/modules/mm-humanwave.el b/.config/emacs/modules/mm-humanwave.el
new file mode 100644
index 0000000..9af567e
--- /dev/null
+++ b/.config/emacs/modules/mm-humanwave.el
@@ -0,0 +1,257 @@
+;;; mm-humanwave.el --- Humanwave extras -*- lexical-binding: t; -*-
+
+;;; Query the Backend
+
+(defvar mm-humanwave--query-history nil
+ "History for endpoints given to `mm-humanwave-query'.")
+
+(defun mm-humanwave-query (endpoint &optional method)
+ "Query and display the result of an HTTP request on ENDPOINT.
+If METHOD is nil, a GET request is performed."
+ (interactive
+ (let* ((query (read-string (format-prompt "Query" nil)
+ (car-safe mm-humanwave--query-history)
+ 'mm-humanwave--query-history))
+ (parts (string-split (string-trim query) " " :omit-nulls)))
+ (when (length> parts 2)
+ (user-error "Queries must be of the form `METHOD ENDPOINT' or `ENDPOINT'."))
+ (nreverse parts)))
+ (let* ((project-root (project-root (project-current :maybe-prompt)))
+ (qry-path (expand-file-name "qry" project-root))
+ extras)
+ (unless (file-executable-p qry-path)
+ (user-error "No `qry' executable found in the project root"))
+ (let ((output-buffer (get-buffer-create "*Query Response*")))
+ (with-current-buffer output-buffer
+ (delete-region (point-min) (point-max))
+ (call-process qry-path nil t nil
+ (string-trim endpoint) "-X" (or method "GET"))
+ (unless (eq major-mode 'json-ts-mode)
+ (json-ts-mode))
+ (goto-char (point-min)))
+ (display-buffer output-buffer))))
+
+
+;;; IMenu Support for Handlers
+
+(require 'imenu)
+(require 'which-func)
+
+(defvar mm-humanwave--handler-regexp
+ (rx bol
+ (* blank)
+ (or "if" "elif")
+ (* blank)
+ (or "dialog" "topic" "schedule")
+ (* blank)
+ "=="
+ (* blank)
+ (or ?\' ?\")
+ (group (+ (not (or ?\' ?\"))))
+ (or ?\' ?\")
+ (* blank)
+ ?:
+ (* blank)
+ eol))
+
+(defun mm-humanwave--handler-insert-entry (topic-index function-parts route pos)
+ (if (null function-parts)
+ (cons (cons (format "%s (route)" route) pos) topic-index)
+ (let* ((current-group (car function-parts))
+ (rest-parts (cdr function-parts))
+ (existing-sublist (assoc current-group topic-index)))
+ (if existing-sublist
+ (progn
+ (setcdr existing-sublist
+ (mm-humanwave--handler-insert-entry
+ (cdr existing-sublist) rest-parts route pos))
+ topic-index)
+ (cons (cons current-group
+ (mm-humanwave--handler-insert-entry
+ nil rest-parts route pos))
+ topic-index)))))
+
+(defun mm-humanwave-handler-topic-imenu-index ()
+ (let ((case-fold-search nil)
+ (tree-index (python-imenu-treesit-create-index))
+ (topic-index '()))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward mm-humanwave--handler-regexp nil :noerror)
+ (let ((route (match-string-no-properties 1))
+ (pos (match-beginning 0))
+ (function-parts (split-string (which-function) "\\.")))
+ (setq topic-index (mm-humanwave--handler-insert-entry
+ topic-index function-parts route pos)))))
+ (append (nreverse topic-index) tree-index)))
+
+(defun mm-humanwave-handler-topic-imenu-setup ()
+ "Setup custom imenu index for `python-ts-mode'."
+ (when (and (string-match-p "/handlers?/" (or (buffer-file-name) ""))
+ (derived-mode-p #'python-ts-mode))
+ (setq-local imenu-create-index-function
+ #'mm-humanwave-handler-topic-imenu-index)))
+
+(add-hook 'after-change-major-mode-hook
+ #'mm-humanwave-handler-topic-imenu-setup)
+
+
+;;; Insert Imports in Vue
+
+(defun mm-humanwave-insert-vue-import-path (base-directory target-file)
+ "Insert an import directive at POINT.
+The import directive imports TARGET-FILE relative from BASE-DIRECTORY.
+When called interactively BASE-DIRECTORY is the directory of the
+current open Vue file and TARGET-FILE is a file in the current project
+that is queried interactively.
+
+When called interactively the prefix argument can be used to emulate
+the behaviour of the INCLUDE-ALL-P argument to
+`mm-humanwave-project-read-file-name'."
+ (interactive
+ (progn
+ (barf-if-buffer-read-only)
+ (list
+ default-directory
+ (mm-humanwave-project-read-file-name current-prefix-arg)))
+ (let ((path (file-name-sans-extension
+ (file-relative-name target-file base-directory))))
+ (unless (string-match-p "/" path)
+ (setq path (concat "./" path)))
+ (insert "import ")
+ (save-excursion
+ (insert (thread-last
+ (file-name-base path)
+ (mm-string-split "-")
+ (mapconcat #'capitalize)))
+ (push-mark (point))
+ (insert (format " from '%s';" path)))))
+
+(defun mm-humanwave-project-read-file-name (&optional include-all-p)
+ "Prompt for a project file.
+This function is similar to `project-find-file', but it returns the
+path to the selected file instead of opening it.
+
+When called interactively the selected file is printed to the
+minibuffer, otherwise it is returned.
+
+The prefix argument INCLUDE-ALL-P is the same as the INCLUDE-ALL
+argument to the `project-find-file' command."
+ (interactive "P")
+ (let* ((project (project-current :maybe-prompt))
+ (root (project-root project))
+ (files (if include-all-p
+ (let ((vc-ignores (mapcar
+ (lambda (dir) (concat dir "/"))
+ vc-directory-exclusion-list)))
+ (project--files-in-directory root vc-ignores))
+ (project-files project)))
+ (canditates (mapcar (lambda (f) (file-relative-name f root))
+ files))
+ (table (lambda (string predicate action)
+ (if (eq action 'metadata)
+ '(metadata (category . file))
+ (complete-with-action action canditates string predicate))))
+ (default-directory root)
+ (choice (completing-read (format-prompt "Find project file" nil)
+ table nil :require-match)))
+ (let ((path (expand-file-name choice root)))
+ (if (called-interactively-p 'any)
+ (message "%s" path)
+ path))))
+
+(defun mm-humanwave-insert-last-commit-message ()
+ "Insert the last commit message at point.
+The inserted commit message will have it’s ticket ID prefix stripped."
+ (interactive "*")
+ (insert
+ (with-temp-buffer
+ (call-process "git" nil t nil "log" "-1" "--pretty=%s")
+ (goto-char (point-min))
+ (replace-regexp "\\`HW-[0-9]+ " "")
+ (string-trim (buffer-string)))))
+
+
+;;; Jira Integration
+
+(use-package jira
+ :ensure t
+ :custom
+ (jira-api-version 3)
+ (jira-base-url "https://humanwave.atlassian.net")
+ (jira-detail-show-announcements nil)
+ (jira-issues-max-results 100)
+ (jira-issues-table-fields '(:key :status-name :assignee-name :summary))
+ (jira-token-is-personal-access-token nil))
+
+
+;;; Icon Autocompletion
+
+(defvar mm-humanwave-icon-component-file "web/src/components/icon.vue"
+ "Path to the <icon /> component definition.")
+
+(defun mm-humanwave--find-icon-map ()
+ (let* ((project (project-current :maybe-prompt))
+ (path (expand-file-name mm-humanwave-icon-component-file
+ (project-root project))))
+ (unless (file-exists-p path)
+ (user-error "File `%s' does not exist." path))
+ (with-current-buffer (finda-file-noselect path)
+ (let* ((parser (treesit-parser-create 'typescript))
+ (root-node (treesit-parser-root-node parser))
+ (query `((((lexical_declaration
+ (variable_declarator
+ name: (identifier) @name)) @the_catch)
+ (:equal @name "ICON_MAP"))
+ (((variable_declaration
+ (variable_declarator
+ name: (identifier) @name)) @the_catch)
+ (:equal @name "ICON_MAP"))))
+ (captures (treesit-query-capture root-node query))
+ (found-node (alist-get 'the_catch captures)))
+ found-node))))
+
+(defun mm-humanwave--icon-list (found-node)
+ (let ((captures (treesit-query-capture found-node '((pair) @the_pair)))
+ (pairs nil))
+ (when captures
+ (dolist (capture captures)
+ (let* ((pair-node (cdr capture))
+ (key-node (treesit-node-child-by-field-name pair-node "key"))
+ (val-node (treesit-node-child-by-field-name pair-node "value")))
+ (when (and key-node val-node)
+ (push (cons (mm-camel-to-lisp
+ (treesit-node-text key-node :no-property))
+ (treesit-node-text val-node :no-property))
+ pairs))))
+ (sort pairs :key #'car :lessp #'string<))))
+
+(defun mm-humanwave-insert-icon-component ()
+ "Insert an icon at point with completion.
+
+This command provides completion for the available props that can be
+given to the <icon /> component. The parser searches for the `ICON_MAP'
+definition in the file specified by `mm-humanwave-icon-component-file'."
+ (interactive "*" vue-ts-mode)
+ (if-let* ((node (mm-humanwave--find-icon-map))
+ (alist (mm-humanwave--icon-list node))
+ (max-key-width
+ (thread-last
+ alist
+ (mapcar (lambda (pair) (length (car pair))))
+ (apply #'max)
+ (+ 4)))
+ (completion-extra-properties
+ `(:annotation-function
+ ,(lambda (key)
+ (concat
+ (propertize " "
+ 'display `(space :align-to ,max-key-width))
+ (propertize (cdr (assoc key alist))
+ 'face 'font-lock-string-face)))))
+ (prompt (format-prompt "Icon" nil))
+ (icon (completing-read prompt alist nil :require-match)))
+ (insert (format "<icon %s />" icon))
+ (error "Unable to find ICON_MAP definitions")))
+
+(provide 'mm-humanwave)
diff --git a/.config/emacs/modules/mm-keybindings.el b/.config/emacs/modules/mm-keybindings.el
new file mode 100644
index 0000000..94782ab
--- /dev/null
+++ b/.config/emacs/modules/mm-keybindings.el
@@ -0,0 +1,185 @@
+;;; mm-keybindings.el --- Emacs keybindings -*- lexical-binding: t; -*-
+
+(require 'editing-functions)
+
+;; The following keys are either unbound and are free to populate, or are
+;; bound to functions I don’t care for:
+;; ‘C-i’, ‘C-j’, ‘C-o’, ‘C-{’, ‘C-}’, ‘C-/’, ‘C-\;’, ‘C-:’
+
+
+;;; Helper Macros
+
+(defmacro mm-keybindings-keymap-set (keymap &rest definitions)
+ "TODO"
+ (declare (indent 1))
+ (unless (cl-evenp (length definitions))
+ (user-error "Expected an even-number of elements in DEFINITIONS."))
+ `(cl-loop for (from to) on (list ,@definitions) by #'cddr
+ do (keymap-set ,keymap from to)))
+
+(defmacro mm-keybindings-keymap-set-repeating (keymap &rest definitions)
+ "TODO"
+ (declare (indent 1))
+ (unless (cl-evenp (length definitions))
+ (user-error "Expected an even-number of elements in DEFINITIONS."))
+ (let ((keymap-gen (gensym "mm-keybindings--repeat-map-")))
+ `(progn
+ (defvar-keymap ,keymap-gen)
+ (cl-loop for (from to) on (list ,@definitions) by #'cddr
+ do (progn
+ (keymap-set ,keymap-gen from to)
+ (put to 'repeat-map ',keymap-gen))))))
+
+(defmacro mm-keybindings-keymap-remap (keymap &rest commands)
+ "Define command remappings for a given KEYMAP.
+COMMANDS is a sequence of unquoted commands. For each pair of
+COMMANDS the first command is remapped to the second command."
+ (declare (indent 1))
+ (unless (cl-evenp (length commands))
+ (user-error "Expected an even-number of elements in COMMANDS."))
+ (macroexp-progn
+ (cl-loop for (from to) in (seq-partition commands 2)
+ collect `(keymap-set
+ ,keymap
+ ,(concat "<remap> <" (symbol-name from) ">")
+ #',to))))
+
+
+;;; Support the Kitty Keyboard Protocol
+
+;; PKG-EXTERN
+(use-package kkp
+ :ensure t
+ :unless (or (display-graphic-p) mm-humanwave-p)
+ :hook (tty-setup . global-kkp-mode))
+
+
+;;; Support QMK Hyper
+
+(defun mm-keybindings-qmk-hyper-as-hyper (args)
+ "Around advice for `keymap-set' to handle QMK hyper."
+ (let ((chord (cadr args)))
+ (when (string-prefix-p "H-" chord)
+ (setf (cadr args) (concat "C-M-S-s" (substring chord 1)))))
+ args)
+
+;; Both ‘keymap-global-set’ and ‘keymap-local-set’ call ‘keymap-set’
+;; internally, so this advice covers all cases
+(advice-add #'keymap-set :filter-args #'mm-keybindings-qmk-hyper-as-hyper)
+
+
+;;; Disable ESC as Meta
+
+(keymap-global-set "<escape>" #'ignore)
+
+
+;;; Enable Repeat Bindings
+
+(defun mm-keybindings-enable-repeat-mode ()
+ "Enable `repeat-mode' without polluting the echo area."
+ (mm-with-suppressed-output
+ (repeat-mode)))
+
+(use-package repeat
+ :hook (after-init . mm-keybindings-enable-repeat-mode)
+ :custom
+ (repeat-exit-timeout 5))
+
+
+;;; Remap Existing Bindings
+
+(mm-keybindings-keymap-remap global-map
+ backward-delete-char-untabify backward-delete-char
+
+ capitalize-word capitalize-dwim
+ downcase-word downcase-dwim
+ upcase-word upcase-dwim
+
+ delete-indentation ef-join-current-and-next-line
+ mark-sexp ef-mark-entire-sexp
+ mark-word ef-mark-entire-word
+ open-line ef-open-line
+ yank ef-yank)
+
+(with-eval-after-load 'cc-vars
+ (setopt c-backspace-function #'backward-delete-char))
+
+
+;;; Remove Unwanted Bindings
+
+(keymap-global-unset "C-x C-c" :remove) ; ‘capitalize-region’
+(keymap-global-unset "C-x C-l" :remove) ; ‘downcase-region’
+(keymap-global-unset "C-x C-u" :remove) ; ‘upcase-region’
+
+;; The following conflicts with ‘ace-window’
+(use-package mhtml-mode
+ :after ace-window
+ :config
+ (keymap-unset html-mode-map "M-o" :remove))
+
+
+;;; Bind Commands Globally
+
+(mm-keybindings-keymap-set global-map
+ "<next>" #'forward-page
+ "<prior>" #'backward-page
+ "C-<next>" #'scroll-up
+ "C-<prior>" #'scroll-down
+
+ "C-." #'repeat
+ "C-^" #'ef-split-line
+ "C-/" #'ef-mark-line-dwim
+ "C-]" #'ef-search-forward-char
+
+ "M-\\" #'cycle-spacing
+
+ "C-c c a" #'mc/vertical-align-with-space
+ "C-c c i" #'mc/insert-numbers
+ "C-c c t" #'mce-transpose-cursor-regions
+ "C-c c s" #'ef-sort-dwim
+ "C-c c f" #'fill-paragraph
+ "C-c d" #'duplicate-dwim)
+
+(mm-keybindings-keymap-set-repeating global-map
+ "j" #'ef-join-current-and-next-line
+ "J" #'join-line)
+
+(mm-keybindings-keymap-set-repeating global-map
+ "n" #'next-error
+ "p" #'previous-error)
+
+(with-eval-after-load 'increment
+ (mm-keybindings-keymap-set-repeating global-map
+ "d" #'decrement-number-at-point
+ "i" #'increment-number-at-point))
+
+
+;;; Other Bindings
+
+(with-eval-after-load 'project
+ (with-eval-after-load 'grab
+ (mm-keybindings-keymap-set project-prefix-map
+ "G" #'project-git-grab))
+
+ (when mm-humanwave-p
+ (mm-keybindings-keymap-set project-prefix-map
+ "q" #'mm-humanwave-query)))
+
+(use-package minibuffer
+ :if mm-humanwave-p
+ :config
+ (mm-keybindings-keymap-set minibuffer-mode-map
+ "C-c m" #'mm-humanwave-insert-last-commit-message))
+
+
+;;; Display Available Keybindings
+
+;; PKG-EXTERN
+(use-package which-key
+ :hook after-init
+ :custom
+ (which-key-dont-use-unicode nil)
+ (which-key-ellipsis "…")
+ (wihch-key-idle-delay .5))
+
+(provide 'mm-keybindings)
diff --git a/.config/emacs/modules/mm-projects.el b/.config/emacs/modules/mm-projects.el
new file mode 100644
index 0000000..6ac35b0
--- /dev/null
+++ b/.config/emacs/modules/mm-projects.el
@@ -0,0 +1,48 @@
+;;; mm-projects.el --- Configuration for project management -*- lexical-binding: t; -*-
+
+;;; Project Configuration
+
+(use-package project
+ :config
+ (unless mm-humanwave-p
+ ;; TODO: Speed this up
+ (if-let ((repo-directory (getenv "REPODIR")))
+ (let* ((list-dir
+ (lambda (path)
+ (directory-files path :full "\\`[^.]")))
+ (directories
+ (cl-loop for author in (funcall list-dir (getenv "REPODIR"))
+ append (cl-loop for path in (funcall list-dir author)
+ collect (list (concat path "/"))))))
+ (with-temp-buffer
+ (prin1 directories (current-buffer))
+ (write-file project-list-file))
+ (project--read-project-list))
+ (warn "The REPODIR environment variable is not set."))))
+
+
+;;; Version Control Support
+
+(use-package vc-hooks
+ :custom
+ (vc-follow-symlinks t)
+ (vc-handled-backends '(Git)))
+
+
+;; Project Compilation
+
+(use-package compile
+ :config
+ (require 'ansi-color)
+ (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter))
+
+
+;;; GitHub Pull Requests
+
+;; PKG-INTERN
+(use-package gh
+ :bind (("C-c p c" . #'gh-create-pr)
+ ("C-c p o" . #'gh-open-previous-pr))
+ :commands (gh-create-pr gh-open-previous-pr))
+
+(provide 'mm-projects)
diff --git a/.config/emacs/modules/mm-search.el b/.config/emacs/modules/mm-search.el
new file mode 100644
index 0000000..7c9fece
--- /dev/null
+++ b/.config/emacs/modules/mm-search.el
@@ -0,0 +1,26 @@
+;;; mm-search.el --- Emacs text searching -*- lexical-binding: t; -*-
+
+;;; Classic Emacs text search
+
+(use-package isearch
+ :demand t
+ :custom
+ (search-whitespace-regexp ".*?")
+ (isearch-lax-whitespace t)
+ (isearch-regexp-lax-whitespace nil)
+ (isearch-lazy-count t)
+ (lazy-highlight-initial-delay 0)
+ (lazy-count-prefix-format "%d/%d ")
+ (isearch-repeat-on-direction-change t))
+
+
+;;; Grab Integration
+
+;; PKG-INTERN
+(use-package grab
+ :commands ( grab git-grab project-grab project-git-grab
+ dired-grab-marked-files)
+ :custom
+ (grab-default-pattern '("x/^.*?$/ g// h//" . 12)))
+
+(provide 'mm-search)
diff --git a/.config/emacs/modules/mm-tetris.el b/.config/emacs/modules/mm-tetris.el
new file mode 100644
index 0000000..2a0a206
--- /dev/null
+++ b/.config/emacs/modules/mm-tetris.el
@@ -0,0 +1,19 @@
+;;; mm-tetris.el --- Emacs configurations for ‘tetris’ -*- lexical-binding: t; -*-
+
+(defun mm-tetris-rotate-mirror ()
+ "Rotate the current piece by 180°."
+ (interactive nil tetris-mode)
+ (tetris-rotate-next)
+ (tetris-rotate-next))
+
+(use-package tetris
+ :bind ( :map tetris-mode-map
+ ("a" . tetris-move-left)
+ ("d" . tetris-move-right)
+ ("k" . tetris-rotate-next)
+ (";" . tetris-rotate-prev)
+ ("l" . tetris-move-down)
+ ("o" . mm-tetris-rotate-mirror)
+ ("SPC" . tetris-move-bottom)))
+
+(provide 'mm-tetris)
diff --git a/.config/emacs/modules/mm-theme.el b/.config/emacs/modules/mm-theme.el
new file mode 100644
index 0000000..572064b
--- /dev/null
+++ b/.config/emacs/modules/mm-theme.el
@@ -0,0 +1,232 @@
+;;; mm-theme.el --- Emacs theme settings -*- lexical-binding: t; -*-
+
+
+;;; Themes
+
+(setopt custom-theme-directory (expand-file-name "themes" mm-config-directory))
+(load-theme 'mango-dark :no-confirm)
+
+
+;;; Disable Cursor Blink
+
+(use-package frame
+ :config
+ (blink-cursor-mode -1))
+
+
+;;; Fonts
+
+(defvar mm-theme-monospace-font `(,(if mm-humanwave-p
+ "Iosevka Custom"
+ "Iosevka Smooth")
+ :weight regular
+ :height 162)
+ "The default monospace font.
+This is a plist containing a font name, -weight, and -height.")
+
+(defvar mm-theme-proportional-font
+ ;; TODO: SF font?
+ `(,(if mm-darwin-p "Microsoft Sans Serif" "SF Pro Text")
+ :weight regular :height 162)
+ "The default proportional font.
+This is a plist containing a font name, -weight, and -height.")
+
+(defun mm-theme-set-fonts (&optional _frame)
+ "Set frame font settings.
+Sets the frame font settings according to the fonts specified by
+`mm-theme-monospace-font' and `mm-theme-proportional-font'.
+
+This function can be used as a hook in `after-make-frame-functions' and
+_FRAME is ignored."
+ (interactive)
+ (let* ((mono-family (car mm-theme-monospace-font))
+ (mono-props (cdr mm-theme-monospace-font))
+ (prop-family (car mm-theme-proportional-font))
+ (prop-props (cdr mm-theme-proportional-font))
+ (mono-weight (plist-get mono-props :weight))
+ (mono-height (plist-get mono-props :height))
+ (prop-weight (plist-get prop-props :weight))
+ (prop-height (plist-get prop-props :height)))
+ ;; Some characters in this font are larger than usual
+ (when (string= mono-family "Iosevka Smooth")
+ (dolist (rune '(?․ ?‥ ?… ?— ?← ?→ ?⇐ ?⇒ ?⇔))
+ (set-char-table-range char-width-table rune 2)))
+ (set-face-attribute 'default nil
+ :font mono-family
+ :weight mono-weight
+ :height mono-height)
+ (set-face-attribute 'fixed-pitch nil
+ :font mono-family
+ :weight mono-weight
+ :height mono-height)
+ (set-face-attribute 'variable-pitch nil
+ :font prop-family
+ :weight prop-weight
+ :height prop-height)))
+
+(if (daemonp)
+ (add-hook 'after-make-frame-functions #'mm-theme-set-fonts)
+ (mm-theme-set-fonts))
+
+
+;;; Ligature Support
+
+(defvar mm-theme-ligatures-alist
+ `(((c-mode c++-mode)
+ . ("->"))
+ ((c++-mode)
+ . ("::"))
+ ((js-mode typescript-ts-mode vue-ts-mode)
+ . (("=" ,(rx (or ?> (** 1 2 ?=))))
+ ("!" ,(rx (** 1 2 ?=)))))
+ (go-ts-mode
+ . (":=" "<-"))
+ ((python-mode)
+ . (":=" "->"))
+ ((mhtml-mode html-mode vue-ts-mode)
+ . ("<!--" "-->" "/>"))
+ (prog-mode
+ . ("<<=" "<=" ">=" "==" "!=" "*=" ("_" "_+"))))
+ "Ligatures to enable in specific modes.
+Elements of this alist are of the form:
+
+ (SPEC . LIGATURES)
+
+Where LIGATURES is a list of ligatures to enable for the set of modes
+described by SPEC.
+
+SPEC can be either a symbol, or a list of symbols. These symbols
+should correspond to modes for which the associated LIGATURES should
+be enabled.
+
+A mode may also be specified in multiple entries. To configure
+`go-ts-mode' to have its set of ligatures be a super-set of the
+ligatures for `c-ts-mode', the following two entries could be added:
+
+ \\='((c-ts-mode go-ts-mode) . (\">=\" \"<=\" \"!=\" \"==\"))
+ \\='(go-ts-mode . (\":=\"))
+
+When a language is specified and it’s tree-sitter compatriot is bound,
+then LIGATURES are bound for both modes.")
+
+(defun mm-theme-update-ligatures ()
+ "Update the ligature composition tables.
+After running this function you may need to restart `ligature-mode'.
+
+Also see `mm-theme-ligatures-alist'."
+ (interactive)
+ (setopt ligature-composition-table nil)
+ (cl-loop for (spec . ligatures) in mm-theme-ligatures-alist
+ do (ligature-set-ligatures spec ligatures)
+ (cl-loop for mode in spec
+ when (fboundp (mm-mode-to-ts-mode mode))
+ do (ligature-set-ligatures mode ligatures))))
+
+;; PKG-EXTERN
+(use-package ligature
+ :ensure t
+ :if (and (display-graphic-p)
+ (or (seq-contains-p (split-string system-configuration-features)
+ "HARFBUZZ")
+ mm-darwin-p))
+ :hook prog-mode
+ :config
+ (mm-theme-update-ligatures))
+
+
+;;; Background Opacity
+
+(defvar mm-theme-background-opacity 100
+ "Opacity of the graphical Emacs frame.
+A value of 0 is fully transparent while 100 is fully opaque.")
+
+(defun mm-theme-set-background-opacity (opacity)
+ "Set the current frames' background opacity.
+See also the `mm-theme-background-opacity' variable."
+ (interactive
+ (list (mm-as-number
+ (read-string
+ (format-prompt "Background opacity"
+ (default-value 'mm-theme-background-opacity))
+ nil nil mm-theme-background-opacity))))
+ (set-frame-parameter nil 'alpha-background opacity))
+
+(add-to-list
+ 'default-frame-alist (cons 'alpha-background mm-theme-background-opacity))
+
+
+;;; Divider Between Windows
+
+(use-package frame
+ :hook (after-init . window-divider-mode))
+
+
+;;; In-Buffer Highlighting
+
+;; PKG-INTERN
+(use-package highlighter
+ :bind (("C-c h m" . #'highlighter-mark)
+ ("C-c h u" . #'highlighter-unmark)
+ ("C-c h U" . #'highlighter-unmark-buffer))
+ :commands (highlighter-mark highlighter-unmark highlighter-unmark-buffer)
+ :init
+ (require 'hi-lock)) ; For extra face definitions
+
+
+;;; Pretty Page Boundaries
+
+;; TODO: Implement this myself?
+(use-package page-break-lines
+ :ensure t
+ :hook (after-init . global-page-break-lines-mode)
+ :config
+ (dolist (mode '(c-mode c++-mode gsp-ts-mode))
+ (add-to-list 'page-break-lines-modes mode)
+ (let ((ts-mode (mm-mode-to-ts-mode mode)))
+ (when (fboundp ts-mode)
+ (add-to-list 'page-break-lines-modes ts-mode))))
+ (add-hook
+ 'change-major-mode-hook
+ (defun mm-theme--set-page-break-max-width ()
+ (setopt page-break-lines-max-width fill-column)))
+ ;; Since the ‘^L’ character is replaced by a horizontal rule, the
+ ;; cursor should appear below the horizontal rule. When moving
+ ;; backwards we need to account for the fact that the cursor is
+ ;; actually one character ahead of hte page break and adjust
+ ;; accordingly.
+ (advice-add
+ #'forward-page :after
+ (defun mm-theme--forward-char (&rest _)
+ (forward-char)))
+ (advice-add
+ #'backward-page :before
+ (defun mm-theme--backward-char (&rest _)
+ (backward-char))))
+
+
+;;; Line Highlighting
+
+(use-package hl-line
+ :custom
+ (hl-line-sticky-flag nil))
+
+
+;;; Indent Guides
+
+(when mm-humanwave-p
+ (use-package highlight-indent-guides
+ :ensure t
+ :hook ((jinja2-mode vue-ts-mode mhtml-mode) . highlight-indent-guides-mode)
+ :custom
+ (highlight-indent-guides-method 'fill)
+ (highlight-indent-guides-auto-even-face-perc 30)
+ (highlight-indent-guides-auto-odd-face-perc 0)))
+
+
+;;; Instantly highlight matching parens
+
+(use-package paren
+ :custom
+ (show-paren-delay 0))
+
+(provide 'mm-theme)
diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el
new file mode 100644
index 0000000..9c983a0
--- /dev/null
+++ b/.config/emacs/modules/mm-treesit.el
@@ -0,0 +1,261 @@
+;;; mm-treesit.el --- Tree-Sitter configuration -*- lexical-binding: t; -*-
+
+(require 'treesit)
+
+;;; Tree-Sitter Variables
+
+(defvar mm-treesit-language-remap-alist
+ '((cpp . c++)
+ (gomod . go-mod)
+ (javascript . js)
+ (vim . vimscript))
+ "TODO")
+
+(defun mm-treesit--map-language (language)
+ (declare (ftype (function (symbol) symbol))
+ (pure t) (side-effect-free t))
+ (alist-get language mm-treesit-language-remap-alist language))
+
+(defun mm-treesit--language-exists-p (language)
+ (declare (ftype (function (symbol) boolean))
+ (pure t) (side-effect-free t))
+ (thread-last
+ (mm-treesit--map-language language)
+ (format "%s-ts-mode")
+ (intern)
+ (fboundp)))
+
+(setopt treesit-font-lock-level 2)
+(setopt treesit-language-source-alist
+ '((awk
+ "https://github.com/Beaglefoot/tree-sitter-awk")
+ (c
+ "https://github.com/tree-sitter/tree-sitter-c")
+ (cpp
+ "https://github.com/tree-sitter/tree-sitter-cpp")
+ (css
+ "https://github.com/tree-sitter/tree-sitter-css")
+ (dockerfile
+ "https://github.com/camdencheek/tree-sitter-dockerfile")
+ (elixir
+ "https://github.com/elixir-lang/tree-sitter-elixir")
+ (go
+ "https://github.com/tree-sitter/tree-sitter-go")
+ (gomod
+ "https://github.com/camdencheek/tree-sitter-go-mod")
+ (gsp
+ "git://git.thomasvoss.com/tree-sitter-gsp.git")
+ (heex
+ "https://github.com/phoenixframework/tree-sitter-heex")
+ (html
+ "https://github.com/tree-sitter/tree-sitter-html")
+ (java
+ "https://github.com/tree-sitter/tree-sitter-java")
+ (javascript
+ "https://github.com/tree-sitter/tree-sitter-javascript")
+ (json
+ "https://github.com/tree-sitter/tree-sitter-json")
+ (markdown
+ "https://github.com/tree-sitter-grammars/tree-sitter-markdown"
+ "split_parser" "tree-sitter-markdown/src")
+ (markdown-inline
+ "https://github.com/tree-sitter-grammars/tree-sitter-markdown"
+ "split_parser" "tree-sitter-markdown-inline/src")
+ (python
+ "https://github.com/tree-sitter/tree-sitter-python")
+ (rust
+ "https://github.com/tree-sitter/tree-sitter-rust")
+ (tsx
+ "https://github.com/tree-sitter/tree-sitter-typescript"
+ "master" "tsx/src")
+ (typescript
+ "https://github.com/tree-sitter/tree-sitter-typescript"
+ "master" "typescript/src")
+ (vim
+ "https://github.com/tree-sitter-grammars/tree-sitter-vim")
+ (vue
+ "https://github.com/ikatyang/tree-sitter-vue")
+ (yaml
+ "https://github.com/tree-sitter-grammars/tree-sitter-yaml")))
+
+
+;;; Install Missing Parsers
+
+(defun mm-treesit-install-all ()
+ "Install all Tree-Sitter parsers.
+This is like `mm-treesit-install-missing' but also reinstalls parsers
+that are already installed."
+ (interactive)
+ (cl-loop for (lang) in treesit-language-source-alist
+ when (mm-treesit--language-exists-p lang)
+ do (treesit-install-language-grammar lang)))
+
+(defun mm-treesit-install-missing ()
+ "Install missing Tree-Sitter parsers.
+The parsers are taken from `treesit-language-source-alist'."
+ (interactive)
+ (cl-loop for (lang) in treesit-language-source-alist
+ unless (or (treesit-language-available-p lang)
+ (not (mm-treesit--language-exists-p lang)))
+ do (treesit-install-language-grammar lang)))
+
+(mm-treesit-install-missing)
+
+
+;;; Install Additional TS Modes
+
+;; PKG-INTERN
+(use-package gsp-ts-mode
+ :vc (:url "https://git.thomasvoss.com/gsp-ts-mode"
+ :branch "master"
+ :rev :newest
+ :vc-backend Git)
+ :ensure t)
+
+;; NOTE: This package doesn’t autoload its ‘auto-mode-alist’ entries
+;; PKG-EXTERN
+(use-package vimscript-ts-mode
+ :ensure t
+ :mode (rx (or (seq (? (or ?. ?_)) (? ?g) "vimrc")
+ ".vim"
+ ".exrc")
+ eos))
+
+;; NOTE: This package doesn’t autoload its ‘auto-mode-alist’ entries
+;; PKG-EXTERN
+(use-package vue-ts-mode
+ :vc ( :url "https://github.com/8uff3r/vue-ts-mode.git"
+ :branch "main"
+ :rev :newest
+ :vc-backend Git)
+ :ensure t
+ :mode "\\.vue\\'")
+
+;; NOTE: This package doesn’t autoload its ‘auto-mode-alist’ entries
+;; PKG-EXTERN
+(use-package markdown-ts-mode
+ :ensure t
+ :mode "\\.md\\'")
+
+
+;;; Prefer Tree-Sitter Modes
+
+;; NOTE: ‘go-ts-mode’ already adds itself to ‘auto-mode-alist’ but it
+;; isn’t autoloaded as of 2024-09-29 so we need to do it ourselves
+;; anyway. Same goes for ‘typescript-ts-mode’.
+(defvar mm-treesit-language-file-name-alist
+ '((dockerfile . "/[Dd]ockerfile\\'")
+ (elixir . "\\.exs?\\'")
+ (go . "\\.go\\'")
+ (gomod . "/go\\.mod\\'")
+ (heex . "\\.heex\\'")
+ (json . "\\.json\\'")
+ (rust . "\\.rs\\'")
+ (tsx . "\\.tsx\\'")
+ (typescript . "\\.ts\\'")
+ (yaml . "\\.ya?ml\\'"))
+ "Alist mapping languages to their associated file-names.
+This alist is a set of pairs of the form (LANG . REGEXP) where LANG is
+the symbol corresponding to a major mode with the `-ts-mode' suffix
+removed. REGEXP is a regular expression matching filenames for which
+the associated language’s major-mode should be enabled.
+
+This alist is used to configure `auto-mode-alist'.")
+
+(defvar mm-treesit-dont-have-modes
+ '(markdown-inline)
+ "List of languages that don't have modes.
+Some languages may come with multiple parsers, (e.g. `markdown' and
+`markdown-inline') and as a result one-or-more of the parsers won't be
+associated with a mode. To avoid breaking the configuration, these
+languages should be listed here.")
+
+(dolist (spec treesit-language-source-alist)
+ (let* ((lang (car spec))
+ (lang-remap (mm-treesit--map-language lang))
+ (name-mode (intern (format "%s-mode" lang-remap)))
+ (name-ts-mode (intern (format "%s-ts-mode" lang-remap))))
+ ;; If ‘name-ts-mode’ is already in ‘auto-mode-alist’ then we don’t
+ ;; need to do anything, however if that’s not the case then if
+ ;; ‘name-ts-mode’ and ‘name-mode’ are both bound we do a simple
+ ;; remap. If the above is not true then we lookup the extensions in
+ ;; ‘mm-treesit-language-file-name-alist’.
+ (cond
+ ((memq lang mm-treesit-dont-have-modes)
+ nil)
+ ((not (fboundp name-ts-mode))
+ nil)
+ ((rassq name-ts-mode auto-mode-alist)
+ nil)
+ ((fboundp name-mode)
+ (add-to-list 'major-mode-remap-alist (cons name-mode name-ts-mode)))
+ (:else
+ (if-let ((file-regexp
+ (alist-get lang mm-treesit-language-file-name-alist)))
+ (add-to-list 'auto-mode-alist (cons file-regexp name-ts-mode))
+ (warn "Unable to determine the extension for `%s'." name-ts-mode))))))
+
+;; JavaScript being difficult as usual
+(add-to-list 'major-mode-remap-alist '(javascript-mode . js-ts-mode))
+
+
+;;; Hack For C23
+
+(advice-add #'c-ts-mode--keywords :filter-return
+ (defun mm-c-ts-mode-add-constexpr (keywords)
+ ;; NOTE: We can’t add ‘typeof’ until it’s added to the TS grammar
+ ;; https://github.com/tree-sitter/tree-sitter-c/issues/236
+ (append keywords '("constexpr"))))
+
+
+;;; Highlight Predefined Variables
+
+(defun mm-treesit-c-apply-font-lock-extras ()
+ (setq treesit-font-lock-settings
+ (append treesit-font-lock-settings
+ mm-treesit--c-font-lock-rules)))
+
+(use-package c-ts-mode
+ :hook (c-ts-mode . mm-treesit-c-apply-font-lock-extras))
+
+(defvar mm-treesit--c-font-lock-rules
+ (treesit-font-lock-rules
+ :language 'c
+ :feature 'constant
+ :override t
+ `(((identifier) @font-lock-constant-face
+ (:match ,(rx bos (or "__func__" "__FUNCTION__") eos)
+ @font-lock-constant-face)))))
+
+
+;;; Region Expansion
+
+(defun mm-treesit-expreg-expand (n)
+ "Expand to N syntactic units."
+ (interactive "p")
+ (dotimes (_ n)
+ (expreg-expand)))
+
+(defun mm-treesit-expreg-expand-dwim ()
+ "Do-What-I-Mean `expreg-expand' to start with symbol or word.
+If over a real symbol, mark that directly, else start with a word. Fall
+back to regular `expreg-expand'."
+ (interactive)
+ (if (region-active-p)
+ (expreg-expand)
+ (let ((symbol (bounds-of-thing-at-point 'symbol)))
+ (cond
+ ((equal (bounds-of-thing-at-point 'word) symbol)
+ (mm-treesit-expreg-expand 1))
+ (symbol
+ (mm-treesit-expreg-expand 2))
+ (:else
+ (expreg-expand))))))
+
+;; PKG-EXTERN
+(use-package expreg
+ :ensure t
+ :commands (mm-treesit-expreg-expand mm-treesit-expreg-expand-dwim)
+ :bind ("M-SPC" . mm-treesit-expreg-expand-dwim))
+
+(provide 'mm-treesit)
diff --git a/.config/emacs/modules/mm-window.el b/.config/emacs/modules/mm-window.el
new file mode 100644
index 0000000..dcbf5b6
--- /dev/null
+++ b/.config/emacs/modules/mm-window.el
@@ -0,0 +1,79 @@
+;;; mm-window.el --- Window configurations -*- lexical-binding: t; -*-
+
+;;; Unique Buffer Names
+
+(use-package uniquify
+ :custom
+ (uniquify-buffer-name-style 'forward))
+
+
+;;; Highlight Whitespace
+
+(use-package whitespace
+ :bind (("<f1>" . whitespace-mode)
+ ("C-c z" . delete-trailing-whitespace))
+ :custom
+ (whitespace-style
+ '( face trailing spaces tabs space-mark tab-mark empty indentation
+ space-after-tab space-before-tab))
+ (whitespace-display-mappings
+ '((space-mark 32 [?·] [?.]) ; Space
+ (space-mark 160 [?␣] [?_]) ; Non-Breaking Space
+ (tab-mark 9 [?» ?\t] [?> ?\t]))))
+
+
+;;; Line Numbers
+
+(use-package display-line-numbers
+ :bind ("<f2>" . display-line-numbers-mode)
+ :custom
+ (display-line-numbers-grow-only t)
+ (display-line-numbers-type 'relative)
+ (display-line-numbers-width-start 99))
+
+
+;;; Select Help Windows
+
+(use-package help
+ :custom
+ (help-window-select t))
+
+
+;;; Window Scrolling
+
+(use-package window
+ :custom
+ (scroll-conservatively 101) ; (info "(Emacs)Auto Scrolling")
+ (scroll-error-top-bottom t)
+ (scroll-margin 10)
+ :config
+ (setq-default truncate-partial-width-windows nil))
+
+
+;;; Smoother Scrolling
+
+(mm-comment
+ (use-package pixel-scroll
+ :init
+ (pixel-scroll-precision-mode)
+ :config
+ ;; Make it easier to use custom scroll functions
+ (dolist (binding '("<next>" "<prior>"))
+ (keymap-unset pixel-scroll-precision-mode-map binding :remove))))
+
+
+;;; Ace Window
+
+;; PKG-EXTERN
+(use-package ace-window
+ :ensure t
+ :bind ("M-o" . ace-window)
+ :custom
+ (aw-make-frame-char ?.)
+ (aw-scope 'frame)
+ ;; Use uppercase labels because they look nicer, but allow selecting
+ ;; with lowercase so that I don’t need to hold shift.
+ (aw-keys (cl-loop for x from ?A to ?Z collect x))
+ (aw-translate-char-function #'upcase))
+
+(provide 'mm-window)