> Alan G Isaac wrote: 
>> Suppose I have defined:: 
>>     imap <buffer> <unique> ;fn %<cr>\footnote{%<cr>}<cr>%<esc>-i 
>> in my tex_ai.vim file in my local ftplugin directory. 
>> I create the buffer ``:e c:\temp.tex`` 
>> then I leave the buffer by deleting it ``:bd`` 
>> and then later I decide to reopen it ``:e c:\temp.tex``. 
>> Now I get a bunch of E227 errors, saying the mapping already 
>> exists.  This must mean that there Vim tries to redefine the 
>> mapping. 
>> BUT I had tried to rule this out: at the top of my plugin 
>> I have:: 
>>     if exists("b:loaded_tex_ai") 
>>             finish 
>>     endif 
>>     let b:loaded_tex_ai=1 
>> But of course ``b:loaded_tex_ai`` is gone once I use ``:bd``. 


On Tue, 05 Dec 2006, "A.J.Mechelynck" apparently wrote: 
> It is not gone, it is just marked as "unlisted". ":ls!" (with exclamation 
> mark) will show you that the so-called "deleted" buffer is still around. 


But the *variable* ``b:loaded_tex_ai`` is cleared once I use ``:bd``.
Am I right?  (See below.)

There is one error in my description above.
I do not have any trouble with my imaps.
The problem is *only* with my vmaps and maps.
E.g., the following do not seem to clear when I delete the buffer:

map <buffer> <unique> ]] /\\\(sub\)\{0,1}section[[{]<cr>
vmap <buffer> <unique> ;fr "xc\frac{}<esc>"xPla{}<esc>i

And indeed this difference can be tested very easily at the 
command line: it has nothing to do with ftplugins and 
everything to do with whether maps and vmaps are cleared 
when the buffer is deleted.  They are not.  I thought they 
were supposed to be.  (See the quoted documents below.)

Specifically, is it a BUG that the buffer is "deleted" but 
the map or vmap that is local (!!) to that buffer is not cleared?
(I am not presuming it is a BUG, nor that I have correctly 
characterized what is going on; I'm just trying to understand.)


> What you can do is to merely "unload" the buffer (write it 
> to disk and edit something else in its stead).

I edit with hidden buffers.
So they are not unloaded when I edit something else.
But this does not matter:
the same errors appear if I do what you say.
This is consistent with the help documents.

Quoting from :h <buffer> ::

        Local mappings are also cleared when a buffer is 
        deleted, but not when it is unloaded.  Just like 
        local option values.

Quoting from :h :bd ::

        Actually, the buffer isn't completely deleted, it is 
        removed from the buffer list |unlisted-buffer| and 
        option values, variables and mappings/abbreviations 
        for the buffer are cleared.

Cheers,
Alan Isaac
using version 7.0


Reply via email to