Skip to content
Browse files

fixes so CaptureBuffer and EditAgendaFiles buf will quit properly reg…

…ardless of whether modified
  • Loading branch information...
1 parent f018a03 commit d0c49aa68ccc2e798b89c9a7358b303e5c1faaaa @hsitz committed Dec 11, 2011
Showing with 15 additions and 9 deletions.
  1. +1 −0 _vimrc
  2. +3 −0 autoload/org.vim
  3. +11 −9 ftplugin/org.vim
View
1 _vimrc
@@ -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()
+" let g:org_capture_file = '~/org_files/mycaptures.org'
command! OrgCapture :call org#CaptureBuffer()
"==============================================================
View
3 autoload/org.vim
@@ -158,6 +158,7 @@ function! org#CaptureBuffer()
endif
sp _Org_Capture_
autocmd BufWriteCmd <buffer> :call <SID>ProcessCapture()
+ autocmd BufLeave <buffer> :bwipeout
set ft=org
setlocal buftype=acwrite
setlocal noswapfile
@@ -168,12 +169,14 @@ function! org#CaptureBuffer()
normal i*
silent exec "normal o:<".org#Timestamp().">"
normal gg
+ set nomodified
startinsert!
endfunction
function! s:ProcessCapture()
"normal ggVG"xy
let curbufnr = bufnr(g:org_capture_file)
+ " check if capture file is already open or not
if curbufnr == -1
exe '1,$write >> ' . g:org_capture_file
bw! _Org_Capture_
View
20 ftplugin/org.vim
@@ -6573,8 +6573,8 @@ function! s:EditAgendaFiles()
tabnew Edit_Agenda_Files
call s:ScratchBufSetup()
set buftype=acwrite
- autocmd BufLeave <buffer> :call org#RestoreLocation()
- autocmd BufWriteCmd <buffer> :call <SID>SaveAgendaFiles()
+ autocmd BufLeave <buffer> :call <SID>SaveAgendaFiles(0)
+ autocmd BufWriteCmd <buffer> :call <SID>SaveAgendaFiles(1)
command! W :call s:SaveAgendaFiles()
let msg = "These are your current agenda files:"
let msg2 = "Org files in your 'g:org_agenda_select_dirs' are below."
@@ -6594,16 +6594,18 @@ function! s:EditAgendaFiles()
call append("$",dir_files)
endfor
endfunction
-function! s:SaveAgendaFiles()
+function! s:SaveAgendaFiles(save)
" saves edited file list into g:agenda_files
" yank files into @a
set nomodified
- normal gg/^-- jV/^-- ?^\S "ay
- let @a = substitute(@a,' ','\\ ','g')
- if @a[0] != '-'
- let g:agenda_files = split(@a,"\n")
- else
- let g:agenda_files=[]
+ if a:save == 1
+ normal gg/^-- jV/^-- ?^\S "ay
+ let @a = substitute(@a,' ','\\ ','g')
+ if @a[0] != '-'
+ let g:agenda_files = split(@a,"\n")
+ else
+ let g:agenda_files=[]
+ endif
endif
:bw
delcommand W

0 comments on commit d0c49aa

Please sign in to comment.
Something went wrong with that request. Please try again.