如何在 emacs 中定期运行任务? [英] How to periodically run a task within emacs?

查看:21
本文介绍了如何在 emacs 中定期运行任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在长时间运行的 emacs 中定期运行 elisp 函数,类似于 cron,但在 emacs 进程内?

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

例如,我想每半小时自动运行一次(recentf-save-list)",否则它只会在退出时运行,这在 emacs 偶尔崩溃时会很糟糕.(还有其他例子,所以寻找一个通用的解决方案,而不是一个特别适用于最近的解决方案).

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).

推荐答案

查看 run-with-timer.

(run-with-timer 0 (* 30 60) 'recentf-save-list)

这篇关于如何在 emacs 中定期运行任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆