summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2024-01-07 19:51:46 -0500
committerKjetil Orbekk <kj@orbekk.com>2024-01-07 19:51:46 -0500
commit98b91b323d87231dd475b9a0c722f2fb0e935bc0 (patch)
tree4ddb06cb918b45b9d8c5b9e7dad20ce2d1adbebc
parent86f5f069d0c31d4afa5386c52290b6632e9f380e (diff)
include tempel templates
-rw-r--r--emacs/.config/emacs-v2/lisp/kj-development.el33
-rw-r--r--emacs/.config/emacs-v2/templates23
2 files changed, 56 insertions, 0 deletions
diff --git a/emacs/.config/emacs-v2/lisp/kj-development.el b/emacs/.config/emacs-v2/lisp/kj-development.el
index c7f1168..423ddf8 100644
--- a/emacs/.config/emacs-v2/lisp/kj-development.el
+++ b/emacs/.config/emacs-v2/lisp/kj-development.el
@@ -13,6 +13,39 @@
(add-to-list 'yas-snippet-dirs (expand-file-name "yasnippets" user-emacs-directory))
(yas-global-mode))
+(use-package tempel
+ ;; Require trigger prefix before template name when completing.
+ ;; :custom
+ ;; (tempel-trigger-prefix "<")
+
+ :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand
+ ("M-*" . tempel-insert))
+
+ :init
+
+ ;; Setup completion at point
+ (defun tempel-setup-capf ()
+ ;; Add the Tempel Capf to `completion-at-point-functions'.
+ ;; `tempel-expand' only triggers on exact matches. Alternatively use
+ ;; `tempel-complete' if you want to see all matches, but then you
+ ;; should also configure `tempel-trigger-prefix', such that Tempel
+ ;; does not trigger too often when you don't expect it. NOTE: We add
+ ;; `tempel-expand' *before* the main programming mode Capf, such
+ ;; that it will be tried first.
+ (setq-local completion-at-point-functions
+ (cons #'tempel-expand
+ completion-at-point-functions)))
+
+ (add-hook 'conf-mode-hook 'tempel-setup-capf)
+ (add-hook 'prog-mode-hook 'tempel-setup-capf)
+ (add-hook 'text-mode-hook 'tempel-setup-capf)
+
+ ;; Optionally make the Tempel templates available to Abbrev,
+ ;; either locally or globally. `expand-abbrev' is bound to C-x '.
+ ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode)
+ ;; (global-tempel-abbrev-mode)
+)
+
(use-package rustic
:after eglot
:bind (("C-c C-r C-s" . rustic-popup)
diff --git a/emacs/.config/emacs-v2/templates b/emacs/.config/emacs-v2/templates
new file mode 100644
index 0000000..5d8a773
--- /dev/null
+++ b/emacs/.config/emacs-v2/templates
@@ -0,0 +1,23 @@
+;; ~/.config/emacs/templates -*- mode: lisp-data; -*-
+
+fundamental-mode
+
+(today (format-time-string "%Y-%m-%d"))
+
+text-mode
+
+(cut "--8<---------------cut here---------------start------------->8---" n r n
+ "--8<---------------cut here---------------end--------------->8---" n)
+
+emacs-lisp-mode
+
+(header ";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name)))
+ " -- " p " -*- lexical-binding: t -*-" n
+ ";;; Commentary:" n ";;; Code:" n n)
+(provide "(provide '" (file-name-base (or (buffer-file-name) (buffer-name))) ")" n
+ ";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name)))
+ " ends here" n)
+
+;; Local Variables:
+;; outline-regexp: "[a-z]"
+;; End: