I've got a yasnippet for creating a subsection banner comment in c style code:
# -*- mode: snippet -*-
# name: Subsection Comment Block
# key: comm-subsec
# --
/*${1:$(make-string (floor (/ (- fill-column 8 (string-width yas-text)) 2.0)) ?\=)} ${1:Comment} ${1:$(make-string (ceiling (/ (- fill-column 8 (string-width yas-text)) 2.0)) ?\=)}*/
$0
It creates a comment and automatically pads out the line to the fill-column width of the current buffer. It's a little long and tough to read so I was wondering if I could somehow define a functions in this snippet.
I was able to create a defun within backticks like so:
`(defun add-padding (x) x)`
but the function name was returned and entered in the rendered snippet, not ideal.
Should I simply define the function in my init.el file? Is that that best solution? Or is there another way to create what I'm doing?