Tuesday, January 8, 2013

Re: How to call a function from b:undo_ftplugin?

Boris Danilov wrote:

> The question is how to call a function on a ftplugin undo? As far as I
> understand, the universal method for undoing stuff is putting commands
> to b:undo_ftplugin, but I can't put either "s:Fun" or "<SID>Fun"
> there.
>
> "s:Fun" doesn't work because b:undo_ftplugin is executed in the other
> script file and "<SID>Fun" doesn't work because <SID> isn't expanded
> in strings but expanded in the other place where b:undo_ftplugin is
> being executed with :execute. Is there a function that will expand
> <SID> immediatelly and convert it to a string?
>
> Of course there is always a way to use :autocmd FileType to handle it
> manually, but then it makes me wonder why there is a mechanism of
> b:undo_ftplugin if I have to do it on my own.
>
> What I am missing there?

Right, since this is done with Vim scripts the script-local functions
cannot be easily called. Would be useful though.
For the time being you could use a global function with a unique name.

--
"Marriage is when a man and woman become as one; the trouble starts
when they try to decide which one"

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
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

No comments: