Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hooking some Emacs events to improve org-mode/MobileOrg integration

Tags:

emacs

org-mode

I've recently started using MobileOrg (through Dropbox) to be able to manage my org-mode TODO lists while I'm away from my computer.

It's generally great, but the syncing back and forth has a few steps, so I'd like to try and simplify it a bit by automating the steps on the PC side.

Anyway, here are the two things I'd like to do:

  1. Run org-mobile-push every time a file is saved, after the save completes. The only thing I use emacs for is org-mode, so this should be fine.
  2. Run org-mobile-pull on emacs startup.
  3. Run org-mobile-pull periodically, say every hour or so.

Thanks.

like image 813
Chad Birch Avatar asked Nov 18 '10 17:11

Chad Birch


3 Answers

I don't have Emacs installed on this machine, but here's what you can do:

  1. http://www.gnu.org/s/emacs/manual/html_node/elisp/Standard-Hooks.html - look for after-save-hook
  2. Startup things go to your .emacs file - if you put the call to org-mobile-pull at the end of this file, you will have it run every time you open Emacs
  3. Check this SO answer for a periodical run of some function: How to periodically run a task within emacs?

Hope this helps.

like image 57
icyrock.com Avatar answered Nov 02 '22 23:11

icyrock.com


Here's what I use

(add-hook 
  'after-save-hook 
  (lambda () 
     (if (string= buffer-file-name "<path to my notes.org>") 
        (org-mobile-push)
     )
  ))
like image 29
Sandeep Chayapathi Avatar answered Nov 02 '22 22:11

Sandeep Chayapathi


In this reply I've posted code that automatically pulls and then pushes after MobileOrg has synced, and automatically pushes whenever a relevant org file is saved. This makes it fully automatic and you don't have to wait for an hourly period.

like image 32
senf78 Avatar answered Nov 02 '22 22:11

senf78