Macro wrapper?

So, this is a question about macros, and it’s one that might have a solution via addons, or something clever in the macro system itself I hadn’t thought of. :slight_smile:

I’ve used macros for leveling and questing for many years, and have some old habits I have might be silly, but one of the things I’ve gotten used to doing is wrapping pretty much every attack that is targeted (IE: not ground-targeted areas or self-centered AoE) in something like this:

/targetenemy [noexists][dead]
/cast [harm][@targettarget,harm][] Spell-or-ability

This does what I want it to do. It targets a new enemy if the one I’m on is dead, it makes sure I’m actually swinging my staff if I’m a caster, and it fires off the ability at the bad guy. If I target a friendly, it shoots at their target.

The problem is, I have to make hundreds of these, and they’re all pretty much identical, because of how many abilities there are across classes and specs.

So, I was wondering if anyone has found an addon to do this behavior, or perhaps a way to make a “global” wrapper for a bar addon, so every slot just adds this to whatever ability is on the button?

PS: If there’s a better place for these kinds of questions/discussions, feel free to move it there!

I think this is an OK place to ask your question, but I’m not aware of an addon that does what you’re after.