Skip to content
33 changes: 21 additions & 12 deletions ftplugin/org.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,7 @@ function! OrgNavigateLevels(direction)
let visible = s:IsVisibleHeading(dest)
if (dest > 0) && visible && (dest >= lowerlimit) && (dest <= upperlimit)
execute dest
execute 'normal ' . (strlen(substitute(getline("."), '^\(\**\).*$', '\1', '')) - 1) . 'l'
else
echo msg
endif
Expand Down Expand Up @@ -2039,9 +2040,12 @@ function! s:DoFullFold(headline)
endfunction
function! s:OrgCycle(headline)
let save_cursor = getpos(".")
let topline = line("w0")

let end = foldclosedend(a:headline)
if (end>0) && (s:Ind(end+1) <= s:Ind(a:headline))
call s:OrgExpandHead(a:headline)
let endline = end
elseif ((end == -1) && (s:Ind(s:OrgNextHead_l(a:headline)) > s:Ind(a:headline))
\ && (foldclosed(s:OrgNextHead_l(a:headline)) > 0))
let nextsamelevel = s:OrgNextHeadSameLevel_l(a:headline)
Expand All @@ -2062,7 +2066,13 @@ function! s:OrgCycle(headline)
else
call s:DoFullFold(a:headline)
endif

exe "normal! " . topline . "G"
normal zt
call setpos(".",save_cursor)
if exists('endline') && line('w$') < endline
normal ztkj
endif
endfunction
function! OrgCycle()
if getline(line(".")) =~ b:v.headMatch
Expand All @@ -2076,7 +2086,7 @@ function! OrgCycle()
endif
" position to top of screen with cursor in col 0
"normal! z.
normal! ztkj
"normal! ztkj
endfunction
let s:orgskipthirdcycle = 0
function! OrgGlobalCycle()
Expand Down Expand Up @@ -4214,7 +4224,7 @@ function! OrgSingleHeadingText(operation)
call OrgBodyTextOperation(l:startline,l:endline,a:operation)
endfunction

function! s:StarLevelFromTo(from, to)
function! StarLevelFromTo(from, to)
let save_cursor = getpos(".")
set fdm=manual
let b:v.levelstars = a:to
Expand Down Expand Up @@ -7502,15 +7512,14 @@ function! s:OrgCustomTodoHighlights()
endif
for item in keys(g:org_todo_custom_highlights)
let d = g:org_todo_custom_highlights
if has('gui_running')
let fg = get(d[item], 'guifg')
let bg = get(d[item], 'guibg')
exec 'hi! ' . item . ((fg>#'') ? ' guifg=' . fg : '') . ((bg>#'') ? ' guibg=' . bg : '')
else
let fg = get(d[item], 'ctermfg')
let bg = get(d[item], 'ctermfg')
exec 'hi! ' . item . ((fg>#'') ? ' ctermfg=' . fg : '') . ((bg>#'') ? ' ctermbg=' . bg : '')
endif
let attrs = has('gui_running') ?
\ ['gui', 'font', 'guifg', 'guibg', 'guisp',] :
\ ['term', 'cterm', 'ctermfg', 'ctermbg',]
let attr_str = ''
for attr in attrs
let attr_str .= get(d[item], attr, '') != '' ? ' ' . attr . '=' . get(d[item], attr) : ""
endfor
exec 'hi! ' . item . attr_str

" xxxx todo put back in containedins, do synclears? check order?
if bufname('%')=='__Agenda__'
Expand All @@ -7529,7 +7538,7 @@ function! s:OrgCustomTodoHighlights()
endif
endfor
"now put new match in
exec 'syntax match ' . item . ' ' . '+\*\+ \zs' . item . ' + containedin=DONETODO,NOTDONETODO,OL1,OL2,OL3,OL4,OL5,OL6'
exec 'syntax match ' . item . ' ' . '+\*\+ \zs' . item . ' +he=e-1 containedin=DONETODO,NOTDONETODO,OL1,OL2,OL3,OL4,OL5,OL6'
endif

endfor
Expand Down
3 changes: 3 additions & 0 deletions ftplugin/vimorg-agenda-mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
nnoremap <silent> <buffer> q :call OrgQuitAgenda()<cr>

nmap <buffer> <silent> <s-CR> :call {mysid}AgendaReplaceTodo()<CR>
if !has('gui_running')
nmap <silent> <buffer> <localleader>nt :call {mysid}AgendaReplaceTodo()<CR>
endif
nmap <silent> <buffer> <c-CR> :MyAgendaToBuf<CR>
nmap <silent> <buffer> <CR> :AgendaMoveToBuf<CR>
nmap <silent> <buffer> ,r :call OrgRunCustom({'redo_num': line('.'), 'type':'tags-todo', 'spec': g:org_search_spec})<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 @@ -199,6 +199,10 @@ nnoremap <silent> <buffer> gk :call OrgNaviMap("gk")<CR>
nnoremap <silent> <buffer> gj :call OrgNaviMap("gj")<CR>
nnoremap <silent> <buffer> gh :call OrgNaviMap("gh")<CR>
nnoremap <silent> <buffer> gl :call OrgNaviMap("gl")<CR>
nnoremap <silent> <buffer> g<Up> :call OrgNaviMap("gk")<CR>
nnoremap <silent> <buffer> g<Down> :call OrgNaviMap("gj")<CR>
nnoremap <silent> <buffer> g<Left> :call OrgNaviMap("gh")<CR>
nnoremap <silent> <buffer> g<Right> :call OrgNaviMap("gl")<CR>
nnoremap <silent> <buffer> <localleader>zu :call OrgNavigateLevels("up")<CR>
nnoremap <silent> <buffer> <localleader>zd :call OrgNavigateLevels("down")<CR>
nnoremap <silent> <buffer> <localleader>zl :call OrgNavigateLevels("left")<CR>
Expand Down