doomemacs/snippets

What is `(%$)` supposed to evaluate to?

rjww opened this issue · 3 comments

rjww commented

Sorry, this is more of a question than an issue, but I noticed your snippets end with `(%$)`. I've pulled bits and pieces from your config, and when I expand one of these snippets, Emacs throws up an elisp error.

Thanks for responding to all of my issues and questions by the way, much appreciated.

I have a few convenience functions for snippets defined in fundamental-mode/.yas-setup.el (link) (I need to update (%$)'s doc comments, it's incorrect). They are available to all my snippets from there.

(defun %$ ()
  (unless (eolp)
    "\n"))

Basically, it places a newline if the snippet is being expanded anywhere but at the end of a line.

For example, emacs-lisp-mode/defun is defined as such:

# name: defun
# --
(defun ${1:name} ($2)
  `%`$0)`(%$)`

It will add a newline at the end if you're expanding the snippet on a non-empty line (i.e. before the end of the line).

rjww commented

Ah, cool! Thanks for clearing that up. It's a tricky string to search for.

No problem!