Function: fset

fset is a function defined in data.c.

Signature

(fset SYMBOL DEFINITION)

Documentation

Set SYMBOL's function definition to DEFINITION, and return DEFINITION.

Probably introduced at or before Emacs version 24.4.

Source Code

// Defined in /usr/src/emacs/src/data.c
{
  register Lisp_Object function;
  CHECK_SYMBOL (symbol);
  /* Perhaps not quite the right error signal, but seems good enough.  */
  if (NILP (symbol) && !NILP (definition))
    /* There are so many other ways to shoot oneself in the foot, I don't
       think this one little sanity check is worth its cost, but anyway.  */
    xsignal1 (Qsetting_constant, symbol);

  function = XSYMBOL (symbol)->u.s.function;

  if (!NILP (Vautoload_queue) && !NILP (function))
    Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);

  if (AUTOLOADP (function))
    Fput (symbol, Qautoload, XCDR (function));

  eassert (valid_lisp_object_p (definition));

#ifdef HAVE_NATIVE_COMP
  if (comp_enable_subr_trampolines
      && SUBRP (function)
      && !SUBR_NATIVE_COMPILEDP (function))
    CALLN (Ffuncall, Qcomp_subr_trampoline_install, symbol);
#endif

  set_symbol_function (symbol, definition);

  return definition;
}