Hey @g see how you get on with this Applescript you asked for. Copy the contents into Script Editor and see if it works for what you want. I bet others could do a way better job, but it’s a start. There are also probably much better ways to achieve this, eg with Keyboard Maestro.

Name selected in Mars Edit compose window.
Selected name has been turned into a link.