summary refs log tree commit diff stats
path: root/tag-emacs/emacs.d/init.org
diff options
context:
space:
mode:
authorAlan Pearce2016-01-20 21:01:25 +0100
committerAlan Pearce2016-01-20 21:01:25 +0100
commit8e55a6102e2ed60d40555ef7d130081b5b415a2e (patch)
tree1bb976b831e817eae9c0bc3571e568aed5be51f8 /tag-emacs/emacs.d/init.org
parent3ec45150a940f762f60583c95c52a37dc1286cf7 (diff)
downloadnixfiles-8e55a6102e2ed60d40555ef7d130081b5b415a2e.tar.lz
nixfiles-8e55a6102e2ed60d40555ef7d130081b5b415a2e.tar.zst
nixfiles-8e55a6102e2ed60d40555ef7d130081b5b415a2e.zip
Emacs: Use file-notify for org-mobile
Diffstat (limited to 'tag-emacs/emacs.d/init.org')
-rw-r--r--tag-emacs/emacs.d/init.org22
1 files changed, 9 insertions, 13 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index 21e30d07..2fce27a1 100644
--- a/tag-emacs/emacs.d/init.org
+++ b/tag-emacs/emacs.d/init.org
@@ -1665,19 +1665,15 @@ I can use this to keep a journal.  I should use it.
               (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)))))
+              (defvar org-mobile-watcher nil)
+              (let ((org-file (expand-file-name
+                               (concat
+                                (file-name-as-directory org-mobile-directory)
+                                org-mobile-capture-file))))
+                (defun ap/org-mobile-pull ()
+                  (org-mobile-pull))
+                (setq org-mobile-watcher
+                      (file-notify-add-watch org-file '(change) #'ap/org-mobile-pull)))))))
 #+END_SRC
 
 * Programming