如何在emacs中自动执行组织移动推送组织移动 [英] How to automatically do org-mobile-push org-mobile pull in emacs
问题描述
由于我正在使用组织模式跟踪我的emacs中的待办事项列表,所以我喜欢iPhone应用程序:MobileOrg,可以一天访问我的待办事项列表。
Since I am using org-mode to track my todo list in emacs, I like the iPhone app: MobileOrg, with it, I can access my todo list all day.
但是这里的问题是:
我必须手动组织移动 - 通过收件箱将本机文件的更改推送到手机,而组织移动通过电话返回的更改。
I have to manually org-mobile-push my changes from local file to mobile phone through dropbox, and org-mobile-pull the changes made by phone back.
如何自动进行设置?喜欢在dotemacs文件中添加一些食谱。
How to make that automatically? Like adding some recipes in dotemacs file.
推荐答案
将这两行添加到点emacs文件中:
Add these two lines to dot emacs file:
(add-hook 'after-init-hook 'org-mobile-pull)
(add-hook 'kill-emacs-hook 'org-mobile-push)
与他们一起,它会自动提取emacs启动时的更改,并在emacs退出之前推送更改。
With them, it automatically pulls the changes on emacs startup, and pushes the changes before emacs exits.
- 更新
如果您从不退出Emacs,此解决方案可能无法适用于您。所以,使用空闲计时器的另一个解决方案
If you never exit your Emacs, this solution might not work for you. So, another solution using idle timer
;; moble sync
(defvar org-mobile-sync-timer nil)
(defvar org-mobile-sync-idle-secs (* 60 10))
(defun org-mobile-sync ()
(interactive)
(org-mobile-pull)
(org-mobile-push))
(defun org-mobile-sync-enable ()
"enable mobile org idle sync"
(interactive)
(setq org-mobile-sync-timer
(run-with-idle-timer org-mobile-sync-idle-secs t
'org-mobile-sync)));
(defun org-mobile-sync-disable ()
"disable mobile org idle sync"
(interactive)
(cancel-timer org-mobile-sync-timer))
(org-mobile-sync-enable)
我刚刚发现它与以下答案,所以,如果你喜欢空闲计时器解决方案,请提请 tkf的答案。
I just found out it is same as below answer, so, if you prefer the idle timer solution, please upvote tkf's answer.
这篇关于如何在emacs中自动执行组织移动推送组织移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!