Subject: Re: Function called from the Listener or from another function
From: Erik Naggum <clerik@naggum.no>
Date: 1997/12/12
Newsgroups: comp.lang.lisp
Message-ID: <3090936459477164@naggum.no>


* Hrvoje Niksic
| Judging on experience from Emacs, there *is* use in distinguishing
| whether a function has been called interactively or noninteractively,
| but checking whether it has been evaluated from the listener
| definitely sounds like the wrong thing to do.

Emacs exports its Lisp call stack.  `interactivep' actually walks up the
call stack and looks for a call frame with `call-interactively' in it,
skipping only a few known call frames on the way.  if it finds it, the
function is deemed "interactive".

if your Lisp has a debugger that can print backtraces, it has a way to
locate call frames.  if you can also use it, you can do the same job as
Emacs' `interactive-p': look for a particular function you expect to mean
"interactive" in the backtrace.

there are many other ways to distinguish between an interactive call and a
normal call, but they generally require changes in the caller.  this is
most easily solved by writing one's own top-level loop, which is not all
that hard.

in any case, I miss the ability in Common Lisp to obtain the function
object corresponding to the running function.  in Emacs, this is (almost)
achievable through (backtrace-frame 0).

#\Erik
-- 
If you think this year is number 97,  |  Help fight MULE in GNU Emacs 20!
_you_ are not "Year 2000 Compliant".  |  http://sourcery.naggum.no/emacs/