You're overthinking this massively. Replace the cables/housing once a year like you'd change the oil in your car...it's preventative maintenance. If you're that worried about it carry a spare cable with you and maybe some needle nose pliers. If you think you can get home in one gear put the cable in the derailleur backwards so the head is in the barrel adjuster. Push the derailleur into a gear you can ride and tighten the anchor bolt.
As happens all the time this should've been posted in 'bicycle mechanics' not GD but I wouldn't have seen it as I'm still banned from that section.