Bozhidar Batsov continues his excellent series on the upcoming Emacs 24.4 release with a post about new hooks for when frames go in or out of focus. As Batsov explains, that allows you to easily save the current file or even all files when a frame goes out of focus.
As with some of the other enhancements in 24.4, you probably won’t be using this facility every day but it does, as Batsov says, move Emacs towards the goal of making everything possible from the user level.