         (error "You must specify an `el-patch-feature' directive for `%S'"
                function-name))
       (eval
-       (el-patch--autoload-function function-name el-patch--feature)))
+       (el-patch--autoload-function (car definition)
+                                    function-name
+                                    el-patch--feature)))
     (advice-add function-name :override advice-name)))
 
 ;;;###autoload

  `(defun ,(el-patch--advice-name (cadr definition))
       ,@(cddr definition)))

(defun el-patch--autoload-function (function-name feature)
  "Generate the code for an autoload stub.
This will return a list starting with `defun'. The function is
called FUNCTION-NAME. When the function is called, it will load
FEATURE (which is expected to redefine FUNCTION-NAME) and then
call itself. If FEATURE did not redefine FUNCTION-NAME, an error
is signaled."
  (let ((recursive-autoload
         (intern (format "el-patch--recursive-autoload--%S"
                         function-name))))
    `(defun ,function-name (&rest args)
       ,(format "This function is a stub generated by el-patch. The patch for
`%S' has been loaded (see the `:override'
advice on this function), but the original definition of

           (error "Autoload of `%S' failed to define `%S'"
                  feature function-name)
         (require ',feature)
         (apply ,(if (equal defun 'defmacro)
                     ;; Sneaky way to call a macro as a function.
                     `(cdr (symbol-function ',function-name))
                   ;; Alternatively: (list 'quote function-name)
                   `',function-name)
                args)))))

(defun el-patch--definition (patch-definition)
  "Activate a PATCH-DEFINITION.
