I really like the new eldoc that is turned on in 13.04, and it would be
cool to make it work on S4 methods. Right now, it accesses only the
generic, which is often insufficient, because S4 methods will add arguments
as allowed by the presence of "..." in the generic formals.

Having no idea of how this works inside ESS, I thought that if you could
somehow get the text of the call, you could use selectMethod() to find the
actual method. I threw together the function below just for fun. It takes a
string representation of an R call, parses it, evaluates the arguments,
matches them to elements of the generic signature, and resolves the method.
It even handles the ".local" delegation that happens when methods add
formal arguments as mentioned. The evaluation of the arguments might be
expensive, so this should be on-demand only.

parseToSelectMethod <- function(expr) {
    call <- parse(text = expr)[[1]]
    generic <- match.fun(call[[1]])
    matched.call <- match.call(generic, call)
    args <- lapply(as.list(matched.call[-1]), eval, parent.frame())
    classes <- vapply(args, class, character(1))
    classes.sig <- classes[generic@signature]
    method <- selectMethod(generic, classes.sig)
    method.body <- body(method)[[2]]
    has.local <- identical(quote(`<-`(.local)), method.body[1:2])
    if (has.local) {
        method <- method.body[[3]]
    }
    method
}

Hope that helps some,
Michael

	[[alternative HTML version deleted]]

