On Thu, Sep 13, 2012 at 12:02 AM, Ben Fritz <[email protected]> wrote:
> On Wednesday, September 12, 2012 10:03:09 AM UTC-5, Ben Fritz wrote:
>> On Wednesday, September 12, 2012 8:22:44 AM UTC-5, Karthick wrote:
>>
>> > Hello,
>> > I would like to modify the value of 'dir' option for a few specific
>> > files (e.g: all files in directory ~/Foo/). Had 'dir' been a buffer
>> > local option, it would have been a easy thing,
>> One workaround might be to set 'noswapfile' globally in your .vimrc, and set 
>> 'swapfile' locally on BufEnter, after setting the correct 'dir' option.
>
> I have some slow network shares, so I gave this idea a try to prevent using 
> them for swap files. It seems successful so far, but beware of the crash I 
> observed here: 
> https://groups.google.com/d/topic/vim_dev/ZcJEKqNsVRI/discussion
>
> Here's the code I came up with:
>
>     " Make slow network shares on Windows prefer not to use the file's 
> directory
>     " for swap files
>     if has('win32')
>       set noswapfile
>       autocmd BufReadPre * setlocal noswapfile
>       autocmd BufEnter {Z,U,W}:{/,\\}* set dir-=. dir+=.
>       " nested autocmd to enable swap files so SwapExists autocmds fire, too
>       autocmd BufEnter * nested setlocal swapfile
>       autocmd BufLeave {Z,U,W}:{/,\\}* set dir-=. dir^=.
>     endif
I think the basic assumption here is BufReadPre triggers execute
before swap file is created?

I tried to validate that with the following:

au BufReadPre TEMPTST call Check()
function Check()
   sleep 10
endfunction

:e TEMPTST
<type some chars>
" Now delete the buffer
:bd

" Reload buffer to test the autocmd
:e TEMPTST
BufReadPre will now trigger. I was monitoring the directory (in a file
explorer) and saw a swap file being created before the Check()
function returns.

-- 
You received this message from the "vim_use" 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

Reply via email to