Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to periodically run a task within emacs?

Tags:

emacs

elisp

Is there a way to periodically run an elisp function in a long-running emacs, similar to cron, but within the emacs process?

For example I want to "automatically run (recentf-save-list) every half hour" because it otherwise only runs on exit, which sucks when emacs occasionally crashes. (There are other examples as well so looking for a general solution rather than one in particular for recentf).

like image 236
Jonathan Swartz Avatar asked Oct 01 '10 17:10

Jonathan Swartz


1 Answers

Check out run-with-timer.

(run-with-timer 0 (* 30 60) 'recentf-save-list) 
like image 117
Trey Jackson Avatar answered Oct 09 '22 09:10

Trey Jackson