Permalink
Browse files

moved CaptureBuffer() funcs to autoload (and put command in vimrc) pl…

…us bugfixes to void ^M chars in Windows and leaving capture file buf open when started out not open
  • Loading branch information...
1 parent d97a638 commit ae9a45682c296c5deef143d5dcd6f799dd7df3a0 @hsitz committed Dec 11, 2011
Showing with 54 additions and 58 deletions.
  1. +1 −0 _vimrc
  2. +42 −0 autoload/org.vim
  3. +11 −58 ftplugin/org.vim
View
@@ -11,6 +11,7 @@ filetype plugin indent on
" and then put these lines in vimrc somewhere after the line above
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
+command! OrgCapture :call org#CaptureBuffer()
"==============================================================
" THE UNNECESSARY STUFF"
View
@@ -151,5 +151,47 @@ function! org#RestoreLocation()
endfunction
+function! org#CaptureBuffer()
+ if !exists('g:org_capture_file') || empty(g:org_capture_file)
+ echo 'Capture is not set up. Please read docs at :h vimorg-capture.'
+ return
+ endif
+ sp _Org_Capture_
+ set ft=org
+ setlocal buftype=nofile
+ setlocal noswapfile
+ command! -buffer W :call <SID>ProcessCapture()
+ " below is the basic template
+ " a first level head with date timestamp
+ normal ggVGd
+ normal i*
+ silent exec "normal o:<".org#Timestamp().">"
+ normal gg
+ startinsert!
+
+endfunction
+function! s:ProcessCapture()
+ "normal ggVG"xy
+ let curbufnr = bufnr(g:org_capture_file)
+ if curbufnr == -1
+ exe '1,$write >> ' . g:org_capture_file
+ bw! _Org_Capture_
+ else
+ normal ggVG"xy
+ bw! _Org_Capture_
+ call org#SaveLocation()
+ call org#LocateFile(g:org_capture_file)
+ normal G"xp
+ silent write
+ call org#RestoreLocation()
+ endif
+ exe 'bwipeout! ' . g:org_capture_file
+
+endfunction
+
+command! EditAgendaFiles :call <SID>EditAgendaFiles()
+command! OrgCycleAgendaForward :call <SID>CycleAgendaFiles('forward')
+command! OrgCycleAgendaBackward :call <SID>CycleAgendaFiles('backward')
+command! OrgChooseOrgBuffer :call <SID>OrgGotoChosenFile()
View
@@ -89,6 +89,7 @@ hi MatchGroup guibg=yellow guifg=black
setlocal ignorecase " searches ignore case
setlocal smartcase " searches use smart case
setlocal autoindent
+setlocal fileformat=unix
setlocal backspace=2
setlocal nowrap
setlocal tw=78
@@ -145,6 +146,9 @@ endif
if !exists('g:org_save_when_searched')
let g:org_save_when_searched = 0
endif
+if !exists('g:org_capture_file')
+ let g:org_capture_file = ''
+endif
if !exists('g:org_tags_alist')
let g:org_tags_alist = ''
endif
@@ -188,7 +192,6 @@ let s:headline = ''
let g:org_ColumnHead = 'Lines'
let g:org_gray_agenda = 0
let g:org_sparse_lines_after = 10
-let g:org_capture_file=''
let g:org_log_todos=0
let g:org_timegrid=[8,20,2]
let w:v.org_colview_list = []
@@ -5399,10 +5402,10 @@ function! s:SetProp(key, val,...)
endif
endif
- "if exists("*Org_property_changed_functions") && (bufnr("%") != bufnr('Agenda'))
- " let Hook = function("Org_property_changed_functions")
- " silent execute "call Hook(line('.'),a:key, a:val)"
- "endif
+ if exists("*Org_property_changed_functions") && (bufnr("%") != bufnr('Agenda'))
+ let Hook = function("Org_property_changed_functions")
+ silent execute "call Hook(line('.'),a:key, a:val)"
+ endif
if a:0 >=2
"back to tab/window where setprop call was made
execute "tabnext ".curtab
@@ -5498,7 +5501,6 @@ function! s:OrgGotoChosenFile(...)
redraw
echo "Agenda files:"
echo "============================="
- "let nums = range(char2nr('0'), char2nr('9')) + range(char2nr('a'),char2nr('z'))
let nums = range(char2nr('a'),char2nr('z')) + range(char2nr('0'), char2nr('9'))
for i in range(0,len(bufnums)-1)
@@ -6559,57 +6561,6 @@ function! s:AgendaBufferOpen(new_win)
let &splitright = save_sr
endfunction
-function! s:CaptureBuffer()
- if !exists('g:org_capture_file') || empty(g:org_capture_file)
- echo 'Capture is not set up. Please read docs at :h vimorg-capture.'
- return
- endif
- let w:prevbuf=bufnr("%")
- sp _Org_Capture_
- set ft=org
- normal ggVGd
- normal i*
- silent exec "normal o:<".org#Timestamp().">"
- call s:ScratchBufSetup()
- command! -buffer W :call s:ProcessCapture()
- normal gg
- startinsert!
-
-endfunction
-function! s:ProcessCapture()
- "normal ggVG"xy
- let curbufnr = bufnr(g:org_capture_file)
- if curbufnr == -1
- exe '1,$write >> ' . g:org_capture_file
- bw! _Org_Capture_
- else
- normal ggVG"xy
- bw! _Org_Capture_
- call org#SaveLocation()
- call org#LocateFile(g:org_capture_file)
- normal G"xp
- silent write
- call org#RestoreLocation()
- endif
- "bw! _Org_Capture_
- "call org#SaveLocation()
-
- "call org#LocateFile(g:org_capture_file)
- "normal gg
- "let found = search('^\* CaptureItems','c')
- "if found == 0
- " normal i* CaptureItems
- "else
- " exec found
- "endif
- "execute s:OrgSubtreeLastLine()
- "normal p
- "silent wq "writes and quits g:org_capture_file
- "
- "call org#RestoreLocation()
-
-endfunction
-
command! EditAgendaFiles :call <SID>EditAgendaFiles()
command! OrgCycleAgendaForward :call <SID>CycleAgendaFiles('forward')
command! OrgCycleAgendaBackward :call <SID>CycleAgendaFiles('backward')
@@ -8288,8 +8239,10 @@ amenu &Org.-Sep5- :
amenu &Org.Narro&w.Outline\ &Subtree<tab>,ns :call NarrowOutline(line('.'))<cr>
amenu &Org.Narro&w.&Code\ Block<tab>,nc :call NarrowCodeBlock(line('.'))<cr>
amenu &Org.-Sep6- :
-amenu &Org.Export/Publish\ w/Emacs :call OrgExportDashboard()<cr>
+amenu &Org.Open\ Capture\ Buffer :call {sid}CaptureBuffer()<cr>
amenu &Org.-Sep7- :
+amenu &Org.Export/Publish\ w/Emacs :call OrgExportDashboard()<cr>
+amenu &Org.-Sep8- :
amenu <silent> &Org.R&e-read\ Config\ Lines :call OrgProcessConfigLines()<cr>
"*********************************************************************

0 comments on commit ae9a456

Please sign in to comment.