Skip to content

karthink/timeout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Timeout: Sometimes Emacs needs one

timeout is a small library to help you throttle or debounce elisp function calls. See this write-up for an introduction and potential uses.

It’s actually tiny, just a couple of functions.

To use this library:

You can throttle an elisp function func to run at most once every 2 seconds:

(timeout-throttle! 'func 2.0)

To reset func:

(timeout-throttle! 'func 0.0)

When the call is a noop, a throttled function will return the same result as the last successful run.

You can debounce an elisp function func to run after an uninterrupted delay of 0.5 seconds:

(timeout-debounce! 'func 0.5)

To reset func:

(timeout-debounce! 'func 0.0)

By default a debounced function returns nil at call time. To change this, run:

(timeout-debounce! 'func 0.5 'some-return-value)

About

Throttle or debounce elisp code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published