diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-04-03 02:09:58 +0200 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-04-03 02:09:58 +0200 |
| commit | daeeecee613987bd821b4e15d03b2cb925cd88b0 (patch) | |
| tree | ac0a00fbd75e586431244832b1e1ee846bd17f68 /.config/emacs-old/modules/mm-abbrev.el | |
| parent | 42effeee09203f4ec101bb3c0e5c9028bcce97fc (diff) | |
emacs: Mark the config as legacy
Diffstat (limited to '.config/emacs-old/modules/mm-abbrev.el')
| -rw-r--r-- | .config/emacs-old/modules/mm-abbrev.el | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/.config/emacs-old/modules/mm-abbrev.el b/.config/emacs-old/modules/mm-abbrev.el new file mode 100644 index 0000000..d32ec0d --- /dev/null +++ b/.config/emacs-old/modules/mm-abbrev.el @@ -0,0 +1,110 @@ +;;; mm-abbrev.el --- Emacs abbreviations and templates -*- lexical-binding: t; -*- + +;;; Helpers + +(defmacro mm-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 + +(defvar mm-c-mode-abbrev-table (make-abbrev-table) + "Abbreviations shared between `c-mode', `c++-mode', `c-ts-mode', and +`c++-ts-mode'.") + +(mm-define-abbreviations mm-c-mode-abbrev-table + "flf" "flockfile" + "fpf" "fprintf" + "fuf" "funlockfile" + "pf" "printf" + "sde" "stderr" + "sdi" "stdin" + "sdo" "stdout") + +(with-eval-after-load 'cc-mode + (setq c-mode-abbrev-table (copy-abbrev-table mm-c-mode-abbrev-table) + c++-mode-abbrev-table (copy-abbrev-table mm-c-mode-abbrev-table))) +(with-eval-after-load 'c-ts-mode + (setq c-ts-mode-abbrev-table (copy-abbrev-table mm-c-mode-abbrev-table) + c++-ts-mode-abbrev-table (copy-abbrev-table mm-c-mode-abbrev-table))) + +(mm-define-abbreviations emacs-lisp-mode-abbrev-table + "ald" ";;;###autoload" + "gc" "goto-char" + "ins" "insert" + "itv" "interactive" + "mtb" "match-beginning" + "mte" "match-end" + "ntr" "narrow-to-region" + "pbl" "pos-bol" + "pel" "pos-eol" + "pmn" "point-min" + "pmx" "point-max" + "pnt" "point" + "rap" "region-active-p" + "rb" "region-beginning" + "re" "region-end" + "rsb" "re-search-backward" + "rsf" "re-search-forward" + "sb" "search-backward" + "se" "save-excursion" + "sf" "search-forward" + "sme" "save-mark-and-excursion" + "sr" "save-restriction") + +(when mm-humanwave-p + (with-eval-after-load 'python + (mm-define-abbreviations python-ts-mode-abbrev-table + "empb" "with emphasize.Block():" + "empf" "@emphasize.func" + "empi" "from shared.system import emphasize" + "empt" "emphasize.this"))) + + +;;; Template Configuration + +(use-package tempel + :ensure t + :demand t + :pin gnu + :bind ( :map tempel-map + ("TAB" . tempel-next) + ("S-TAB" . tempel-previous)) + :custom + (tempel-trigger-prefix "<") + :init + (setopt tempel-path (expand-file-name "templates" mm-config-directory)) + (dolist (mode '(conf-mode prog-mode text-mode)) + (add-hook (mm-mode-to-hook mode) + (defun mm-setup-tempel-capf () + (add-hook 'completion-at-point-functions + #'tempel-complete -10 :local)))) + (add-to-list 'auto-mode-alist (cons tempel-path #'lisp-data-mode))) + +(provide 'mm-abbrev) |