Wistfully describes something that's done with longing or regret. You might smile wistfully while sitting on a train that's pulling away from the station, leaving your hometown behind.
If there's a vague sense of yearning behind an action, you can say it's done wistfully. People sigh wistfully, gaze wistfully, and wave goodbye wistfully — thinking about the past or what you are leaving behind with a little bit of sadness. In the 1600s, wistfully had a completely different meaning — from the now-obsolete word wist, or intent — done with close attention. It gained today's meaning in the early 1700s.