Hi James!
On Fr, 16 Apr 2010, James Vega wrote:
> IMO, that way would be performing automatic diffing of the recovered
> buffer with the on-disk file. If anything short of that is done, then
> the current behavior should be maintained.
Would the attached plugin be helpful? It uses the SwapExists autocommand
to create a diff buffer. Using the SwapExists autocommand works
differently it seems, therefore the plugin uses feedkeys() extensively.
regards,
Christian
--
Mann: Es ist doch immer wieder erstaunlich, daß die hübschesten
Mädchen die größten Idioten heiraten.
Frau: Liebling. Das ist das schönste Kompliment seit Jahren.
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Subscription settings: http://groups.google.com/group/vim_dev/subscribe?hl=en
" Vim plugin for diffing when swap file was found
" Maintainer: Christian Brabandt <[email protected]>
" Last Change: 2010-04-17
" Last Version: 0.2
" Exit quickly when:"{{{
" - this plugin was already loaded
" - when 'compatible' is set
if exists("b:loaded_recover") || &cp
finish
endif
let b:loaded_recover = 1"}}}
fu! <sid>Recover(on)
if a:on
call <sid>ModifySTL()
if !exists("s:old_vsc")
let s:old_vsc = v:swapchoice
endif
augroup Swap
au!
au SwapExists * :let v:swapchoice='r'|:let g:diff_file=1|exe "au
BufReadPost " expand('<afile>') " :call <sid>DiffRecoveredFile()"
augroup END
else
augroup Swap
au!
augroup end
if exists("s:old_vsc")
let v:swapchoice=s:old_vsc
endif
"call <sid>ResetSTL()
let g:diff_file=0
endif
endfu
fu! <sid>DiffRecoveredFile()
if exists("g:diff_file") && g:diff_file==1
" For some reason, this only works with feedkeys.
" I am not sure why.
call feedkeys(":diffthis\n", "t")
call feedkeys(":setl modified\n", "t")
call feedkeys(":let b:mod='recovered version'\n", "t")
call feedkeys(":noa vert new\n", "t")
call feedkeys(":0r #\n", "t")
call feedkeys(":f! " . escape(expand("<afile>")," ") . "\\ (on-disk\\
version)\n", "t")
call feedkeys(":diffthis\n", "t")
call feedkeys(":set bt=nowrite\n", "t")
call feedkeys(":let b:mod='unmodified version on-disk'\n", "t")
"call feedkeys(":redraw!\n", "t")
call feedkeys(":echo 'Found Swapfile, showing diff!'\n", "t")
unlet g:diff_file
" Delete Autocommand
call <sid>Recover(0)
endif
endfu
fu! <sid>EchoMsg(msg)
echohl WarningMsg
echomsg a:msg
echohl Normal
endfu
fu! <sid>ModifySTL()
:let s:ostl=&stl
:let &stl=substitute(&stl, '%f', "\\0 %{exists('b:mod')?('['.b:mod.']') :
''}", 'g')
endfu
fu! <sid>ResetSTL()
if exists("s:ostl")
let &stl=s:ostl
endif
endfu
"call <sid>Recover(0)
call <sid>Recover(1)
com! RecoverPluginEnable :call <sid>Recover(1)
com! RecoverPluginDisable :call <sid>Recover(0)