If you want to create a music-function for a customized TextSpanner, you may want to integrate \startTextSpan and \stopTextSpan in this function.
The advantage would be to use it like: \customizedTextSpanner { ... }
The following code tries to show a template for it.
A version to use with 2.16.0 is commented.