Several times on board a "Star Ship" the hulls have been compromised expelling crew members into space. Why not have an emergency system whereas when a person is ejected into space a transporter automatically beams that person back on board?
Examining a prime example of this in action:
From what we see, the first line of defense should be the emergency bulkhead, but in the example above it fails to initiate in a timely manner. Given that the processes involved in determining whether or not there's a hole in the hull should be comparatively simple compared to deciding if a crewmember is in or out of the ship (and whether or not they should be in or out, since they might be in a spacesuit) and then transporting them back in, we can probably assume that either:
- The bulkheads are normally considered sufficient, so no programming exists for the transporters.
- The bulkheads are malfunctioning, in which case the transporters may be as well.
There may also be considerable risk in programming the computer to auto-transport. If someone were to hack the computer, such a system could be reversed to place people out into space instead. Considering we don't see automated beaming of intruders into the brig or injured crew to sickbay (I can't recall any cases of fully automated transporting in the shows actually), it may be safe to say that Starfleet chose to prevent the computer from running transports without direct human control/initiation for safety/security reasons.
Shields block the transporter, and in combat a ship is going to have shields full on.
In ENT, the transporters were normally only used for cargo and not for people (multiple episodes, Star Trek: Enterprise). In TOS, beaming within the ship was considered unsafe or at least risky (Star Trek 3x11 "Day of the Dove"). For both time periods, it seems unlikely that they would be able to develop a system of the sort that the question describes.
From TNG on, this is less obviously problematic. However, as early as the launch of the Enterprise-B, ships were capable of projecting emergency force fields to seal hull breaches, and were programmed to do this automatically (Star Trek: Generations). This greatly reduces the need for an emergency beam-out system. Combine this with the simple fact that, when a person is sucked out into space, they are moving and therefore hard to lock onto, and this whole design just seems rather improbable to me.
: "Correction, sir, that's blown out into space" - Data, Star Trek: The Next Generation 1x03 "The Naked Now"
: If you accept the Abramsverse as canon, Star Trek (2009) provides an example of this being difficult but not impossible with a sufficiently talented transporter operator.
Realistically the reason is to add tension and drama to the story.
In universe there are many situations where a transporter lock requires manual input. On top of that if the ship is in combat it's possible that the computer's are busy with processing other combat related tasks or that power is being routed to shields and weapons rather than transporters.
In the ENT episode "Cold Station 12", Archer is briefly in open space and transported aboard so a human could survive in open space and be transported back. Throughout the series we have seen numerous examples of reviving the dead so it is reasonable to assume that a shipmate flung into open space could be revived after a much longer time that we are currently able to at this point in reality: http://memory-alpha.wikia.com/wiki/Death
Knowing this; and with the chaos and confusion of a battle, power needs for weapons and shields, and not being able to drop shields to transport, it may have simply not been a priority to retrieve them immediately as they would most likely be recoverable and revivable after some time.