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

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

问题描述

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



例如我想每半小时自动运行一次(最近的保存列表),因为否则它只能在退出时运行,这在emacs偶尔会崩溃时会很糟糕。 (还有其他的例子,所以寻找一个一般的解决方案,而不是一个特别是近期的解决方案)。

解决方案

a href =http://www.gnu.org/s/emacs/manual/html_node/elisp/Idle-Timers.html =noreferrer> run-with-timer

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


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

解决方案

Check out run-with-timer.

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

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

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