From 4314d1370aa89aea9a942a336ced43b49a3c9115 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 13 May 2025 10:23:41 +0100 Subject: [PATCH 1/3] Yasnippet configuration --- emacs.org | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/emacs.org b/emacs.org index 79f410c..018018a 100644 --- a/emacs.org +++ b/emacs.org @@ -591,6 +591,27 @@ Apparently all the cool kids have moved from auto-complete to Company these days. Should probably look into LSP at the same time. Maybe I'll go without for a bit first... +** Yasnippet + +This is a really nice customisable completion system. For now I am +avoiding external packages full of completions. Let's keep it lean and +personalised. + +#+begin_src elisp + (use-package yasnippet + :config (yas-global-mode 1)) +#+end_src + +*** Snippets +#+begin_src conf :tangle "emacs/.emacs.d/snippets/python-mode/import_numpy" :mkdirp yes +# -*- mode: snippet -*- +# name: import numpy +# key: Date: Tue, 13 May 2025 11:24:39 +0100 Subject: [PATCH 2/3] Add test for yasnippet --- emacs.org | 6 +++++- tests/elisp/test-yasnippet.el | 12 ++++++++++++ tests/emacs_tests.bats | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/elisp/test-yasnippet.el diff --git a/emacs.org b/emacs.org index 018018a..1ea93a2 100644 --- a/emacs.org +++ b/emacs.org @@ -599,7 +599,11 @@ personalised. #+begin_src elisp (use-package yasnippet - :config (yas-global-mode 1)) + :hook ((python-mode . yas-minor-mode)) + :config + (yas-recompile-all) + (yas-reload-all) + ) #+end_src *** Snippets diff --git a/tests/elisp/test-yasnippet.el b/tests/elisp/test-yasnippet.el new file mode 100644 index 0000000..5a28861 --- /dev/null +++ b/tests/elisp/test-yasnippet.el @@ -0,0 +1,12 @@ +(progn + (find-file "test.py") + (insert " Date: Tue, 13 May 2025 15:32:11 +0100 Subject: [PATCH 3/3] Avoid elisp test dependence on bats run directory Also changing the temporary filename so that find-file doesn't get directed to the wrong file by a "helpful" fuzzy completion framework. --- tests/elisp/test-yasnippet.el | 3 ++- tests/emacs_tests.bats | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) mode change 100644 => 100755 tests/emacs_tests.bats diff --git a/tests/elisp/test-yasnippet.el b/tests/elisp/test-yasnippet.el index 5a28861..4660507 100644 --- a/tests/elisp/test-yasnippet.el +++ b/tests/elisp/test-yasnippet.el @@ -1,5 +1,5 @@ (progn - (find-file "test.py") + (find-file "tmp.py") (insert "