Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for MobileOrg push/pull #46

Open
wants to merge 3 commits into from

1 participant

@rmsilva

This patch add support to push/pull to VimOrganizer, so a user can synchronize with the Android / iOS MobileOrg applications. It uses the emacs for doing the export and import. Add 2 new entries to the Org Menu in VimOrganizer and uses the ,me (,mobile export) ,mi (,mobile import) keys sequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 28, 2012
  1. @rmsilva
Commits on Jan 9, 2013
  1. @rmsilva
Commits on Jan 10, 2013
  1. @rmsilva
This page is out of date. Refresh to see the latest.
View
7 _vimrc
@@ -44,6 +44,13 @@ let g:org_tags_alist='{@home(h) @work(w) @tennisclub(t)} {easy(e) hard(d)} {comp
let g:org_agenda_select_dirs=["~/desktop/org_files"]
let g:org_agenda_files = split(glob("~/desktop/org_files/org-mod*.org"),"\n")
+" MobileOrg specific variables needed to Push/Pull to the mobile application
+" for synchornization
+
+let g:org_mobile_directory=["~/desktop/org_files/mobile"]
+let g:org_mobile_files=["~/desktop/org_files/projects.org","~/desktop/org_files/personal.org"]
+let g:org_mobile_inbox_for_pull=["~/desktop/org_files/mobile/from-mobileorg.org"]
+
" ----------------------
" Emacs setup
" ----------------------
View
4 autoload/org.vim
@@ -179,6 +179,8 @@ function! org#CaptureBuffer()
echo 'Capture is not set up. Please read docs at :h vimorg-capture.'
return
endif
+ let l:savedbufn = bufname('%')
+ call org#SaveLocation()
if bufnr('_Org_Capture_') > 0
exec 'bwipeout! ' . bufnr('_Org_Capture_')
endif
@@ -196,6 +198,8 @@ function! org#CaptureBuffer()
normal ggVGd
normal i*
silent exec "normal o:<".org#Timestamp().">"
+ let pos = g:location[1]
+ silent exec "normal o[[file:".g:location[0]."#line=".pos[1]."]"."[".l:savedbufn."]]"
normal gg
set nomodified
startinsert!
View
39 doc/vimorg.txt
@@ -284,6 +284,45 @@ issuing the command manually within Emacs (alt-x server-start).
----------------------------------------------------------------------------
+INTERACTING WITH MOBILEORG AND VIMORGANIZER *vimorg-mobileorg-interaction*
+ *vimorg-mobileorg-setup*
+
+Vim/VimOrganizer allows users to synchronize with the MobileOrg applications. For
+this it uses Emacs client, so Emacs client need to be properly configure to
+use this feature. (see |vimorg-emacs-setup|)
+
+MobileOrg applications for iOS (http://mobileorg.ncogni.to/) or Android
+(https://github.com/matburt/mobileorg-android/wiki/) allow users to change,
+remove or capture on the mobile devices. But for that the user need to push their
+local agendas files and after pull to get the capture notes from the devices.
+
+For the VimOrganizer functions OrgExportToMobileOrg() and
+OrgImportFromMobileOrg() to work you need first to setup some variables in
+your vimrc file, e.g.:
+>
+ let g:org_mobile_directory = ["~/documents/org_files/mobile"]
+
+This will be the directory where the push command will create the index.org,
+checksum and other files to be fetch by the MobileOrg application.
+>
+ let g:org_mobile_files = ["~/documents/org_files/projects.org", "~/documents/org_files/personal.org"]
+
+This are the list of files that you want to synchronize with the MobileOrg,
+since you may not want all your .org files to be push.
+>
+ let g:org_mobile_inbox_for_pull =
+ ["~/documents/org_files/mobile/from-mobile.org"]
+
+This is the file where the MobileOrg will write the notes capture by you when
+on the move. Afterwards you will need to refile the notes where you desire.
+
+You can issue the push/pull using the Org menu entries for this or using the
+following shotcuts:
+,me Push/Export to MobileOrg
+,mi Pull/Import From MobileOrg
+
+----------------------------------------------------------------------------
+
CONVERSION BETWEEN ORG-MODE AND VIMORGANIZER *vimorg-orgmode-conversion*
In practice nothing may go drastically wrong if you don't have perfect
View
104 ftplugin/org.vim
@@ -7446,6 +7446,107 @@ function! OrgExportDashboard()
endfunction
+
+function! s:OrgHasMobileOrgVar()
+ let result = 1
+
+ if s:OrgHasEmacsVar() == 0
+ let result = 0
+ return result
+ endif
+
+ if !exists("g:org_mobile_files") || (g:org_mobile_files == []) || !exists("g:org_mobile_directory") || (g:org_mobile_directory == '') || !exists("g:org_mobile_inbox_for_pull") || (g:org_mobile_inbox_for_pull == '')
+ let msg = "=============================================== \n"
+ \ . "You're trying to call out to Emacs MobileOrg Push or Pull \n"
+ \ . "you haven't set the necessary variables. \n"
+ \ . "You should set this in your vimrc by including \n"
+ \ . "a line like: \n\n"
+ \ . " let g:org_mobile_directory=[directory where MobileOrg file will be pushed] \n\n"
+ \ . " let g:org_mobile_files=[agenda files that you would like to be pushed] \n\n"
+ \ . " let g:org_mobile_inbox_for_pull=[file in which will appear your pulls from MobileOrg] \n\n"
+ \ . "See :h vimorg-mobileorg-setup for more info. \n\n"
+ \ . "The call you attempted to Emacs will now be aborted. \n"
+ \ . "Revise your vimrc and restart Vim to use this feature.\n"
+ \ . "==============================================\n"
+ \ . "Press <enter> to continue."
+ call input(msg)
+ let result = 0
+ endif
+
+ return result
+endfunction
+
+function! s:OrgSetMobileOrgVar()
+ let org_mob_files = map(copy(g:org_mobile_files), '"\\" . "\"" . v:val . "\\" . "\""')
+ let orgpath = g:org_command_for_emacsclient . ' -n --eval '
+ let g:mypart1 = '(custom-set-variables ' . "\'" . '(org-mobile-files (list ' . join(org_mob_files) . '))'
+ let g:mypart1 .= ' ' . "\'" . '(org-mobile-directory \' . '"' . g:org_mobile_directory . '\' . '")'
+ let g:mypart1 .= ' ' . "\'" . '(org-mobile-inbox-for-pull \' . '"' . (g:org_mobile_inbox_for_pull) . '\' . '"))'
+
+ let orgcmd = orgpath . '"' . g:mypart1 . '"'
+ let g:orgcmd = orgcmd
+ echo "Setting mobile org variables... "
+ silent! execute '!' . orgcmd
+ echo "Setting mobile org variables... Done "
+endfunction
+
+function! OrgExportToMobileOrg()
+
+ if s:OrgHasMobileOrgVar() == 0
+ return
+ endif
+
+ call s:OrgSetMobileOrgVar()
+
+ let orgpath = g:org_command_for_emacsclient . ' -n --eval '
+ "need to close all opened buffers that belong to the mobile org list
+ let g:mypart1 = '(dolist (x org-mobile-files) (let((org-export-babel-evaluate t)(org-confirm-babel-evaluate nil)(buf (find-file x))) (progn (set-buffer buf)(revert-buffer t t t) (not-modified) (kill-this-buffer))))'
+ let orgcmd1 = orgpath . '"' . g:mypart1 . '"'
+ echo "Closing exporting files to mobile org... "
+ silent! execute '!' . orgcmd1
+ redraw
+
+ let g:mypart2 = ' (progn (org-mobile-push))'
+
+ let orgcmd = orgpath . '"' . g:mypart2 . '"'
+ let g:orgcmd = orgcmd
+ echo "Exporting to mobile org... "
+ silent! execute '!' . orgcmd
+ redraw
+ echo "Exporting to mobile org... Done "
+ redraw
+
+ "need to close all opened buffers
+ let g:mypart3 = '(dolist (x org-mobile-files) (let((org-export-babel-evaluate t)(org-confirm-babel-evaluate nil)(buf (find-file x))) (progn (set-buffer buf) (not-modified) (kill-this-buffer))))'
+ let orgcmd3 = orgpath . '"' . g:mypart3 . '"'
+ echo "Closing again exporting files to mobile org..."
+ silent! execute '!' . orgcmd3
+ redraw!
+ echo "Closing again exporting files to mobile org... Done "
+endfunction
+
+function! OrgImportFromMobileOrg()
+ if s:OrgHasMobileOrgVar() == 0
+ return
+ endif
+
+ call s:OrgSetMobileOrgVar()
+
+ let orgpath = g:org_command_for_emacsclient . ' -n --eval '
+ let g:myfilename = substitute(expand("%:p"),'\','/','g')
+ let g:myfilename = substitute(g:myfilename, '/ ','\ ','g')
+ let g:mypart1 = '(let ((org-export-babel-evaluate t)(org-confirm-babel-evaluate nil)'
+ let g:mypart1 .= '(buf (find-file \' . '"' . g:myfilename . '\' . '")) ) (progn '
+ let g:mypart2 = ' (set-buffer buf) (org-mobile-pull) (save-buffer) (kill-this-buffer)) )'
+ let orgcmd = orgpath . '"' . g:mypart1 . g:mypart2 . '"'
+ let g:orgcmd = orgcmd
+ redraw
+ echo "Import from mobile org... "
+ silent! execute '!' . orgcmd
+ redraw
+ echo "Import from mobile org...Done"
+endfunction
+
function! s:MailLookup()
Utl openlink https://mail.google.com/mail/?hl=en&shva=1#search/after:2010-10-24+before:2010-10-26
"https://mail.google.com/mail/?hl=en&shva=1#search/after%3A2010-10-24+before%3A2010-10-26
@@ -8349,6 +8450,9 @@ amenu &Org.-Sep6- :
amenu &Org.Open\ Capture\ Buffer :call org#CaptureBuffer()<cr>
amenu &Org.-Sep7- :
amenu &Org.Export/Publish\ w/Emacs :call OrgExportDashboard()<cr>
+amenu &Org.-Sep75- :
+amenu &Org.Push\ (export)\ Mobile\ Org\ w/Emacs :call OrgExportToMobileOrg()<cr>
+amenu &Org.Pull\ (import)\ Mobile\ Org\ w/Emacs :call OrgImportFromMobileOrg()<cr>
amenu &Org.-Sep8- :
amenu <silent> &Org.R&e-read\ Config\ Lines :call OrgProcessConfigLines()<cr>
View
4 ftplugin/vimorg-main-mappings.vim
@@ -59,6 +59,10 @@ nnoremap <localleader>pl :call s:MyPopup()<cr>
nnoremap <silent> <buffer> <localleader>et :call OrgTagsEdit()<cr>
+" MobileOrg push (export) / pull (import)
+noremap <silent> <buffer> <localleader>me :call OrgExportToMobileOrg()<cr>
+noremap <silent> <buffer> <localleader>mi :call OrgImportFromMobileOrg()<cr>
+
" clear search matching
nnoremap <silent> <buffer> <localleader>cs :let @/=''<cr>
Something went wrong with that request. Please try again.