Fix setting selection/active line from automation scripts

The error handling function is under the results of the called function,
not at the top of the stack, so lua_pop was removing the wrong thing.