Function: cl-generic-call-method

cl-generic-call-method is a byte-compiled function defined in cl-generic.el.gz.

Signature

(cl-generic-call-method GENERIC METHOD &optional FUN)

Documentation

Return a function that calls METHOD.

FUN is the function that should be called when METHOD calls call-next-method.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-generic.el.gz
(defun cl-generic-call-method (generic method &optional fun)
  "Return a function that calls METHOD.
FUN is the function that should be called when METHOD calls
`call-next-method'."
  (let ((met-fun (cl--generic-method-function method)))
    (pcase (cl--generic-method-call-con method)
      ('nil met-fun)
      ('curried
       (funcall met-fun (or fun
                            (oclosure-lambda (cl--generic-nnm) (&rest args)
                              (apply #'cl-no-next-method generic method
                                     args)))))
      ;; FIXME: backward compatibility with old convention for `.elc' files
      ;; compiled before the `curried' convention.
      (_
       (lambda (&rest args)
         (apply met-fun
                (if fun
                    ;; FIXME: This sucks: passing just `next' would
                    ;; be a lot more efficient than the lambda+apply
                    ;; quasi-η, but we need this to implement the
                    ;; "if call-next-method is called with no
                    ;; arguments, then use the previous arguments".
                    (lambda (&rest cnm-args)
                      (apply fun (or cnm-args args)))
                  (oclosure-lambda (cl--generic-nnm) (&rest cnm-args)
                    (apply #'cl-no-next-method generic method
                           (or cnm-args args))))
                args))))))