Function: funcall-with-delayed-message

funcall-with-delayed-message is a function defined in eval.c.

Signature

(funcall-with-delayed-message TIMEOUT MESSAGE FUNCTION)

Documentation

Like funcall, but display MESSAGE if FUNCTION takes longer than TIMEOUT.

TIMEOUT is a number of seconds, and can be an integer or a floating point number.

If FUNCTION takes less time to execute than TIMEOUT seconds, MESSAGE is not displayed.

Probably introduced at or before Emacs version 29.1.

Source Code

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

  CHECK_NUMBER (timeout);
  CHECK_STRING (message);

  /* Set up the atimer.  */
  struct timespec interval = dtotimespec (XFLOATINT (timeout));
  struct atimer *timer = start_atimer (ATIMER_RELATIVE, interval,
				       with_delayed_message_display,
				       xstrdup (SSDATA (message)));
  record_unwind_protect_ptr (with_delayed_message_cancel, timer);

  Lisp_Object result = calln (function);

  return unbind_to (count, result);
}