I welcome your idea! In fact I've been thinking for quite some time we needed something like this. I don't like the names of the hooks, however, since they don't seem particularly standard - usually the terminology used with focus is "focus gained" and "focus lost" (or "on focus" and "on lose focus"). On 17 November 2013 19:50, Brian Jenkins wrote: > Hello. > > I'd like to contribute the attached patch, which adds hooks into gain and > loss of focus events. > > This allows saving all buffers on loss of focus. (Alt-tabbing between > an editor and browser is a popular workflow for web programmers.) > > It also allows reversion of buffers on regain of focus, convenient if > one is switching between Emacs and another editor. > > People will probably find other handy uses for these hooks. > > Best, > Brian Jenkins >