I have improved my macro a bit to prevent accidental spam even better. Sometimes I spam my hex button for no reason, so I have added a 3 second spam protection window.
This is the macro:
#showtooltip
/cast Hex
/tm 0
/tm 6
/run if UnitIsEnemy("player", "target") and GetTime()>(spamwait or 0) then spamwait=GetTime()+3 SendChatMessage("%t marked with {square} is being hexed", "SAY") end
What it does
Cast Hex
Removes raid/dungeon markers if the target has any
Adds square raid/dungeon marker to the target
If the target is an enemy then send a message to the party chat, announcing that the target is being hexed and marked with a square. This has a 3 second spam protection window, meaning that the message can only be broadcasted to party chat once every 3 seconds.