Tony,
>> function s:SID()
>> return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
> I don't understand the SID$ at the end
<sfile> inside a function returns function name (i.e. might be
'<SNR>18_SID') which is matched against pattern '<SNR>\d+_SID$', where
$ matches for end of line. Function matchstr returns the match, if we
only need a number we're specifying that segment with \zs and \ze
which set start and end of a match. In the end I get the following to
work, which is much simpler:
function s:SID()
return matchstr(expand('<sfile>'),'<SNR>\d\+_')
endfun
Honestly I don't know the scenario where we need the part after \ze in
the pattern from documentation. That part is probably here only to be
more clear for a reader.
Anyways, now I'm using s:SID() to put current <SID> into the string:
let b:undo_ftplugin = "call " . s:SID() . "UndoFTPlugin()"
And all operations required for clean up on undo go to function
s:UndoFTPlugin().
> Getting the "current script number" is feasible but not easy. If this works
> for you after testing, stay with it.
It works? Yes it does. But I'm looking for a convenient method of
calling functions from b:undo_ftplugin. If there is a plugins
framework and a standart mechanism of cleaning up a plugin then there
must be a standart way of calling functions on clean up. I'm afraid I
don't see it, if anyone knows it please point me out, because my
solution is only a workaround. If there isn't that kind of method I
think it should be added in the future versions of Vim.
P.S. Sorry I probably didn't mention earlier but the first thing to
try was expand("<SID>") which expands to empty string.
Regards,
Boris
--
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