To do something on the spur of the moment, or to act spontaneously, comes from the idea of using a sharp device to urge on a horse. This is part of a complete episode.