diff options
author | Alan Pearce | 2015-08-16 13:30:57 +0200 |
---|---|---|
committer | Alan Pearce | 2015-08-16 13:30:57 +0200 |
commit | be6667e171f077384482c4806d851a75bb625085 (patch) | |
tree | dcbecdfa4a2c5abaeae3d49160901118fd4d99a4 /tag-emacs | |
parent | d3981bdfb3ccd4603a1ea7f5d130a3b2e24ec714 (diff) | |
download | dotfiles-be6667e171f077384482c4806d851a75bb625085.tar.lz dotfiles-be6667e171f077384482c4806d851a75bb625085.tar.zst dotfiles-be6667e171f077384482c4806d851a75bb625085.zip |
Emacs: Add org-mobile timer setup
Diffstat (limited to 'tag-emacs')
-rw-r--r-- | tag-emacs/emacs.d/init.org | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index 32fa196..b426428 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -1505,7 +1505,47 @@ Org is wünderbar. (org-back-to-heading t) (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) (if (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) - (org-todo "STARTED"))))))) + (org-todo "STARTED"))))) + + (defvar org-mobile-push-timer nil + "Timer that `org-mobile-push-timer' used to reschedule itself, or nil.") + + (defun org-mobile-push-with-delay (secs) + (when org-mobile-push-timer + (cancel-timer org-mobile-push-timer)) + (setq org-mobile-push-timer + (run-with-idle-timer + (* 1 secs) nil 'org-mobile-push))) + + (add-hook 'after-save-hook + (lambda () + (when (eq major-mode 'org-mode) + (dolist (file (org-mobile-files-alist)) + (if (string= (file-truename (expand-file-name (car file))) + (file-truename (buffer-file-name))) + (org-mobile-push-with-delay 30))) + ))) + + (run-at-time "00:05" 86400 '(lambda () (org-mobile-push-with-delay 1))) ;; refreshes agenda file each day + (org-mobile-pull) ;; run org-mobile-pull at startup + + (defun install-monitor (file secs) + (run-with-timer + 0 secs + (lambda (f p) + (unless (< p (second (time-since (elt (file-attributes f) 5)))) + (org-mobile-pull))) + file secs)) + + (install-monitor (file-truename + (concat + (file-name-as-directory org-mobile-directory) + org-mobile-capture-file)) + 5) + + ;; Do a pull every 5 minutes to circumvent problems with timestamping + ;; (ie. dropbox bugs) + (run-with-timer 0 (* 5 60) 'org-mobile-pull))) #+END_SRC **** org-babel |