The answer is no, there is no way to know which function was just called, or which function called a function that is currently being evaluated.
Consider, for example, what happens when byte-compiled code is executed: functions you see in the source code are typically absent from the byte-compiled code.
The comment about this-command
and last-command
is valid, but it applies only to commands, not functions in general. Be aware too that some functions change the value of this-command
or last-command
, so these do not necessarily always indicate what their names suggest.