Stephen Bond writes the definitive word on ad hominem in "the ad hominem fallacy fallacy":
In reality, ad hominem is unrelated to sarcasm or personal abuse. Argumentum ad hominem is the logical fallacy of attempting to undermine a speaker's argument by attacking the speaker instead of addressing the argument. The mere presence of a personal attack does not indicate ad hominem: the attack must be used for the purpose of undermining the argument, or otherwise the logical fallacy isn't there.
A: "All rodents are mammals, but a weasel isn't a rodent, so it can't be a mammal."
B: "You evidently know nothing about logic. This does not logically follow."
B's argument is still not ad hominem. B does not imply that A's sentence does not logically follow because A knows nothing about logic. B is still addressing the substance of A's argument...
This is too beautiful, thorough, and precise to not post. HT to sfk on HN.