Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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
" ----------------------
Expand Down
4 changes: 4 additions & 0 deletions autoload/org.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
39 changes: 39 additions & 0 deletions doc/vimorg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
110 changes: 109 additions & 1 deletion ftplugin/org.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
" Last Change: Qua, 24 Abr 2013 12:52:48 -0300
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
Expand Down Expand Up @@ -7408,6 +7408,10 @@ function! OrgExportDashboard()
let command_part2 = ' org-publish-' . mydict[key]
elseif item == 'g'
let command_part2 = ' org-babel-tangle'
elseif item == 'l'
let command_part2 = ' org-latex-export-to-latex'
elseif item == 'p'
let command_part2 = ' org-latex-export-to-pdf'
else
let command_part2 = ' org-export-as-' . mydict[key]
endif
Expand Down Expand Up @@ -7458,6 +7462,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
Expand Down Expand Up @@ -8361,6 +8466,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>

Expand Down
4 changes: 4 additions & 0 deletions ftplugin/vimorg-main-mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
17 changes: 16 additions & 1 deletion indent/org.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
" Last Change: Qui, 25 Abr 2013 19:38:28 -0300
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
Expand Down Expand Up @@ -32,6 +32,7 @@ setlocal nolisp
setlocal nosmartindent
setlocal autoindent
"setlocal indentkeys+=},=\\item,=\\bibitem
setlocal indentkeys+==+


" Only define the function once
Expand Down Expand Up @@ -63,6 +64,10 @@ function! GetOrgIndent(...)
let prevline = getline(prevnonblank(v:lnum-1))
endif

let g:org_indent_debug_cur=curline
let g:org_indent_debug_prev=prevline
let g:org_indent_debug_my_rule='no'

if (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
let b:v.suppress_list_indent = 0
let b:v.org_list_offset=0
Expand All @@ -85,6 +90,9 @@ function! GetOrgIndent(...)
" \ && (len(synstack(v:lnum-1,1))>0)
" \ && (synIDattr(synstack(v:lnum-1,1)[0],'name') == 'orgList')
" let b:v.suppress_list_indent = 0
"elseif curline =~ '^\s\+'
"(curline =~ '^\s\+'\([+\*#] \|[\d\+[.:)-] \)')
" let g:org_indent_debug_my_rule='yes'
elseif b:v.suppress_indent == 1
return indent(curline)
elseif b:v.suppress_list_indent == 1
Expand All @@ -103,9 +111,16 @@ function! GetOrgIndent(...)
elseif prevline =~ '^\s*\d\+[).\]:]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs\d\+[).\]:]\s\+\ze\S'))
elseif prevline =~ '^\s*[-+\*]\s\+\S'
let g:org_debug_i_am_here='yes'
let ind = ind + len(matchstr(prevline,'^\s*\zs[-+\*]\s\+\ze\S'))
if curline =~ '^\s*[-+\*]\s\+\S'
let lenmatch=len(matchstr(curline,'^\s*[-+\*]\s\+\S')
let ind=ind-lenmatch
let g:org_indent_debug_my_rule='yes'
endif
elseif (len(synstack(v:lnum,1))>0) && (synIDattr(synstack(v:lnum,1)[0],'name') == 'orgList')
let ind = len(matchstr(getline(v:lnum-1),'^\s*'))
else
endif

return ind
Expand Down