All this is well covered by Law 39:
(a) The striker is out Stumped [...] if,
(i) a ball which is not a No ball is delivered,
and (ii) he is out of his ground [...]
and (iii) he has not attempted a run,
when (iv) his wicket is fairly put down by the wicket-keeper without the intervention of another fielder. [...]
(b) The striker is out Stumped if all the conditions of (a) above are satisfied, even though a decision of Run out would be justified.
Therefore to answer your specific questions:
Is it a run out or is a stumping if he edges it just short of the keeper/keeper drops the catch?
Stumped (assuming no other fielder has touched the ball). Part (b) above makes it clear that stumped takes precedence over run out.
is it still a stumping if the batsman hits it to long on, the wicketkeeper runs to long on, picks it up and throws a direct hit at the batsman's crease?
On the assumption that the batsmen were attempting a run while the wicketkeeper was running all over the ground, run out due to (a)(iii). In the extremely unlikely case that the striker just stood around outside his ground while the wicketkeeper went all the way to long on and all the other fielders ignored the ball, it could conceivably be stumped.