Running a function (e.g. comment-region) on inserted region in :post
#131
-
hi! I'm trying to implement templates that universally (wrt mode) emits a copyright comment. My goal is something akin to the following: (copyright
(p "Brief file description") n
"Copyright (C) " copyright-current-year
" " user-full-name " <" user-mail-address ">" n
; etc
:post (comment-region (mark t) (point))) ... but, I don't see how to get the inserted region in the context of TIA, have a lovely day. PS: I've considered the alternative of comment-{start,continue,end}, but the logic for commenting regions is not quite as simple as just inserting those values in the right spot in a comment, so I wanted to reuse the newcomment.el logic |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hello! The mark needs to be set explicitly. This is usually done interactively by the user during the normal navigation of text, but can also be done while the template is being "auto-typed" by evaluating s-exps at strategic points. For instance: (cpr (push-mark) "Copyright (C) " copyright-current-year " "
user-full-name " <" user-mail-address ">" n
:post (comment-region (mark) (point))) This should work well as a standalone template, but I did find that it causes problems when included in a larger template using the I've not been able to understand why that happens yet. |
Beta Was this translation helpful? Give feedback.
hello!
The mark needs to be set explicitly. This is usually done interactively by the user during the normal navigation of text, but can also be done while the template is being "auto-typed" by evaluating s-exps at strategic points. For instance:
This should work well as a standalone template, but I did find that it causes problems when included in a larger template using the
tempel-include
element as defined in the README. Trying to use this form in that way causes the encapsulating template to fail before evaluatingcomment-region
wit…