Function: autoload-do-load

autoload-do-load is a function defined in eval.c.

Signature

(autoload-do-load FUNDEF &optional FUNNAME MACRO-ONLY)

Documentation

Load FUNDEF which should be an autoload.

If non-nil, FUNNAME should be the symbol whose function value is FUNDEF, in which case the function returns the new autoloaded function value. If equal to macro, MACRO-ONLY specifies that FUNDEF should only be loaded if it defines a macro.

View in manual

Probably introduced at or before Emacs version 24.3.

Source Code

// Defined in /usr/src/emacs/src/eval.c
{
  if (!CONSP (fundef) || !EQ (Qautoload, XCAR (fundef)))
    return fundef;

  Lisp_Object kind = Fnth (make_fixnum (4), fundef);
  if (EQ (macro_only, Qmacro)
      && !(EQ (kind, Qt) || EQ (kind, Qmacro)))
    return fundef;

  /* This is to make sure that loadup.el gives a clear picture
     of what files are preloaded and when.  */
  if (will_dump_p () && !will_bootstrap_p ())
    {
      /* Avoid landing here recursively while outputting the
	 backtrace from the error.  */
      gflags.will_dump_ = false;
      error ("Attempt to autoload %s while preparing to dump",
	     SDATA (SYMBOL_NAME (funname)));
    }

  CHECK_SYMBOL (funname);

  /* If `macro_only' is set and fundef isn't a macro, assume this autoload to
     be a "best-effort" (e.g. to try and find a compiler macro),
     so don't signal an error if autoloading fails.  */
  Lisp_Object ignore_errors
    = (EQ (kind, Qt) || EQ (kind, Qmacro)) ? Qnil : macro_only;
  load_with_autoload_queue (Fcar (Fcdr (fundef)), ignore_errors, Qt, Qnil, Qt);

  if (NILP (funname) || !NILP (ignore_errors))
    return Qnil;
  else
    {
      Lisp_Object fun = Findirect_function (funname, Qnil);

      if (!NILP (Fequal (fun, fundef)))
	error ("Autoloading file %s failed to define function %s",
	       SDATA (Fcar (Fcar (Vload_history))),
	       SDATA (SYMBOL_NAME (funname)));
      else
	return fun;
    }
}