By golly I think I got it! Someone on the UI/Macros forum gave me the idea of using conditionals in a stopmacro. I think this is what I'm looking for:

/petattack [target=mouseover,exists,nodead][]
/stopmacro [target=mouseover, exists]
/petfollow [target=pettarget,exists]

The only thing I'm not sure is if I choose a different target and don't have something under my mouse, I think it would set it to follow. I wonder if I can add another condition into the stopmacro if my target does not equal my pet's target...


edit: Actually, there's a good chance it'll work. I'm going to test it tonight before I over-think it.