Fork me on GitHub
#practicalli
<
2022-01-20
>
practicalli-johnny02:01:55

I found a curious bug with Yasnippets in Emacs with the test snippet, in that when creating a deftest form and naming it function-name-test, the test text match the test snippet and expands into another deftest form within the existing deftest. I've https://github.com/AndreaCrotti/yasnippet-snippets/issues/438 and suggested an alternative deftest snippet that follows a more common form deftest that avoids the issue

# -*- mode: snippet -*-
# name: deftest clojure.test function
# key: deftest
# contributor: practicalli
# --
(deftest ${1:name}-test
  (testing "${2:Context of the test assertions}"$>
    (is (= ${3:assertion-values}))$4))$>
$0

practicalli-johnny12:01:48

I've updated two blog post related to using Snippets with Emacs, including many examples of writing custom snippets • https://practical.li/blog/posts/yasnippets-for-faster-clojure-development/https://practical.li/blog/posts/writing-custom-snippets-for-yasnippets/ I was writing a new article on using snippets with Clojure LSP, although I am unable to get custom snippets to load into Emacs (Spacemacs or Doom), so want to figure out what is going on before that article is published. Clojure LSP snippets are very similar to Yasnippets, except they should be accessible to any editor that supports LSP. The Clojure LSP snippets can also pull in a Clojure form, which can help with refactoring some forms (wrapping in a let for example)