anonymous functions as shortcut handlers

In my particular case it is sometimes convenient to provide (generated) anonymous functions as handlers. This patch makes handling them easy.