Function: unwind-protect

unwind-protect is a special form defined in eval.c.

Signature

(unwind-protect BODYFORM UNWINDFORMS...)

Documentation

Do BODYFORM, protecting with UNWINDFORMS.

If BODYFORM completes normally, its value is returned after executing the UNWINDFORMS. If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.

Probably introduced at or before Emacs version 19.24.

Source Code

// Defined in /usr/src/emacs/src/eval.c
{
  Lisp_Object val;
  ptrdiff_t count = SPECPDL_INDEX ();

  record_unwind_protect (prog_ignore, XCDR (args));
  val = eval_sub (XCAR (args));
  return unbind_to (count, val);
}