diff --git a/ha-config.org b/ha-config.org index d62d3c2..bba64de 100644 --- a/ha-config.org +++ b/ha-config.org @@ -131,20 +131,20 @@ Seems the best [[https://github.com/hlissner/doom-snippets][collection of snippe ** Auto Insert Templates The [[https://www.emacswiki.org/emacs/AutoInsertMode][auto-insert]] feature is a wee bit complicated. All I want is to associate a filename regular expression with a YASnippet template. I'm stealing some ideas from Henrik Lissner's [[https://github.com/hlissner/doom-emacs/blob/develop/modules/editor/file-templates/autoload.el][set-file-template!]] macro, but simpler? #+begin_src emacs-lisp -(use-package autoinsert - :init - (setq auto-insert-directory (expand-file-name "templates" user-emacs-directory)) - ;; Don't prompt before insertion: - (setq auto-insert-query nil) + (use-package autoinsert + :init + (setq auto-insert-directory (expand-file-name "templates" user-emacs-directory)) + ;; Don't prompt before insertion: + (setq auto-insert-query nil) - (add-hook 'find-file-hook 'auto-insert) - (auto-insert-mode t)) + (add-hook 'find-file-hook 'auto-insert) + (auto-insert-mode t)) #+end_src Since auto insertion requires entering data for particular fields, and for that Yasnippet is better, so in this case, we combine them: #+begin_src emacs-lisp -(defun ha-autoinsert-yas-expand() - "Replace text in yasnippet template." - (yas-expand-snippet (buffer-string) (point-min) (point-max))) + (defun ha-autoinsert-yas-expand() + "Replace text in yasnippet template." + (yas-expand-snippet (buffer-string) (point-min) (point-max))) #+end_src And since I'll be associating snippets with new files all over my configuration, let's make a helper function: