diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..e2a49d1
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: tpope
+custom: ["https://www.paypal.me/vimpope"]
diff --git a/README.markdown b/README.markdown
index aa05b2b..68eb584 100644
--- a/README.markdown
+++ b/README.markdown
@@ -33,7 +33,7 @@ installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
then simply copy and paste:
cd ~/.vim/bundle
- git clone git://github.com/tpope/vim-obsession.git
+ git clone https://github.com/tpope/vim-obsession.git
vim -u NONE -c "helptags vim-obsession/doc" -c q
## Self-Promotion
diff --git a/doc/obsession.txt b/doc/obsession.txt
index 5d302dd..f53525e 100644
--- a/doc/obsession.txt
+++ b/doc/obsession.txt
@@ -12,6 +12,10 @@ USAGE *obsession* *:Obsession*
it will be overwritten if and only if it looks like a
session file.
+ Set `g:obsession_no_bufenter` to disable saving the
+ session on |BufEnter|, improving performance at the
+ expense of safety.
+
:Obsession {dir} Invoke |:Obsession| on {dir}/Session.vim. Use "." to
write to a session file in the current directory.
@@ -29,7 +33,8 @@ STATUS INDICATOR *obsession-status*
*ObsessionStatus()*
Add %{ObsessionStatus()} to 'statusline', 'tabline', or 'titlestring' to get
an indicator when Obsession is active or paused. Pass an argument to override
-the text of the indicator and a second argument to override the text of the
-paused indictor.
+the text of the active indicator and a second argument to override the text of
+the paused indictor. By default, the active indicator is `[$]`, and the
+paused indicator is `[S]`.
vim:tw=78:et:ft=help:norl:
diff --git a/plugin/obsession.vim b/plugin/obsession.vim
index 2517430..e36729d 100644
--- a/plugin/obsession.vim
+++ b/plugin/obsession.vim
@@ -1,8 +1,9 @@
" obsession.vim - Continuously updated session files
" Maintainer: Tim Pope
" Version: 1.0
+" GetLatestVimScripts: 4472 1 :AutoInstall: obsession.vim
-if exists("g:loaded_obsession") || v:version < 700 || &cp
+if exists("g:loaded_obsession") || v:version < 704 || &cp
finish
endif
let g:loaded_obsession = 1
@@ -53,27 +54,47 @@ function! s:dispatch(bang, file) abort
endtry
endfunction
+function! s:doautocmd_user(arg) abort
+ if !exists('#User#' . a:arg)
+ return ''
+ else
+ return 'doautocmd User ' . fnameescape(a:arg)
+ endif
+endfunction
+
function! s:persist() abort
if exists('g:SessionLoad')
return ''
endif
let sessionoptions = &sessionoptions
if exists('g:this_obsession')
+ let tmp = g:this_obsession . '.' . getpid() . '.obsession~'
try
set sessionoptions-=blank sessionoptions-=options sessionoptions+=tabpages
- execute 'mksession! '.fnameescape(g:this_obsession)
- let body = readfile(g:this_obsession)
+ exe s:doautocmd_user('ObsessionPre')
+ execute 'mksession!' fnameescape(tmp)
+ let v:this_session = g:this_obsession
+ let body = readfile(tmp)
call insert(body, 'let g:this_session = v:this_session', -3)
call insert(body, 'let g:this_obsession = v:this_session', -3)
- call insert(body, 'let g:this_obsession_status = 2', -3)
- call writefile(body, g:this_obsession)
+ if type(get(g:, 'obsession_append')) == type([])
+ for line in g:obsession_append
+ call insert(body, line, -3)
+ endfor
+ endif
+ call writefile(body, tmp)
+ call rename(tmp, g:this_obsession)
let g:this_session = g:this_obsession
+ exe s:doautocmd_user('Obsession')
+ catch /^Vim(mksession):E11:/
+ return ''
catch
unlet g:this_obsession
let &l:readonly = &l:readonly
return 'echoerr '.string(v:exception)
finally
let &sessionoptions = sessionoptions
+ call delete(tmp)
endtry
endif
return ''
@@ -100,7 +121,11 @@ endfunction
augroup obsession
autocmd!
- autocmd BufEnter,VimLeavePre * exe s:persist()
+ autocmd VimLeavePre * exe s:persist()
+ autocmd BufEnter *
+ \ if !get(g:, 'obsession_no_bufenter') |
+ \ exe s:persist() |
+ \ endif
autocmd User Flags call Hoist('global', 'ObsessionStatus')
augroup END