What I mean by a "transparent 'pass-through' function wrapper" is a function, let's call it wrapper
, that returns the result from passing all its argument to some other function, let's call it wrappee
.
How is this done in Emacs Lisp?
NB: The ideal wrapper
function is agnostic about the wrappee
function's signature; i.e. it knows nothing of the number, positions, names, etc. of wrappee
's arguments; it just passes all its arguments along to wrappee
, just as if wrappee
had been the one originally called. (There's no need, however, to mess with the call stack to replace the call to wrapper
with a call to wrappee
.)
I posted a partial answer to my question:
(defun wrapper (&rest args) (apply 'wrappee args))
This works only when wrappee
is not interactive. Apparently, the way interactive functions get their arguments represents a different "channel" from what's covered by the (&rest args)
incantation. What I still need, therefore, is an equally-wrappee
-agnostic counterpart of the (&rest args)
signature for the case where wrappee
is an interactive function.
(This question was motivated by a problem described in this earlier question.)
In case further clarification of what I'm asking for is needed, below are a couple of examples, showing the Python and JavaScript equivalents of what I'm after.
In Python a couple of standard ways to implement such a wrapper are shown below:
def wrapper(*args, **kwargs):
return wrappee(*args, **kwargs)
# or
wrapper = lambda *args, **kwargs: wrappee(*args, **kwargs)
(Here *args
stands for "all the positional arguments", and **kwargs
stands for "all the keyword arguments".)
The JavaScript equivalent would be something like this:
function wrapper () { return wrappee.apply(this, arguments); }
// or
wrapper = function () { return wrappee.apply(this, arguments); }
For the record, I disagree that this question is a duplicate of How to apply mapcar to a function with multiple arguments. I am at a loss to explain why, since the two questions look so obviously different to me. It is like being asked "explain why an apple should not be considered equivalent to an orange". The mere question is so crazy, that one doubts one could ever come up with an answer that would satisfy the person asking it.
advice
stuff problematic enough that I'd rather stay clear of it. In fact, the motivation for this question was trying to find a solution to an otherwise intractable problem I have with an adviced function...interactive
spec.