replace flet with let+lambda+funcall

flet is marked obsolete in 24.3 resulting in quite a lot of annoying
messages. The intended replacement is cl-flet, but that is unavailable
in earlier emacsen, so we can't use that either.

closes #1620.