The distance to the alternate really doesn’t matter much, because you always load enough additional fuel to divert to your alternate and land, plus more fuel called the “final reserve” which is enough to fly for another 30 or 45 minutes (depending on the airline and region). That amount of fuel is called the “minimum fuel”. If you get down to your minimum fuel and you aren’t actually landing at your destination yet, then you radio the controllers and tell them that you’re at minimum fuel and are diverting to your alternate. It is only time to declare an emergency if you get down to your final reserve, by which time you should already be at your alternate airport.
Also, you can’t really use the straight–line distance between airports to figure out how much extra fuel to bring, because you never end up flying that line. For one thing, you have to approach the airport from the correct direction so that you line up with a runway and so that you’re headed into the wind. For another, you have to get down from the altitude you were holding at to ground level. Between the two you need to go not towards the airport, but towards a spot far enough away from the airport that you can fly a gentle slope down towards the runway. You might even end up flying completely around the airport while descending before actually turning in and lining up with the approach runway.