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.
Hm, I'm surprised nobody has mentioned the evidentiary reasoning version of ad hominem, something like "you seem to have a bad character, so I'm going to assign low weight to anything you say". I use this rule all the time. Ie, I'll give more weight to statements made in a reputable scientific journal than those on a Nazi website. This is not a valid argument againt anything on the Nazi website, just a rule that says not to pay too much attention to stuff found there, or at least seek independent verification from a more reputable source. There ought to be a fancy rhetorical term for this...there is for the opposite. Authority of sources is an important and under-described part of practical reason, and attacking the authority of a source is a pretty common form of argument that is quasi-ad-hominem but valid.