Raimondi/delimitMate — pull request #96 by grota (2012-04-07 11:48:12+00:00)
Title: Avoid mapping in ExtraMappings when there's already a map.

I found a corner case in delimitMate that prevents @tpope's `vim-eunuch`'s plugin to work.

As you can see from https://github.com/tpope/vim-eunuch/blob/master/plugin/eunuch.vim#L14 `v:errmsg` is checked before deleting the file. I think this is correct behavior.
`:Unlink` didn't work on my system because `v:errmsg` was not empty. After some digging I tracked the source of the problem in delimitMate.

I use @tpope's `pathogen` do manage my plugins.

Basically there's a race condition between delimitMate and other plugins' mappings.

Let's take for example `UltiSnips`: https://github.com/SirVer/ultisnips/blob/master/plugin/UltiSnips.vim#L182
This plugin wants to map `` in insert mode:
`i * =UltiSnips_ListSnippets()`

So what happens in chronological order is that

1. my `.vimrc` is sourced
2. then all my plugins in `.vim/bundle`, and lets say `delimitMate` is loaded before `UltiSnips`
3. then all the `after` dirs are sourced.

during 2. above we call `DelimitMateDo` and all is ok, then `UltiSnips` comes in and maps ``, then `delimitMate`'s `BufNewFile,BufRead,BufEnter` autocommands call `DelimitMate` again, and here https://github.com/Raimondi/delimitMate/blob/master/plugin/delimitMate.vim#L353 we end up setting `v:errmsg`.

This then makes it impossible to call `:Unlink`.

My patch basically avoids calling a piece of code that, in that case, does nothing other than setting `v:errmsg`, but I guess we can also clear that variable at the end of `DelimitMateDo`.

I also put a `, 'i'` on line https://github.com/Raimondi/delimitMate/blob/master/plugin/delimitMate.vim#L393