box-style comments with yasnippet

Changing your snippet to this one fixes the last line.

Copyright (c) ${1:`(nth 5 (decode-time))`}
All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted
`(let ((comment-style 'box))(comment-region (point-min) (point-at-eol 0)))`

Note that there is a line break between the license ("... are permitted") and embedded emacs lisp code.

As for the second line, I'll first explain why this occurs and then offer an (ugly) fix. When your snippet is inserted into a file, embedded blocks of lisp are sequentially evaluated from the beginning of buffer to the end. What this means in your snippet is that (nth 5 (decode-time)) has been replaced by 2011 when the next block, (comment-region ...), is evaluated.

As a result, comment-region sees the second line as

Copyright (c) ${1:2011}

So, comment-region puts enough white spaces for this string. Then, the template engine transforms ${1:2011} into 2011, and this transformation shortens the string by 5 characters. This explains the premature appearance of *) by 5 characters in the second line.

One way to fix this situation is putting 5 white spaces back after comment-region is evaluated --- Something along the line of:

Copyright (c) ${1:`(nth 5 (decode-time))`} @
All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted.
`(let ((comment-style 'box))(comment-region (point-min) (point-at-eol 0)))``
(replace-string "@" "      " nil (point-min) (point))`$0