commit 6a68ad1081bf3cd6dca5f3dee58b738eb53d8269 from: Ashton Wiersdorf via: mtmn date: Tue Jul 15 19:52:32 2025 UTC Add Tempel configuration to dev.el commit - 1f595c0978daa39795209bc3fbefaaa42b695dd5 commit + 6a68ad1081bf3cd6dca5f3dee58b738eb53d8269 blob - 215e982797826bcac188fef386f9fdee7aaf122b blob + d3ca6b4f4c6fe1f4650f40701818c62165c37443 --- extras/base.el +++ extras/base.el @@ -72,7 +72,7 @@ (use-package embark :ensure t :demand t - :after avy + :after (avy embark-consult) :bind (("C-c a" . embark-act)) ; bind this to an easy key to hit :init ;; Add the option to run embark when using avy blob - fe535f53a608a69a8a4c9bfd2acd3723a3297074 blob + cf0530e3fffd988dbd79053bc6ce40797d7b215e --- extras/dev.el +++ extras/dev.el @@ -20,6 +20,7 @@ ;;; - Version Control ;;; - Common file types ;;; - Eglot, the built-in LSP client for Emacs +;;; - Templating ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; @@ -96,7 +97,7 @@ ;; Configure hooks to automatically turn-on eglot for selected modes ; :hook - ; (((python-mode ruby-mode elixir-mode) . eglot)) + ; (((python-mode ruby-mode elixir-mode) . eglot-ensure)) :custom (eglot-send-changes-idle-time 0.1) @@ -108,3 +109,34 @@ ; (add-to-list 'eglot-server-programs ; '(haskell-mode . ("haskell-language-server-wrapper" "--lsp"))) ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; +;;; Templating +;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(use-package tempel + :ensure t + ;; By default, tempel looks at the file "templates" in + ;; user-emacs-directory, but you can customize that with the + ;; tempel-path variable: + ;; :custom + ;; (tempel-path (concat user-emacs-directory "custom_template_file")) + :bind (("M-*" . tempel-insert) + ("M-+" . tempel-complete) + :map tempel-map + ("C-c RET" . tempel-done) + ("C-" . tempel-next) + ("C-" . tempel-previous) + ("M-" . tempel-next) + ("M-" . tempel-previous)) + :init + ;; Make a function that adds the tempel expansion function to the + ;; list of completion-at-point-functions (capf). + (defun tempel-setup-capf () + (add-hook 'completion-at-point-functions #'tempel-expand -1 'local)) + ;; Put tempel-expand on the list whenever you start programming or + ;; writing prose. + (add-hook 'prog-mode-hook 'tempel-setup-capf) + (add-hook 'text-mode-hook 'tempel-setup-capf)) blob - /dev/null blob + aab8a98fa56a047df501cec68d0b93de55434476 (mode 644) --- /dev/null +++ templates @@ -0,0 +1,58 @@ +;; -*- mode: emacs-lisp -*- + +;; This file is for templates for use with Tempel +;; (https://github.com/minad/tempel). You can move this file around as +;; you like; you just need to customize the tempel-path variable. +;; +;; Templates are defined on a per-major-mode basis. The name of a mode +;; alone on a line starts templates for that major mode. See the +;; documentation for tempel for more details. +;; +;; Template syntax: +;; +;; "string" Inserts a string literal. +;; p Inserts an unnamed placeholder field. +;; n Inserts a newline. +;; > Indents with indent-according-to-mode. +;; r Inserts the current region. If no region is active, quits the containing template when jumped to. +;; r> Acts like r, but indent region. +;; n> Inserts a newline and indents. +;; & Insert newline unless there is only whitespace between line start and point. +;; % Insert newline unless there is only whitespace between point and line end. +;; o Like % but leaves the point before newline. +;; (s NAME) Inserts a named field. +;; (p PROMPT ) Insert an optionally named field with a prompt. The PROMPT is displayed directly in the buffer as default value. If NOINSERT is non-nil, no field is inserted. Then the minibuffer is used for prompting and the value is bound to NAME. +;; (r PROMPT ) Insert region or act like (p ...). +;; (r> PROMPT ) Act like (r ...), but indent region. +;; +;; (p FORM ) Like p described above, but FORM is evaluated. +;; (FORM ...) Other Lisp forms are evaluated. Named fields are lexically bound. +;; q Quits the containing template when jumped to. + + +text-mode + +(-- "–") +(--- "—") +(shrug "¯\\_(ツ)_/¯") + +(box "┌─" (make-string (length str) ?─) "─┐" n + "│ " (s str) " │" n + "└─" (make-string (length str) ?─) "─┘" n) +(abox "+-" (make-string (length str) ?-) "-+" n + "| " (s str) " |" n + "+-" (make-string (length str) ?-) "-+" n) +(rot13 (p "plain text" text) n "----" n (rot13 text)) +(calc (p "taylor(sin(x),x=0,3)" formula) n "----" n (format "%s" (calc-eval formula))) + + +prog-mode + +(fixme (if (or (derived-mode-p 'racket-mode) (derived-mode-p 'emacs-lisp-mode)) ";; " comment-start) "FIXME: ") +(todo (if (or (derived-mode-p 'racket-mode) (derived-mode-p 'emacs-lisp-mode)) ";; " comment-start) "TODO: ") +(bug (if (or (derived-mode-p 'racket-mode) (derived-mode-p 'emacs-lisp-mode)) ";; " comment-start) "BUG: ") +(hack (if (or (derived-mode-p 'racket-mode) (derived-mode-p 'emacs-lisp-mode)) ";; " comment-start) "HACK: ") +(working (if (or (derived-mode-p 'racket-mode) (derived-mode-p 'emacs-lisp-mode)) ";; " comment-start) "WORKING HERE: ") + + +;; See the README of Tempel for more template ideas