Improve comma placement in generated snippets

Required parameters place the comma outside the snippet field, so that
typing does not overwrite them.

Optional parameters still place the comma inside the snippet field, so
that C-d wipes out all traces of the optional parameter.

The last parameter does not have a trailing comma, since it is always a
syntax error to include it.