Search code examples
emacselisp

How to remove a function from run-with-idle-timer?


I have added a lambda() function to run-with-idle-timer like this:

(run-with-idle-timer my-configurable-idle-time t
                 (lambda ()
                    ;;; do something
                  ) )

Is it possible to remove this function at a later point again from the idle timer trigger?


Solution

  • Yes, run-with-idle-timer returns a timer object which you can pass to cancel-timer.

    If you did not keep the timer object around, you can modify timer-idle-list by hand.

    See also Getting a list of running Emacs timers.