emacs-noob · 2022-11-06 14:45
xenodium · 2022-11-06 15:42
Yasnippet can be magical. Would love to see your usages in action. Here’s one I really enjoy using https://xenodium.com/smarter-snippets
emacs-noob · 2022-11-06 16:35
Very nice snippet! I don't have too many advanced usages, most of them just look like:
# -*- mode: snippet -*-
# name: insert new interactive command function definition
# key: interactive
# --
(defun matt/$1 ()
(interactive)
($0))
But I do have one neat one which powers the [library](https://mjdiloreto.github.io/books_i_like/) on my personal blog, which creates a custom org-mode block that exports to the HTML for each book:
# key: book
# name: book entry
# --
+begin_src book :title $1 :author ${2:$(apply #'concat (mapcar (lambda (w) (substring w 0 1)) (split-string yas-text)))} :cover-url
,* ${1:title}
,** ${2:author}
$0
+end_src
Whatever I type after $0 becomes the book's review when you click on it ;)
xenodium · 2022-11-06 20:16
Nice one. Thanks for sharing!
papercatlol · 2022-11-07 18:25
Neat idea! Btw you can modify the `yas-new-snippet-default` variable to change what yasnippet inserts into a new snippet buffer. This itself is a snippet though, so don't forget to escape $ and `.